mirror of
https://github.com/php/php-src.git
synced 2024-11-28 12:26:37 +08:00
MFH: Fixed bug #48336 (ReflectionProperty::getDeclaringClass() does not
work with redeclared property) (patch by Markus dot Lidel at shadowconnect dot com)
This commit is contained in:
parent
9aca3c04a0
commit
5c5dcf5e7a
@ -4603,6 +4603,10 @@ ZEND_METHOD(reflection_property, getDeclaringClass)
|
||||
break;
|
||||
}
|
||||
ce = tmp_ce;
|
||||
if (tmp_ce == tmp_info->ce) {
|
||||
/* declared in this class, done */
|
||||
break;
|
||||
}
|
||||
tmp_ce = tmp_ce->parent;
|
||||
}
|
||||
|
||||
|
44
ext/reflection/tests/bug48336.phpt
Normal file
44
ext/reflection/tests/bug48336.phpt
Normal file
@ -0,0 +1,44 @@
|
||||
--TEST--
|
||||
Bug #48286 (ReflectionProperty::getDeclaringClass() does not work with redeclared properties)
|
||||
--FILE--
|
||||
<?php
|
||||
class A {
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
static protected $prop;
|
||||
}
|
||||
|
||||
class C extends B {
|
||||
static protected $prop;
|
||||
}
|
||||
|
||||
class D extends C {
|
||||
}
|
||||
|
||||
class E extends D {
|
||||
}
|
||||
|
||||
class F extends E {
|
||||
static protected $prop;
|
||||
}
|
||||
|
||||
$class = 'A';
|
||||
for($class = 'A'; $class <= 'F'; $class ++) {
|
||||
print($class.' => ');
|
||||
try {
|
||||
$rp = new ReflectionProperty($class, 'prop');
|
||||
print($rp->getDeclaringClass()->getName());
|
||||
} catch(Exception $e) {
|
||||
print('N/A');
|
||||
}
|
||||
print("\n");
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
A => N/A
|
||||
B => B
|
||||
C => C
|
||||
D => C
|
||||
E => C
|
||||
F => F
|
Loading…
Reference in New Issue
Block a user