ID: 38028 Updated by: [EMAIL PROTECTED] Reported By: rapsys at free dot fr -Status: Open +Status: Bogus Bug Type: Feature/Change Request -Operating System: Mandriva Linux 2007 (Cooker) +Operating System: * -PHP Version: 5.1.4 +PHP Version: 5.* -Assigned To: +Assigned To: helly New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Use reflection api Previous Comments: ------------------------------------------------------------------------ [2006-07-07 02:32:17] rapsys at free dot fr Description: ------------ I noticed a limitation in (at least) latest version of php. It's impossible to iterate the const or static member of a class. The only possible (but REALY too hard) whould be to use the reflector propriety. I don't know if it's a feature to add or a missing explanation in documentation. But if it's not supported at all, it should be reported as a lack of feature in documentation and scheduled for php6 ? Reproduce code: --------------- <?php //The class class someclass { //The constant const someconst = 'somevalue'; //The public static member public static $somepublicstatic = 'somevalue'; //The protected static member protected static $someprotectedstatic = 'somevalue'; //The private static member private static $someprivatestatic = 'somevalue'; //A function to list static or const members public static function somefunction() { //Try to iterate const or static member foreach(self as $key => $value) echo "$key = $value\n"; } } echo "static function list:\n"; someclass::somefunction(); echo "external list:\n"; foreach(someclass as $key => $value) echo "$key = $value\n"; ?> Expected result: ---------------- static function list: someconst = somevalue somepublicstatic = somevalue someprotectedstatic = somevalue someprivatestatic = somevalue external list: someconst = somevalue somepublicstatic = somevalue Actual result: -------------- static function list: PHP Notice: Use of undefined constant self - assumed 'self' in /var/www/web/test.php on line 17 Notice: Use of undefined constant self - assumed 'self' in /var/www/web/test.php on line 17 PHP Warning: Invalid argument supplied for foreach() in /var/www/web/test.php on line 17 Warning: Invalid argument supplied for foreach() in /var/www/web/test.php on line 17 external list: PHP Notice: Use of undefined constant someclass - assumed 'someclass' in /var/www/web/test.php on line 25 Notice: Use of undefined constant someclass - assumed 'someclass' in /var/www/web/test.php on line 25 PHP Warning: Invalid argument supplied for foreach() in /var/www/web/test.php on line 25 Warning: Invalid argument supplied for foreach() in /var/www/web/test.php on line 25 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38028&edit=1