|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-04-20 05:30 UTC] johannes@php.net
[2007-04-20 08:26 UTC] flopin at webgarden dot cz
[2007-04-20 08:32 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 17:00:01 2025 UTC |
Description: ------------ It is not possible to create and assign new class instance to static variable in declaration of another class. Reproduce code: --------------- class A { public $dummy='AAA'; } class B { static $foo=new A(); } Expected result: ---------------- The variable B::$foo should contain an instance of class A, instead the parser returns error "Parse error: syntax error, unexpected T_NEW in /var/www/php6/test.php6 on line 6". It is possible to hack the problem with code like this: class A { public $dummy='AAA'; } class B { static $foo=null; static function prepare() { self::$foo = new A(); } } B::prepare(); but since i need to use this construct in my program widely, the code gets very crappy, buggy and unreadable