Edit report at https://bugs.php.net/bug.php?id=63578&edit=1
ID: 63578 Comment by: pierre at pcservice dot co dot za Reported by: pierre at pcservice dot co dot za Summary: is_callable returns false with __call Status: Not a bug Type: Bug Package: *General Issues Operating System: mac & linux PHP Version: Irrelevant Assigned To: dmitry Block user comment: N Private report: N New Comment: so when calling is_callable(array('Foo', 'bar')), if the method doesn't exist, it only looks for a static method? with the following class Controller { public function testAction() { } public static function staticAction() { } public function __call($method, $arguments) { } } is_callable(array(new Controller, 'testAction')); is_callable(array(new Controller, 'staticAction')); is_callable(array(new Controller, 'fooAction')); is_callable(array('Controller', 'testAction')); is_callable(array('Controller', 'staticAction')); is_callable(array('Controller', 'fooAction')); everything returns true except for the last call. Shouldn't it return true as well, since the class has the magic __call method? Or the documentation should then at least specify that is_callable only works with the __call method, if the first parameter of the array is an instance of the object Previous Comments: ------------------------------------------------------------------------ [2012-11-22 07:08:32] larue...@php.net Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Class Foo { public function __call($method, $args) {} } Foo::bar(); //result in Fatal error: Call to undefined method Foo::bar() ------------------------------------------------------------------------ [2012-11-22 06:31:25] pierre at pcservice dot co dot za Description: ------------ When you have a class that have a __call magic method, when calling is_callable with an array and the first argument a string, it returns false. Test script: --------------- Class Foo { public function __call($method, $args) {} } var_dump(is_callable(array('Foo', 'bar'))); var_dump(is_callable(array(new Foo, 'bar'))); Expected result: ---------------- true true Actual result: -------------- false true ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=63578&edit=1