Changeset 313 for trunk/trax/vendor/trax/php_shell/shell.php
- Timestamp:
- 07/07/09 21:57:06 (3 years ago)
- Files:
-
- 1 modified
-
trunk/trax/vendor/trax/php_shell/shell.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/trax/vendor/trax/php_shell/shell.php
r227 r313 212 212 * @see registerColourScheme 213 213 */ 214 protected $colour_scheme; 214 protected $colour_scheme; 215 216 protected $virtual_methods = array('find_by', 'find_all_by', 'count_all', 'sum_all', 'avg_all'); 215 217 216 218 # shell colours … … 294 296 'description' => $help 295 297 ); 298 } 299 300 public function classMethodExists($object, $method) { 301 if(preg_grep("/^(find|find_all)_by.*$/", $this->virtual_methods) || method_exists($object, $method)) { 302 return true; 303 } 304 return false; 296 305 } 297 306 … … 459 468 /* obj */ 460 469 461 if (! method_exists($object, $method)) {470 if (!$this->classMethodExists($object, $method)) { 462 471 throw new Exception(sprintf("Variable %s (Class '%s') doesn't have a method named '%s'", 463 472 $objname, get_class($object), $method)); … … 491 500 /* obj */ 492 501 493 if (! method_exists($object, $method)) {502 if (!in_array($method, $this->virtual_methods) && !method_exists($object, $method)) { 494 503 throw new Exception(sprintf("Variable %s (Class '%s') doesn't have a method named '%s'", 495 504 $objname, get_class($object), $method)); … … 534 543 /* obj */ 535 544 536 if (! method_exists($object, $method)) {545 if (!in_array($method, $this->virtual_methods) && !method_exists($object, $method)) { 537 546 throw new Exception(sprintf("Variable %s (Class '%s') doesn't have a method named '%s'", 538 547 $objname, get_class($object), $method)); … … 555 564 $method = $ts[$last - 1]['value']; 556 565 557 if (!in_array($method, get_class_methods($classname))) {566 if (!in_array($method, $this->virtual_methods) && !in_array($method, get_class_methods($classname))) { 558 567 throw new Exception(sprintf("Class '%s' doesn't have a method named '%s'", 559 568 $classname, $method)); … … 580 589 $method = $GLOBALS[ltrim($methodname, '$')]; 581 590 582 if (!in_array($method, get_class_methods($classname))) {591 if (!in_array($method, $this->virtual_methods) && !in_array($method, get_class_methods($classname))) { 583 592 throw new Exception(sprintf("Class '%s' doesn't have a method named '%s'", 584 593 $classname, $method)); … … 812 821 return false; 813 822 } 814 } 815 $l = fgets($this->stdin); 823 } 824 825 $l = fgets($this->stdin); 816 826 } 817 827 return $l;
