Bug #52933 [Opn->Bgs]: is_callable() return always TRUE if __call() is defined
| From: | cataphract@php.net | Date: | Mon, 27 Sep 2010 11:33:01 +0000 |
| Subject: | Bug #52933 [Opn->Bgs]: is_callable() return always TRUE if __call() is defined | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-154671@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52933&edit=1
ID: 52933
Updated by: cataphract@php.net
Reported by: jackovson at gmail dot com
Summary: is_callable() return always TRUE if __call() is
defined
-Status: Open
+Status: Bogus
Type: Bug
Package: Class/Object related
Operating System: linux
PHP Version: 5.3.3
Block user comment: N
New Comment:
Expected behavior.
You can use method_exists and, if that's insufficient, reflection.
Previous Comments:
------------------------------------------------------------------------
[2010-09-27 11:47:55] jackovson at gmail dot com
Description:
------------
As said in the link below, is_callable() will always return TRUE if
_call() is
defined.
Maybe it should simply not, or maybe whe should have another magic
method like :
__methodexist($name), that return TRUE if a method could be called by
__call().
http://www.php.net/manual/fr/function.is-callable.php#49879
Test script:
---------------
<?php
class TestMe {
public function __call($name, $args) {
}
public function bug($function) {
return is_callable(array($this, $function));
}
public function iExist() {
}
}
$test = new TestMe();
var_dump($test->bug('iExist'));
var_dump($test->bug('iDont'));
Expected result:
----------------
bool(true)
bool(false)
Actual result:
--------------
bool(true)
bool(true)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52933&edit=1