Req #81440 [NEW]: Missing reflection information for BackedEnums

From: Date: Wed, 15 Sep 2021 11:51:34 +0000
Subject: Req #81440 [NEW]: Missing reflection information for BackedEnums
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236621@lists.php.net to get a copy of this message
From: bpolaszek at gmail dot com Operating system: PHP version: 8.1.0RC1 Package: Class/Object related Bug Type: Feature/Change Request Bug description:Missing reflection information for BackedEnums Description: ------------ Hello there, Newly introduced enums come with a reflection API so that we can be aware of what "type" of enum we're dealing with. Regarding backed enums, I just noticed that we are not able, given an enum class (as opposed to an enum case), to determine if cases will be string or integers. We can debug that by doing var_dump((new ReflectionEnum(SomeIntegerOrStringBackedEnum::class))->getBackingType()), and the information will be displayed by debugging the corresponding ReflectionNamedType through the name property, but that property unfortunately has no accessors. Could it be public? Use case is for denormalizing from PDO, which can return strings instead of integers depending of user configuration, using BackedEnum::from method, by knowing in advance if the target enum expects an int or a string. Is it something fixable before stable release? Thanks, Ben -- Edit bug report at https://bugs.php.net/bug.php?id=81440&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=81440&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=81440&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=81440&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=81440&r=needscript Try newer version: https://bugs.php.net/fix.php?id=81440&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=81440&r=support Expected behavior: https://bugs.php.net/fix.php?id=81440&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=81440&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=81440&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=81440&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=81440&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=81440&r=dst IIS Stability: https://bugs.php.net/fix.php?id=81440&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=81440&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=81440&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=81440&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=81440&r=mysqlcfg

« previous php.bugs (#236621) next »