#45210 [Opn->Csd]: Support for (static) property initilialization is limited

From: Date: Wed, 05 Nov 2008 07:41:39 +0000
Subject: #45210 [Opn->Csd]: Support for (static) property initilialization is limited
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-1331@lists.php.net to get a copy of this message
ID: 45210 Updated by: torben@php.net Reported By: jaap dot taal at gmail dot com -Status: Open +Status: Closed Bug Type: Documentation problem Operating System: Windows PHP Version: Irrelevant New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. I've added a note that static properties are like other static variables in PHP in that they may not be initialized using expressions. It would not make sense to document this for PHP 4 classes since in PHP 4 there was no language support for static properties. However, I will look over the static keyword documentation to see whether this could use further clarification there as well. Previous Comments: ------------------------------------------------------------------------ [2008-06-08 21:43:52] jaap dot taal at gmail dot com Description: ------------ Somehow initializing properties has it's limitations. I think my example should have worked just fine (it would've worked in Java C# and a lot of other language). However, the limitation is there, but I can't find it in the documentation! I think it should be under both Classes and Objects (PHP 4) and Classes and Objects (PHP 5). Reproduce code: --------------- <?php class TestClass { public static function somefunc() { return 'somevalue'; } public static $someProperty = TestClass::somefunc(); // PARSE ERROR protected static $singleton = new TestClass(); // PARSE ERROR public $someVar = new TestClass(); // PARSE ERROR } Expected result: ---------------- No errors or limitations documented. Actual result: -------------- Parse error: syntax error, unexpected '(', expecting ',' or ';' in D:\www\binding\test.php on line 6 Parse error: syntax error, unexpected T_NEW in D:\www\binding\test.php on line 7 Parse error: syntax error, unexpected T_NEW in D:\www\binding\test.php on line 8 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=45210&edit=1

« previous php.doc.bugs (#1331) next »