php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #45001 Provide the ability to use is_callable() with __call()
Submitted: 2008-05-15 00:21 UTC Modified: 2015-01-07 20:53 UTC
Votes:4
Avg. Score:3.5 ± 0.9
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:2 (66.7%)
From: kristopherwilson at gmail dot com Assigned:
Status: Open Package: *General Issues
PHP Version: 5.2.6 OS: Irrelevant
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: kristopherwilson at gmail dot com
New email:
PHP Version: OS:

 

 [2008-05-15 00:21 UTC] 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]

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-01-07 20:53 UTC] levim@php.net
-Package: Feature/Change Request +Package: *General Issues
 [2015-01-07 20:53 UTC] levim@php.net
It would be difficult to know what the result of calling `__call` would be. This would need more discussion if people are really interested.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 09:01:30 2024 UTC