Req #18187 [Opn->Csd]: Consequent implementation of array referencing to user method
| From: | nikic@php.net | Date: | Sat, 22 Sep 2012 09:17:16 +0000 |
| Subject: | Req #18187 [Opn->Csd]: Consequent implementation of array referencing to user method | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-173630@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=18187&edit=1
ID: 18187
Updated by: nikic@php.net
Reported by: bram at totalgsm dot net
Summary: Consequent implementation of array referencing to
user method
-Status: Open
+Status: Closed
Type: Feature/Change Request
-Package: Feature/Change Request
+Package: *General Issues
Operating System: any
PHP Version: 4.2.1
-Assigned To:
+Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
Closing as the $callable() syntax now works for array-callbacks too (as of PHP 5.4). Instead of
function_exists the function is_callable can be used.
Previous Comments:
------------------------------------------------------------------------
[2002-07-05 11:46:28] bram at totalgsm dot net
You support calling user methods using an array in the call_user_func() function. But related
functions of call_user_func() don't support the syntax. I would like to see that
function_exists could check if the user method exists.
The following example code should work:
class Foo {
function bar($what = 'world') {
print 'Hello ' . $what;
}
}
$a_foo = new Foo();
$user_method = array($a_foo, 'bar');
if (!function_exists($user_method))
die('You shouldn\'t see this :)');
$user_method('PHP'); // Should print "Hello PHP" ofcourse.
Furthermore the implementation of the user_method calling in call_user_func is incorrect for
referencing variabeles, which might be pretty usefull. (see http://bugs.php.net/bug.php?id=17309)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=18187&edit=1