From: dan at wep dot net Operating system: Linux (Redhat 9, 2.4.22) PHP version: 5CVS-2003-10-10 (dev) PHP Bug Type: Class/Object related Bug description: Class constants of type array hold directly inaccessible keys/values
Description: ------------ Constants defined inside classes can be defined as an array prepopulated with key, value pairs; however this data is not directly accessible. It is possible to create a local variable copy of the constant at runtime and use it to access the data. If class constants are not meant to be able to hold array data, then a parse error should of been thrown on the 'const' declaration. Reproduce code: --------------- class test { const someData = array('foo' => 'bar'); function __construct() { $dataCopy = someData; print($dataCopy['foo']); // This works print(var_dump(someData)); // This works (shows all array information) print(someData['foo']); // This throws a parse error } } $obj = new test(); Expected result: ---------------- bar bar bar .. Jackpot! :) Actual result: -------------- Parse error: parse error, unexpected '[' -- Edit bug report at http://bugs.php.net/?id=25816&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=25816&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=25816&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=25816&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=25816&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=25816&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=25816&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=25816&r=support Expected behavior: http://bugs.php.net/fix.php?id=25816&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=25816&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=25816&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=25816&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25816&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=25816&r=dst IIS Stability: http://bugs.php.net/fix.php?id=25816&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=25816&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=25816&r=float