コード例 #1
0
 /**
  * @see vB_Api::callNamed
  * @param mixed $current
  * @param string $method -- the name of the method to call
  * @param array $args -- The list of args to call.  This is a name => value map that will
  *   be matched up to the names of the API method.  Order is not important.  The names are
  *   case sensitive.
  * @return mixed
  */
 public function callNamed()
 {
     // since the parent method has different arguments,
     // we need to do this to avoid strict standards notice
     list($current, $method, $args) = func_get_args();
     if (!is_callable(array($this, $method))) {
         /* if the method does not exist then dont check anything,
         		 just return the current value. */
         return $current;
     }
     // Check if the result varname is present
     $foundResultVarName = false;
     $reflection = new ReflectionMethod($this, $method);
     foreach ($reflection->getParameters() as $param) {
         if ($param->getName() == $this->resultVarName) {
             $foundResultVarName = true;
             break;
         }
     }
     if (!$foundResultVarName) {
         // The method is not using the result varname, so it's better to ignore it and return previous result
         // todo: log this error somewhere?
         return $current;
     }
     $args[$this->resultVarName] = $current;
     return parent::callNamed($method, $args);
 }