Req #74245 [NEW]: No other ways to get all constants from class but using reflection

From: Date: Tue, 14 Mar 2017 10:09:12 +0000
Subject: Req #74245 [NEW]: No other ways to get all constants from class but using reflection
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-207822@lists.php.net to get a copy of this message
From: rusbik91 at gmail dot com Operating system: Ubuntu 16.04 PHP version: 7.1.2 Package: Performance problem Bug Type: Feature/Change Request Bug description:No other ways to get all constants from class but using reflection Description: ------------ There is no other ways to get constants list from class but using reflection, that is really slow (look at example 1). For properties of class i can do it by using get_object_vars() and it is fast (look at example 2). Why we need it? PHP lacks of enum construction and we have to implement it via const. If we want to get all enum values (like dictionary), so we need to use damned ReflectionClass. Would be very nice if we can get all const values by quick simple function. btw, getConstants even does not have documentation, so you see how bad it is. Test script: --------------- example 1: http://sandbox.onlinephpfunctions.com/code/e4d114eb2e339be4c6fc5d3a17877d96fbfbcc38 example 2: http://sandbox.onlinephpfunctions.com/code/8d0f8dcc733804fd2f78677bf6e2ac70bd942852 -- Edit bug report at https://bugs.php.net/bug.php?id=74245&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74245&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74245&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74245&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=74245&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=74245&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=74245&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=74245&r=needscript Try newer version: https://bugs.php.net/fix.php?id=74245&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=74245&r=support Expected behavior: https://bugs.php.net/fix.php?id=74245&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=74245&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=74245&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=74245&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74245&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=74245&r=dst IIS Stability: https://bugs.php.net/fix.php?id=74245&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=74245&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=74245&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=74245&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=74245&r=mysqlcfg

« previous php.bugs (#207822) next »