ID:               41141
 User updated by:  flopin at webgarden dot cz
 Reported By:      flopin at webgarden dot cz
-Status:           Bogus
+Status:           Open
 Bug Type:         Feature/Change Request
 Operating System: any
 PHP Version:      6CVS-2007-04-19 (snap)
 New Comment:

Of course this is not a bug, thats why i marked the report
Feature/Change Request. And since I see no logical reason why this
feature is not possible, it could be introduced to the language


Previous Comments:
------------------------------------------------------------------------

[2007-04-20 05:30:59] [EMAIL PROTECTED]

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

.

------------------------------------------------------------------------

[2007-04-19 23:57:17] flopin at webgarden dot cz

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




------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=41141&edit=1

Reply via email to