php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67709 Error calling static function on array declaration
Submitted: 2014-07-29 14:40 UTC Modified: 2014-07-29 16:21 UTC
From: simonettigo at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.6.0RC2 OS: Ubuntu 12.10
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: simonettigo at gmail dot com
New email:
PHP Version: OS:

 

 [2014-07-29 14:40 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-07-29 16:21 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2014-07-29 16:21 UTC] requinix@php.net
You can't call methods there - only constant expressions are allowed.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sat Oct 10 02:00:02 2026 UTC