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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 15 21:01:28 2024 UTC