diff options
Diffstat (limited to 'ext/reflection/tests/bug45139.phpt')
| -rw-r--r-- | ext/reflection/tests/bug45139.phpt | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/ext/reflection/tests/bug45139.phpt b/ext/reflection/tests/bug45139.phpt new file mode 100644 index 0000000000..6aa84263c6 --- /dev/null +++ b/ext/reflection/tests/bug45139.phpt @@ -0,0 +1,58 @@ +--TEST-- +Bug #45139 (ReflectionProperty returns incorrect declaring class) +--FILE-- +<?php + +class A { + private $foo; +} + +class B extends A { + protected $bar; + private $baz; + private $quux; +} + +class C extends B { + public $foo; + private $baz; + protected $quux; +} + +$rc = new ReflectionClass('C'); +$rp = $rc->getProperty('foo'); +var_dump($rp->getDeclaringClass()->getName()); // c + +$rc = new ReflectionClass('A'); +$rp = $rc->getProperty('foo'); +var_dump($rp->getDeclaringClass()->getName()); // A + +$rc = new ReflectionClass('B'); +$rp = $rc->getProperty('bar'); +var_dump($rp->getDeclaringClass()->getName()); // B + +$rc = new ReflectionClass('C'); +$rp = $rc->getProperty('bar'); +var_dump($rp->getDeclaringClass()->getName()); // B + +$rc = new ReflectionClass('C'); +$rp = $rc->getProperty('baz'); +var_dump($rp->getDeclaringClass()->getName()); // C + +$rc = new ReflectionClass('B'); +$rp = $rc->getProperty('baz'); +var_dump($rp->getDeclaringClass()->getName()); // B + +$rc = new ReflectionClass('C'); +$rp = $rc->getProperty('quux'); +var_dump($rp->getDeclaringClass()->getName()); // C + +?> +--EXPECT-- +string(1) "C" +string(1) "A" +string(1) "B" +string(1) "B" +string(1) "C" +string(1) "B" +string(1) "C" |
