php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77325 ReflectionClassConstant::$class returns wrong class when extending
Submitted: 2018-12-20 13:43 UTC Modified: 2018-12-20 23:37 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: me at vasekpurchart dot cz Assigned:
Status: Open Package: Reflection related
PHP Version: 7.2 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: me at vasekpurchart dot cz
New email:
PHP Version: OS:

 

 [2018-12-20 13:43 UTC] 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).


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-12-20 23:37 UTC] cmb@php.net
-PHP Version: 7.3.0 +PHP Version: 7.2
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Mar 20 11:01:27 2019 UTC