#49220 [Opn->Bgs]: method_exists check goes wrong when checking for a static function

From: Date: Tue, 11 Aug 2009 09:33:21 +0000
Subject: #49220 [Opn->Bgs]: method_exists check goes wrong when checking for a static function
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-140907@lists.php.net to get a copy of this message
ID: 49220 Updated by: jani@php.net Reported By: william at 1moment dot nl -Status: Open +Status: Bogus Bug Type: Class/Object related Operating System: Linux -PHP Version: 5.2SVN-2009-08-11 (SVN) +PHP Version: 5.2.5 New Comment: Both latest PHP 5.2 / 5.3 / HEAD SVN checkouts work just fine and produce your expected behaviour. Time to upgrade.. Previous Comments: ------------------------------------------------------------------------ [2009-08-11 09:25:54] william at 1moment dot nl Description: ------------ The method_exists function can have two types of input for the first parameter: An object instance or a class name. The documentation (http://us2.php.net/manual/en/function.method-exists.php) has two examples. One for checking static methods and one for checking normal methods. (Based on the type of var for the first parameter). When i do this in php version 5.2.5 the code below will echo 'testClass has a static function named testFunction'. When i do this in php version 5.0.4 the code below will echo 'testClass has not a static function named testFunction'. I think 5.0.4 is correct behavior. Thnx! Reproduce code: --------------- Class testClass { public function testFunction() { return true; } } if(method_exists('testClass', 'testFunction')) { echo 'testClass has a static function named testFunction'; } else { echo 'testClass has not a static function named testFunction'; } Expected result: ---------------- testClass has a static function named testFunction Actual result: -------------- testClass has not a static function named testFunction ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=49220&edit=1

« previous php.bugs (#140907) next »