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

 ID:                 53386
 User updated by:    lifinsky at yandex dot ru
 Reported by:        lifinsky at yandex dot ru
 Summary:            Allow use funtion or class for rvalue of static
                     variable
 Status:             Open
 Type:               Feature/Change Request
 Package:            Scripting Engine problem
 PHP Version:        5.3.3
 Block user comment: N
 Private report:     N

 New Comment:

Description:

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

Now language allow only constant for static variable in function (static
$a = 0).

Please allow functionality such as in C++



Test script:

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

class testA {

        private function __construct(){}

        public static function getInstance() {

                static $a = new testA();

                return $a;

        }



        public function a() {

                return 5;

        }

}



$a = testA::getInstance();

echo $a->a();

exit;



Expected result:

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

5



Actual result:

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

fatal error

PHP Parse error:  syntax error, unexpected T_NEW


Previous Comments:
------------------------------------------------------------------------
[2010-11-23 14:55:42] lifinsky at yandex dot ru

Description:
------------
Now language allow only constant for static variable in function (static
$a = 0).

Please allow functionality such as in C++

Test script:
---------------
class testA {

        private function __constructor(){}

        public static function getInstance() {

                static $a = new testA();

                return $a;

        }



        public function a() {

                return 5;

        }

}



$a = testA::getInstance();

echo $a->a();

exit;

Expected result:
----------------
5

Actual result:
--------------
fatal error

PHP Parse error:  syntax error, unexpected T_NEW


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



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

Reply via email to