#48286 [Bgs]: ReflectionProperty::getDeclaringClass() does not work with redeclared properties
| From: | Markus dot Lidel at shadowconnect dot com | Date: | Thu, 14 May 2009 22:19:52 +0000 |
| Subject: | #48286 [Bgs]: ReflectionProperty::getDeclaringClass() does not work with redeclared properties | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-137345@lists.php.net to get a copy of this message | ||
ID: 48286
User updated by: Markus dot Lidel at shadowconnect dot com
Reported By: Markus dot Lidel at shadowconnect dot com
Status: Bogus
Bug Type: Reflection related
Operating System: *
PHP Version: 5.*, 6CVS (2009-05-14)
New Comment:
Thank you for you fast response.
But how do you find out, if the property is redeclard in a derived
class?
Note: ReflectionProperty::getDeclaringClass() also displays A if
property is static. Shouldn't getDeclaringClass() in this case display
the class from which the value is retrieved?
BTW, ReflectionMethod::getDeclaringClass() works as expected (displays
B). Although i don't know the internals, it is a bit confusing that two
identically named functions behave differently.
Previous Comments:
------------------------------------------------------------------------
[2009-05-14 21:51:55] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
It is declared in A, the 2nd declaration has no actual effect when the
class is being bound.
------------------------------------------------------------------------
[2009-05-14 20:29:15] Markus dot Lidel at shadowconnect dot com
Description:
------------
ReflectionProperty::getDeclaringClass() called on derived properties
always return the class where the property was first defined, instead of
the class where the property was redeclared. If $prop is private it
works. (properly related to #39104)
Reproduce code:
---------------
class A
{
protected $prop;
}
class B extends A
{
protected $prop;
}
$rp = new ReflectionProperty('B', 'prop');
echo $rp->getDeclaringClass()->getName();
Expected result:
----------------
B
Actual result:
--------------
A
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=48286&edit=1