Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.3.2

Bug #8554 Raises Exception for Dynamically Dispatched Functions
Submitted: 2006-08-24 20:57 UTC
From: ripta dot pasay at lunarpages dot com Assigned: jespino
Status: Closed Package: PHP_Shell (version 0.3.0)
PHP Version: 5.1.4 OS: CentOS release 3.5 (Final)
Roadmaps: (Not assigned)    
Subscription  


 [2006-08-24 20:57 UTC] ripta dot pasay at lunarpages dot com (Ripta Pasay)
Description: ------------ When function calls are handled by __call (PHP 5.x only), PHPShell will raise an Exception on line 346, because it uses method_exists() to check whether the function exists or not. Using is_callable() instead of method_exists() will handle __call()s correctly. A down side: is_callable() seems to always return TRUE if __call() exists. Test script: --------------- class Test { public function __call($methodName, $argList) { echo "$methodName called\n"; } } $t = new Test(); $t->doIt(); Expected result: ---------------- doIt called Actual result: -------------- Exception (code: 0) got thrown exception 'Exception' with message 'Variable $t (Class 'Test') doesn't have a method named 'doIt'' in /usr/local/lib/php/PHP/Shell.php:346 Stack trace: #0 /usr/local/lib/php/php-shell-cmd.php(116): PHP_Shell->parse() #1 {main}

Comments

 [2006-10-18 20:33 UTC] scottmattocks (Scott Mattocks)
Here is a patch to fix the bug. All it does is change all of the method_exists calls to is_callable. In reality, if __call() is defined, anything is callable. It is up to the developer to throw an exception if a method they don't want passed in is called. http://crisscott.com/tmp/PEAR/pear_bug_8554.patch
 [2010-08-08 21:26 UTC] jespino (Jesús Espino)
-Status: Open +Status: Closed -Assigned To: +Assigned To: jespino
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. Fixed the problem based on the solution proposed by Scott Mattocks.