Req #45001 [Opn]: Provide the ability to use is_callable() with __call()
| From: | levim@php.net | Date: | Wed, 07 Jan 2015 20:53:59 +0000 |
| Subject: | Req #45001 [Opn]: Provide the ability to use is_callable() with __call() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-189716@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=45001&edit=1
ID: 45001
Updated by: levim@php.net
Reported by: kristopherwilson at gmail dot com
Summary: Provide the ability to use is_callable() with
__call()
Status: Open
Type: Feature/Change Request
-Package: Feature/Change Request
+Package: *General Issues
Operating System: Irrelevant
PHP Version: 5.2.6
Block user comment: N
Private report: N
New Comment:
It would be difficult to know what the result of calling
__call would be. This would
need more discussion if people are really interested.
Previous Comments:
------------------------------------------------------------------------
[2008-05-15 00:21:39] kristopherwilson at gmail dot com
Description:
------------
It would be useful to be able to use the is_callable() function on an object that overloads with
__call(). Perhaps something like a magic __callable() or __is_callable() method that would return
true or false on whether or not the method is callable.
Reproduce code:
---------------
<?php
class MyClass
{
public function __callable( $sMethod )
{
return( is_callable( array( $this, $sMethod ) ) );
}
private function MyFunction() {}
}
$oMyClass = new MyClass();
if( is_callable( $oMyClass, "MyFunction" ) )
{
echo "Callable!";
}
?>
Expected result:
----------------
Callable!
Actual result:
--------------
[no output]
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=45001&edit=1