php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33463 Unexpected Paamayim Nekudotayim in Dynamic Static Method Call
Submitted: 2005-06-24 12:26 UTC Modified: 2005-06-24 12:44 UTC
Votes:12
Avg. Score:4.4 ± 1.2
Reproduced:10 of 11 (90.9%)
Same Version:3 (30.0%)
Same OS:0 (0.0%)
From: etienne at actrix dot co dot nz Assigned:
Status: Wont fix Package: Class/Object related
PHP Version: 5.0.4 OS: Windows XP Pro
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2005-06-24 12:26 UTC] etienne at actrix dot co dot nz
Description:
------------
Basically, a call to a static class method produces a parse error. Unexpected Paamayim Nekudotayim (::).

This sort of coding works on normal method calls, and object instantiation.

For example, the following works fine:

$name = "ClassName";
$instance = new $name();

^^ will create a new instance of ClassName;

or

public function method() {
//some code
}

$methodName = "method";
$methodName();

^^ will run method().

Reproduce code:
---------------
class ClassName {

public static function staticClassMethod() {
//some code
}

}

$name = "ClassName";
$name::staticClassMethod();


Expected result:
----------------
I expected php to call the method "staticClassMethod".

Actual result:
--------------
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM ...

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-24 12:44 UTC] tony2001@php.net
Use call_user_func() for that.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Tue Aug 29 15:01:52 2017 UTC