php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32429 method_exists() always return TRUE if __call method exists
Submitted: 2005-03-23 14:43 UTC Modified: 2005-04-25 15:41 UTC
Votes:2
Avg. Score:2.5 ± 1.5
Reproduced:0 of 0 (0.0%)
From: pasha dot zubkov at gmail dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2005-03-29 (dev) OS: Linux 2.6.11-grsec
Private report: No CVE-ID: None
 [2005-03-23 14:43 UTC] pasha dot zubkov at gmail dot com
Description:
------------
See example. I can't use `if (method_exists()) {}` because it always return TRUE

Reproduce code:
---------------
<?php

class TestClass {
	public function __construct() {
		var_dump(method_exists($this, 'test'));

		if (method_exists($this, 'test')) {
			$this->test();
		}
	}

	public function __call($name, $args) {
		throw new Exception('Call to undefined method '.get_class($this).'::'.$name.'()');
	}
}

try {
	$test = new TestClass;
} catch (Exception $e) {
        exit($e->getMessage());
}

?>

Expected result:
----------------
bool(false)

Actual result:
--------------
bool(true) Call to undefined method TestClass::test()

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-23 23:58 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip


 [2005-03-24 00:27 UTC] tony2001@php.net
Confirmed with HEAD only.
 [2005-03-24 14:20 UTC] pasha dot zubkov at gmail dot com
I checkout HEAD from cvs. Problem not solved.
 [2005-03-29 07:49 UTC] pasha dot zubkov at gmail dot com
Any solution for this bag?
 [2005-04-25 15:41 UTC] dmitry@php.net
Fixed in CVS HEAD.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 08:01:29 2024 UTC