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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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: Sat Nov 23 23:01:26 2024 UTC