Req #60687 [Opn->Csd]: add call support to variables methods 'class::method' (spl_autoload also)
Edit report at https://bugs.php.net/bug.php?id=60687&edit=1
ID: 60687
Updated by: cmb@php.net
Reported by: xenogenesi at virgilio dot it
Summary: add call support to variables methods
'class::method' (spl_autoload also)
-Status: Open
+Status: Closed
Type: Feature/Change Request
Package: Class/Object related
Operating System: GNU linux/Debian
PHP Version: 5.3.8
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Fixed for PHP 7.0.0, see <http://3v4l.org/W8hQA>.
Previous Comments:
------------------------------------------------------------------------
[2012-01-08 18:17:45] 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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60687&edit=1
Thread (2 messages)