Show
Ignore:
Timestamp:
07/07/09 21:57:06 (3 years ago)
Author:
john
Message:

updates

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/trax/vendor/trax/php_shell/shell.php

    r227 r313  
    212212    * @see registerColourScheme 
    213213    */ 
    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'); 
    215217 
    216218    # shell colours 
     
    294296            'description' => $help 
    295297        ); 
     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; 
    296305    } 
    297306     
     
    459468                        /* obj */ 
    460469                         
    461                         if (!method_exists($object, $method)) { 
     470                        if (!$this->classMethodExists($object, $method)) { 
    462471                            throw new Exception(sprintf("Variable %s (Class '%s') doesn't have a method named '%s'",  
    463472                                $objname, get_class($object), $method)); 
     
    491500                        /* obj */ 
    492501                         
    493                         if (!method_exists($object, $method)) { 
     502                        if (!in_array($method, $this->virtual_methods) && !method_exists($object, $method)) { 
    494503                            throw new Exception(sprintf("Variable %s (Class '%s') doesn't have a method named '%s'",  
    495504                                $objname, get_class($object), $method)); 
     
    534543                        /* obj */ 
    535544                         
    536                         if (!method_exists($object, $method)) { 
     545                        if (!in_array($method, $this->virtual_methods) && !method_exists($object, $method)) { 
    537546                            throw new Exception(sprintf("Variable %s (Class '%s') doesn't have a method named '%s'",  
    538547                                $objname, get_class($object), $method)); 
     
    555564                        $method = $ts[$last - 1]['value']; 
    556565 
    557                         if (!in_array($method, get_class_methods($classname))) { 
     566                        if (!in_array($method, $this->virtual_methods) && !in_array($method, get_class_methods($classname))) { 
    558567                            throw new Exception(sprintf("Class '%s' doesn't have a method named '%s'",  
    559568                                $classname, $method)); 
     
    580589                        $method = $GLOBALS[ltrim($methodname, '$')]; 
    581590 
    582                         if (!in_array($method, get_class_methods($classname))) { 
     591                        if (!in_array($method, $this->virtual_methods) && !in_array($method, get_class_methods($classname))) { 
    583592                            throw new Exception(sprintf("Class '%s' doesn't have a method named '%s'",  
    584593                                $classname, $method)); 
     
    812821                    return false; 
    813822                } 
    814             } 
    815             $l = fgets($this->stdin); 
     823            }   
     824                                  
     825            $l = fgets($this->stdin);  
    816826        } 
    817827        return $l;