note 101482 added to function.is-callable

From: Date: Sun, 19 Dec 2010 19:12:03 +0000
Subject: note 101482 added to function.is-callable
Groups: php.notes 
Request: Send a blank email to php-notes+get-175068@lists.php.net to get a copy of this message
Regarding the previous comment on closures, in case you need it they can be made "callable" with a simple workaround class TestClass { public $testMethod; public function __construct() { $this->testMethod = function(){}; } function __call($name, $arguments) { // Note: Closure class is an implementation detail // so it might be removed or renamed in the future if (isset($this->$name) && $this->$name instanceof Closure) { return call_user_func_array($this->$name, $arguments); } } } $test = new TestClass(); var_dump(is_callable(array($test, 'testMethod'))); // false var_dump(is_callable($test->testMethod)); // true -- see http://lucato.it/php-anonymous-objects for use cases ---- Server IP: 69.147.83.197 Probable Submitter: 217.43.177.112 ---- Manual Page -- http://www.php.net/manual/en/function.is-callable.php Edit -- https://master.php.net/note/edit/101482 Del: integrated -- https://master.php.net/note/delete/101482/integrated Del: useless -- https://master.php.net/note/delete/101482/useless Del: bad code -- https://master.php.net/note/delete/101482/bad+code Del: spam -- https://master.php.net/note/delete/101482/spam Del: non-english -- https://master.php.net/note/delete/101482/non-english Del: in docs -- https://master.php.net/note/delete/101482/in+docs Del: other reasons-- https://master.php.net/note/delete/101482 Reject -- https://master.php.net/note/reject/101482 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#175068) next »