#28211 [NEW]: function_exists() returns false on static functions

From: Date: Wed, 28 Apr 2004 22:46:08 +0000
Subject: #28211 [NEW]: function_exists() returns false on static functions
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-58973@lists.php.net to get a copy of this message
From: gk at proliberty dot com Operating system: linux red hat 9 PHP version: 4.3.4 PHP Bug Type: Scripting Engine problem Bug description: function_exists() returns false on static functions Description: ------------ function_exists() returns false on static functions method_exists() won't work without an instance of object many times i have a deep class hierarchy and subclasses need to call inherited static methods. instances of each ancestor class in the hierarchy do not generally exist so method_exists() doesn't solve the problem. If this is not a bug but a feature request, then it is also a documentation bug since the manual does not mention that function_exists() does not work with class member functions, which are truly 'functions', not 'methods'. 'method' assumes a class instance. [greg@p3 test]$ php -v PHP 4.3.2-RC (cli) (built: Apr 25 2003 18:03:38) Reproduce code: --------------- <?php class a { function a(){ } function static_func(){ echo ("a::static_func() - the static function really exists!\n"); } } a::static_func(); $function_exists = function_exists("a::static_func") ? 'exists': 'does not exist'; echo ("function_exists(\"a::static_func\") thinks that: \n"); echo("a::static_func() $function_exists\n"); $function_exists = function_exists("static_func") ? 'exists': 'does not exist'; echo ("function_exists(\"static_func\") thinks that: \n"); echo("static_func() $function_exists\n"); ?> Expected result: ---------------- [greg@p3 test]$ php test.php a::static_func() - the static function really exists! function_exists("a::static_func") thinks that: a::static_func() exists function_exists("static_func") thinks that: static_func() does not exist Actual result: -------------- [greg@p3 test]$ php test.php a::static_func() - the static function really exists! function_exists("a::static_func") thinks that: a::static_func() does not exist function_exists("static_func") thinks that: static_func() does not exist -- Edit bug report at http://bugs.php.net/?id=28211&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=28211&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=28211&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=28211&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=28211&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=28211&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=28211&r=needscript Try newer version: http://bugs.php.net/fix.php?id=28211&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=28211&r=support Expected behavior: http://bugs.php.net/fix.php?id=28211&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=28211&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=28211&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=28211&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28211&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=28211&r=dst IIS Stability: http://bugs.php.net/fix.php?id=28211&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=28211&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=28211&r=float

« previous php.bugs (#58973) next »