Bug #77325 [NEW]: ReflectionClassConstant::$class returns wrong class when extending

From: Date: Thu, 20 Dec 2018 13:43:03 +0000
Subject: Bug #77325 [NEW]: ReflectionClassConstant::$class returns wrong class when extending
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-218528@lists.php.net to get a copy of this message
From: me at vasekpurchart dot cz Operating system: PHP version: 7.3.0 Package: Reflection related Bug Type: Bug Bug description:ReflectionClassConstant::$class returns wrong class when extending 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 bug report at https://bugs.php.net/bug.php?id=77325&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77325&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77325&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77325&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=77325&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=77325&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=77325&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=77325&r=needscript Try newer version: https://bugs.php.net/fix.php?id=77325&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=77325&r=support Expected behavior: https://bugs.php.net/fix.php?id=77325&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=77325&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=77325&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=77325&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77325&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=77325&r=dst IIS Stability: https://bugs.php.net/fix.php?id=77325&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=77325&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=77325&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=77325&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=77325&r=mysqlcfg

« previous php.bugs (#218528) next »