Bug #77325 [Opn->Csd]: ReflectionClassConstant::$class returns wrong class when extending
| From: | nikic@php.net | Date: | Fri, 28 Feb 2020 16:21:39 +0000 |
| Subject: | Bug #77325 [Opn->Csd]: ReflectionClassConstant::$class returns wrong class when extending | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-225797@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77325&edit=1
ID: 77325
Updated by: nikic@php.net
Reported by: me at vasekpurchart dot cz
Summary: ReflectionClassConstant::$class returns wrong class
when extending
-Status: Open
+Status: Closed
Type: Bug
Package: Reflection related
PHP Version: 7.2
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=0d06a63ee311270a25bc0147271215c3ad90eba0
Log: Fixed bug #77325
Previous Comments:
------------------------------------------------------------------------
[2018-12-20 13:43:03] me at vasekpurchart dot cz
Description:
------------
The property ReflectionClassConstant::$class is documented as:
http://php.net/manual/en/class.reflectionclassconstant.php#reflectionclassconstant.props
> Name of the class where the class constant is defined.
When using a hierarchy of classes and having constants defined on multiple levels this does return
the child class where the constant is not defined.
Although using ReflectionClassConstant::getDeclaringClass() returns the correct one. In fact these
two should point to the same class.
Test script:
---------------
https://3v4l.org/f0WZf
Expected result:
----------------
ReflectionClassConstant::class should return the class where the constant is really declared as
stated in the docs.
This would also mean, that $constant->class === $constant->getDeclaringClass()->getName()
is true.
This would also bring the constants in line with methods and properties, where this works correctly
(as can be seen for example here https://3v4l.org/rqUF2).
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77325&edit=1