示例#1
0
 /**
  * Catch aliases and reroute them to the right methods
  */
 public static function __callStatic($method, $parameters)
 {
     // Get base class and methods class
     $callingClass = static::computeClassToCall(get_called_class(), $method, $parameters);
     $methodsClass = Method::getMethodsFromType($callingClass);
     // Defer to Methods class
     if (method_exists($methodsClass, $method)) {
         return Repository::callMethod($methodsClass, $method, $parameters);
     }
     // Check for an alias
     if ($alias = Method::getAliasOf($method)) {
         return Repository::callMethod($methodsClass, $alias, $parameters);
     }
     // Check for parsers
     if (method_exists('Underscore\\Parse', $method)) {
         return Repository::callMethod('Underscore\\Parse', $method, $parameters);
     }
     // Defered methods
     if ($defered = Dispatch::toNative($callingClass, $method)) {
         return call_user_func_array($defered, $parameters);
     }
     // Look in the macros
     if ($macro = ArraysMethods::get(static::$macros, $callingClass . '.' . $method)) {
         return call_user_func_array($macro, $parameters);
     }
     throw new BadMethodCallException('The method ' . $callingClass . '::' . $method . ' does not exist');
 }
示例#2
0
 public function testCanGetMethodsFromType()
 {
     $method = Method::getMethodsFromType('\\Underscore\\Types\\Arrays');
     $this->assertEquals('\\Underscore\\Methods\\ArraysMethods', $method);
 }