|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-09-20 13:29 UTC] git@php.net
[2021-09-20 13:29 UTC] git@php.net
-Status: Open
+Status: Closed
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 07:00:01 2025 UTC |
Description: ------------ With Enum, ReflectionMethod->getDeclaringClass() return a ReflectionClass object instead of ReflectionEnum. The RFC is unclear about that. But ReflectionEnum extends ReflectionClass, so the types are compatible and it's more logical. We are forced to use the enum_exists() function, and rebuild a new ExceptionEnum if we need ReflectionEnum. Test script: --------------- <?php Enum testEnum { case A; case B; public function foo () {} } $re = new ReflectionEnum(testEnum::class); $me = $re->getMethod('foo'); echo $me->getDeclaringClass()::class; echo "\n"; $rc = new ReflectionClass(testEnum::class); $mc = $re->getMethod('foo'); echo $mc->getDeclaringClass()::class; Expected result: ---------------- ReflectionEnum ReflectionEnum Actual result: -------------- ReflectionClass ReflectionClass