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

>And since I see no logical reason why this feature is not possible, 
>it could be introduced to the language.
Of course there is a logical explanation - there are two stages:
1) compilation
2) execution

Classes and their static properties are declared during the
compilation, no code can be run at this stage.
Objects are created during the execution.
Therefore it's not possible to use expressions when declaring class
properties unless someone wants to rewrite whole engine from scratch.


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

[2007-04-20 08:26:03] flopin at webgarden dot cz

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

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

[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