php.net |  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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: xenogenesi at virgilio dot it
New email:
PHP Version: OS:

 

 [2012-01-08 18:17 UTC] xenogenesi at virgilio dot it
Description:
------------
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';
else
   $f = 'class::static_f';

// some other file...
{
   global $f;
   $f($args);
}

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


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


Expected result:
----------------
2

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

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-06-26 12:36 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2015-06-26 12:36 UTC] cmb@php.net
Fixed for PHP 7.0.0, see <http://3v4l.org/W8hQA>.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 08 15:01:28 2024 UTC