From: php at vladathome dot com Operating system: Linux PHP version: 5.0.0 PHP Bug Type: Zend Engine 2 problem Bug description: can't call constructor in class definition
Description: ------------ In most (all?) other OOP-oriented languages, it's a common paradigm to define a class and provide a static member of the class in the definition and initialize it with a new object of the class. This is commonly used to implement singletons which are a must for many projects. This doesn't seem to work with PHP5. Reproduce code: --------------- <?php class Foo { static $me = new Foo(); public function __construct() { } } ?> Expected result: ---------------- Parse error: parse error, unexpected T_NEW in /u1/home/vlad/php/test/3.php on line 3 Actual result: -------------- created static member of the class with the initialized object -- Edit bug report at http://bugs.php.net/?id=29377&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29377&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=29377&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=29377&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=29377&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=29377&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=29377&r=needscript Try newer version: http://bugs.php.net/fix.php?id=29377&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=29377&r=support Expected behavior: http://bugs.php.net/fix.php?id=29377&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=29377&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=29377&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=29377&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29377&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=29377&r=dst IIS Stability: http://bugs.php.net/fix.php?id=29377&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=29377&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=29377&r=float