|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #60687 add call support to variables methods 'class::method' (spl_autoload also)
Submitted: 2012-01-08 18:17 UTC Modified: 2015-06-26 12:36 UTC
From: xenogenesi at virgilio dot it Assigned: cmb (profile)
Status: Closed Package: Class/Object related
PHP Version: 5.3.8 OS: GNU linux/Debian
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: xenogenesi at virgilio dot it
New email:
PHP Version: OS:


 [2012-01-08 18:17 UTC] xenogenesi at virgilio dot it
variables static class::method (with autoload support) maybe useful to wrap native vs php implementation (using function_exists) with clean O(1) code

if (function_exists('native_f'))
   $f = 'native_f';
   $f = 'class::static_f';

// some other file...
   global $f;

// current workaround (slow 'n dirty)
$f = function() { return forward_static_call_array('class::static_f',func_get_args()); };

Test script:
class maybe_or_not {
	public static function f($a, $b) { return $a + $b; }
$f = "maybe_or_not::f";
printf("%d\n",$f(1,1)); // DON'T WORK (even if the class is already loaded)

Expected result:

Actual result:
PHP Fatal error:  Call to undefined function maybe_or_not::f() in index.php


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-06-26 12:36 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2015-06-26 12:36 UTC]
Fixed for PHP 7.0.0, see <>.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 14 17:01:28 2024 UTC