Skip to content

Commit 04824aa

Browse files
committed
Merge branch 'PHP-7.2'
2 parents 1b66ba1 + 9bbb9e5 commit 04824aa

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ PHP NEWS
5555
- Reflection:
5656
. Fixed bug #76536 (PHP crashes with core dump when throwing exception in
5757
error handler). (Laruence)
58+
. Fixed bug #75231 (ReflectionProperty#getValue() incorrectly works with
59+
inherited classes). (Nikita)
5860

5961
- Standard:
6062
. Fixed bug #76505 (array_merge_recursive() is duplicating sub-array keys).

ext/reflection/php_reflection.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5455,7 +5455,7 @@ ZEND_METHOD(reflection_property, getValue)
54555455
return;
54565456
}
54575457

5458-
if (!instanceof_function(Z_OBJCE_P(object), ref->ce)) {
5458+
if (!instanceof_function(Z_OBJCE_P(object), ref->prop.ce)) {
54595459
_DO_THROW("Given object is not an instance of the class this property was declared in");
54605460
/* Returns from this function */
54615461
}

ext/reflection/tests/bug75231.phpt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
Bug #75231: ReflectionProperty#getValue() incorrectly works with inherited classes
3+
--FILE--
4+
<?php
5+
class A
6+
{
7+
public $prop;
8+
public function __construct()
9+
{
10+
$this->prop = 'prop';
11+
}
12+
public function method()
13+
{
14+
return 'method';
15+
}
16+
}
17+
class B extends A
18+
{
19+
}
20+
print_r((new ReflectionMethod(B::class, 'method'))->invoke(new A()).PHP_EOL);
21+
print_r((new ReflectionProperty(B::class, 'prop'))->getValue(new A()).PHP_EOL);
22+
?>
23+
--EXPECT--
24+
method
25+
prop

0 commit comments

Comments
 (0)