Bug #67709 [Opn->Nab]: Error calling static function on array declaration

From: Date: Tue, 29 Jul 2014 16:21:53 +0000
Subject: Bug #67709 [Opn->Nab]: Error calling static function on array declaration
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-186865@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67709&edit=1 ID: 67709 Updated by: requinix@php.net Reported by: simonettigo at gmail dot com Summary: Error calling static function on array declaration -Status: Open +Status: Not a bug Type: Bug Package: Scripting Engine problem Operating System: Ubuntu 12.10 PHP Version: 5.6.0RC2 Block user comment: N Private report: N New Comment: You can't call methods there - only constant expressions are allowed. Previous Comments: ------------------------------------------------------------------------ [2014-07-29 14:40:54] simonettigo at gmail dot com Description: ------------ Calling a static function inside an array declaration provides a syntax error. Test script: --------------- class Foo{ static function hello(){ echo "Hello world!"; } } class Bar{ public $message = array( 'foo' => Foo::hello() ); } $Bar = new Bar(); echo $bar->message['foo']; Expected result: ---------------- Hello world! Actual result: -------------- Fatal error: syntax error, unexpected '(', expecting ')' in php shell code on line 9 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=67709&edit=1

« previous php.bugs (#186865) next »