Skip to content

Commit 9bbb9e5

Browse files
committed
Merge branch 'PHP-7.1' into PHP-7.2
2 parents 3a236d0 + c97b8bb commit 9bbb9e5

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
@@ -45,6 +45,8 @@ PHP NEWS
4545
- Reflection:
4646
. Fixed bug #76536 (PHP crashes with core dump when throwing exception in
4747
error handler). (Laruence)
48+
. Fixed bug #75231 (ReflectionProperty#getValue() incorrectly works with
49+
inherited classes). (Nikita)
4850

4951
- Standard:
5052
. 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
@@ -5531,7 +5531,7 @@ ZEND_METHOD(reflection_property, getValue)
55315531
return;
55325532
}
55335533

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

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)