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

Bug #8554 Raises Exception for Dynamically Dispatched Functions
Submitted: 2006-08-24 15:57 UTC Modified: 2006-10-18 15:33 UTC
From: ripta dot pasay at lunarpages dot com Assigned:
Status: Open Package: PHP_Shell (version 0.3.0)
PHP Version: 5.1.4 OS: CentOS release 3.5 (Final)
Roadmaps: (Not assigned)    
Subscription  
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes. If this is not your bug, you can add a comment by following this link. If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ripta dot pasay at lunarpages dot com
New email:
PHP Version: Package Version: OS:

 

 [2006-08-24 15: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 15: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