From: flopin at webgarden dot cz
Operating system: any
PHP version: 6CVS-2007-04-19 (snap)
PHP Bug Type: Feature/Change Request
Bug description: Class as static variable
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 bug report at http://bugs.php.net/?id=41141&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=41141&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=41141&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=41141&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=41141&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=41141&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=41141&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=41141&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=41141&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=41141&r=support
Expected behavior: http://bugs.php.net/fix.php?id=41141&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=41141&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=41141&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=41141&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41141&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=41141&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=41141&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=41141&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=41141&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=41141&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=41141&r=mysqlcfg