#29986 [NEW]: Class constants won't work with predefined constants when using ReflectionClass

From: Date: Sun, 05 Sep 2004 13:40:24 +0000
Subject: #29986 [NEW]: Class constants won't work with predefined constants when using ReflectionClass
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-65759@lists.php.net to get a copy of this message
From: mitchel at sahertian dot com Operating system: Linux 2.6.8.1 x86 PHP version: 5.0.1 PHP Bug Type: Zend Engine 2 problem Bug description: Class constants won't work with predefined constants when using ReflectionClass Description: ------------ I have a variable classname i have to get a constant/static property from. ${$classname}::stuff doesn't work, so i have to use the reflection api. This works for strings and numbers, but when i try to use getConstant() upon a constant that is defined as another constant, it returns UNKNOWN:0. This happens for user defined constants as well as things like `true'. Reproduce code: --------------- <?php define("FOOBAR",0x0008): class Myclass { const foo = true; const bar = FOOBAR; const works = "yes it does"; } $o=new ReflectionClass("MyClass"); var_dump($o->getConstant("foo")); var_dump($o->getConstant("bar")); var_dump($o->getConstant("works")); ?> Expected result: ---------------- bool(true) int(8) string(11) "yes it does" Actual result: -------------- UNKNOWN:0 UNKNOWN:0 string(11) "yes it does" -- Edit bug report at http://bugs.php.net/?id=29986&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29986&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=29986&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=29986&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=29986&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=29986&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=29986&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=29986&r=needscript Try newer version: http://bugs.php.net/fix.php?id=29986&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=29986&r=support Expected behavior: http://bugs.php.net/fix.php?id=29986&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=29986&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=29986&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=29986&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29986&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=29986&r=dst IIS Stability: http://bugs.php.net/fix.php?id=29986&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=29986&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=29986&r=float

« previous php.bugs (#65759) next »