php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52933 is_callable() return always TRUE if __call() is defined
Submitted: 2010-09-27 11:47 UTC Modified: 2010-09-27 13:33 UTC
From: jackovson at gmail dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.3.3 OS: linux
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: jackovson at gmail dot com
New email:
PHP Version: OS:

 

 [2010-09-27 11:47 UTC] 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)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-09-27 13:33 UTC] cataphract@php.net
-Status: Open +Status: Bogus
 [2010-09-27 13:33 UTC] cataphract@php.net
Expected behavior.

You can use method_exists and, if that's insufficient, reflection.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 03:01:32 2025 UTC