|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77295 Class 'static' not found (parent and self too)
Submitted: 2018-12-13 18:40 UTC Modified: 2021-09-02 13:27 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: Assigned: nikic (profile)
Status: Assigned Package: Class/Object related
PHP Version: All OS: Irrelevant
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
26 - 25 = ?
Subscribe to this entry?

 [2018-12-13 18:40 UTC]
When calling dynamically a static method, with array('static', 'method'), from the right class context, PHP emits an error 'Class 'static' not found'.

Using call_user_func($method); with the same array, leads to the correct call to the method. 

The same problem applies to 'self' and 'parent'.

Test script:

class x {   
  static function a() {
  	  // display the current class
     echo __METHOD__;

  static function b($method) {
  	  // display the current class with method a above
          // This stops with a Fatal Error

(new x)->b(array('static', 'a'));

Expected result:

Actual result:
Fatal error: Uncaught Error: Class 'static' not found


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-01-02 11:25 UTC]
-Status: Open +Status: Verified -PHP Version: 7.3.0 +PHP Version: All
 [2019-01-02 11:25 UTC]
Not a big fan of this, but we probably should support it for parity with call_user_func.
 [2021-09-02 13:27 UTC] would resolve this inconsistency by consistently not supporting it.
 [2021-09-02 13:27 UTC]
-Status: Verified +Status: Assigned -Assigned To: +Assigned To: nikic
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Oct 26 06:03:34 2021 UTC