當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ReflectionFunction::invokeArgs方法代碼示例

本文整理匯總了PHP中ReflectionFunction::invokeArgs方法的典型用法代碼示例。如果您正苦於以下問題:PHP ReflectionFunction::invokeArgs方法的具體用法?PHP ReflectionFunction::invokeArgs怎麽用?PHP ReflectionFunction::invokeArgs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ReflectionFunction的用法示例。


在下文中一共展示了ReflectionFunction::invokeArgs方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: execute

 /**
  * (non-PHPdoc)
  * @see \PHPFluent\EventManager\Listener::execute()
  */
 public function execute(Event $event, array $context = array())
 {
     $arguments = array($event, $context);
     $parameters = $this->reflection->getParameters();
     $firstParameter = array_shift($parameters);
     if ($firstParameter instanceof \ReflectionParameter && $firstParameter->isArray()) {
         $arguments = array_reverse($arguments);
     }
     return $this->reflection->invokeArgs($arguments);
 }
開發者ID:phpfluent,項目名稱:eventmanager,代碼行數:14,代碼來源:Callback.php

示例2: getResponse

 public function getResponse($method, $uri)
 {
     foreach ($this->routes as $route) {
         if ($match = $route($method, $uri)) {
             if (is_callable($match[0])) {
                 if (empty($match[1])) {
                     return $match[0]();
                 }
                 // http://www.creapptives.com/post/26272336268/calling-php-functions-with-named-parameters
                 $ref = new \ReflectionFunction($match[0]);
                 $this->params = [];
                 foreach ($ref->getParameters() as $p) {
                     if (!$p->isOptional() and !isset($match[1][$p->name])) {
                         throw new \Exception("Missing parameter {$p->name}");
                     }
                     if (!isset($match[1][$p->name])) {
                         $this->params[$p->name] = $p->getDefaultValue();
                     } else {
                         $this->params[$p->name] = $match[1][$p->name];
                     }
                 }
                 return $ref->invokeArgs($this->params);
             }
             return $match[0];
         }
     }
     throw new \Exception($method . ':' . $uri . ' not found');
 }
開發者ID:kriss,項目名稱:mvvm,代碼行數:28,代碼來源:Router.php

示例3: array

 function exec_function_array($o, array $B = array())
 {
     switch (count($B)) {
         case 0:
             return $o();
         case 1:
             return $o($B[0]);
         case 2:
             return $o($B[0], $B[1]);
         case 3:
             return $o($B[0], $B[1], $B[2]);
         case 4:
             return $o($B[0], $B[1], $B[2], $B[3]);
         case 5:
             return $o($B[0], $B[1], $B[2], $B[3], $B[4]);
         default:
             if (is_object($o)) {
                 $v = new ReflectionMethod($o, '__invoke');
                 return $v->invokeArgs($o, $B);
             } else {
                 if (is_callable($o)) {
                     $v = new ReflectionFunction($o);
                     return $v->invokeArgs($B);
                 }
             }
     }
 }
開發者ID:jl9n,項目名稱:CuteLib,代碼行數:27,代碼來源:cutelib.php

示例4: runMiddlewares

 /**
  * Runs all the middlewares of given type.
  */
 public static function runMiddlewares($type = self::BEFORE_REQUEST)
 {
     $apricot = static::getInstance();
     $middlewares = $apricot->middlewares;
     /** @var \Exception */
     $error = null;
     foreach ($middlewares as $key => $middleware) {
         $hasNextMiddleware = array_key_exists($key + 1, $middlewares);
         if ($type !== $middleware['type']) {
             continue;
         }
         $r = new \ReflectionFunction($middleware['callback']);
         $parameters = $r->getParameters();
         $next = $hasNextMiddleware ? $middlewares[$key + 1] : function () {
         };
         try {
             $r->invokeArgs(array($error, $next));
         } catch (\Exception $e) {
             // If there is no more middleware to run, throw the exception.
             if (!$hasNextMiddleware) {
                 throw $e;
             }
             $error = $e;
         }
     }
 }
開發者ID:djom20,項目名稱:Apricot,代碼行數:29,代碼來源:Middleware.php

示例5: exec

 public function exec($key)
 {
     //匿名函數
     if ($this->route[$key]['callback'] instanceof Closure) {
         //反射分析閉包
         $reflectionFunction = new \ReflectionFunction($this->route[$key]['callback']);
         $gets = $this->route[$key]['get'];
         $args = [];
         foreach ($reflectionFunction->getParameters() as $k => $p) {
             if (isset($gets[$p->name])) {
                 //如果GET變量中存在則將GET變量值賦予,也就是說GET優先級高
                 $args[$p->name] = $gets[$p->name];
             } else {
                 //如果類型為類時分析類
                 if ($dependency = $p->getClass()) {
                     $args[$p->name] = App::build($dependency->name);
                 } else {
                     //普通參數時獲取默認值
                     $args[$p->name] = App::resolveNonClass($p);
                 }
             }
         }
         echo $reflectionFunction->invokeArgs($args);
     } else {
         //設置控製器與方法
         Request::set('get.' . c('http.url_var'), $this->route[$key]['callback']);
         Controller::run($this->route[$key]['get']);
     }
 }
開發者ID:houdunwang,項目名稱:hdphp,代碼行數:29,代碼來源:Compile.php

示例6: invoke

 /**
  * 
  * @param   array   $arguments
  * 
  * @return  mixed
  */
 public function invoke($arguments = array())
 {
     if ($this->isMethod) {
         return $this->reflection->invokeArgs($this->thisObject, $arguments);
     }
     return $this->reflection->invokeArgs($arguments);
 }
開發者ID:opis,項目名稱:routing,代碼行數:13,代碼來源:Callback.php

示例7: pack

 /**
  * Packs 8-bit integers into a binary string
  *
  * @since 1.0
  * 
  * @param  int $ascii,... 8-bit unsigned integer
  * @return binary
  */
 public static function pack($ascii)
 {
     $packer = new \ReflectionFunction('pack');
     $args = func_get_args();
     array_unshift($args, 'C*');
     return $packer->invokeArgs($args);
 }
開發者ID:darwinkim,項目名稱:onlinesequencer,代碼行數:15,代碼來源:Util.php

示例8: call

 /**
  * @param \Closure $closure
  * @return mixed
  */
 public function call($closure)
 {
     $reflect = new \ReflectionFunction($closure);
     $parameters = $reflect->getParameters();
     $dependencies = $this->getDependencies($parameters);
     return $reflect->invokeArgs($dependencies);
 }
開發者ID:jacobmarshall,項目名稱:ioc,代碼行數:11,代碼來源:Container.php

示例9: XLLoop_reflection_handler

function XLLoop_reflection_handler()
{
    try {
        $input = file_get_contents('php://input');
        $value = json_decode($input);
        if ($value != NULL) {
            $argc = count($value->args);
            $args = array();
            for ($i = 0; $i < $argc; $i++) {
                $args[$i] = XLLoop_decode($value->args[$i]);
            }
            $function = new ReflectionFunction($value->name);
            if ($function->isUserDefined()) {
                $reqArgc = $function->getNumberOfParameters();
                for ($i = $argc; $i < $reqArgc; $i++) {
                    $args[$i] = 0;
                }
                $result = $function->invokeArgs($args);
                $enc = XLLoop_encode($result);
                print json_encode($enc);
            } else {
                print json_encode(XLLoop_encode("#Function " . $value->name . "() does not exist"));
            }
        } else {
            print "<html><body><code>XLLoop function handler alive</code></body></html>";
        }
    } catch (Exception $e) {
        print json_encode(XLLoop_encode("#" . $e->getMessage()));
    }
}
開發者ID:mnar53,項目名稱:xlloop,代碼行數:30,代碼來源:XLLoop.php

示例10: testCheckAPI

 /**
  * Asserts that a function is implemented and returns the expected result
  *
  * @param String $function The function name
  * @param Array  $params   The parameters
  * @param Mixed  $result   The expected result
  *
  * @dataProvider provideTestCheckAPI
  * @return void
  */
 public function testCheckAPI($function, array $params, $result)
 {
     $api = new OldPHPAPI_Test();
     $api->checkAPI();
     $this->assertTrue(function_exists($function), "Function {$function} is not defined.");
     $reflection = new ReflectionFunction($function);
     $this->assertEquals($result, $reflection->invokeArgs($params));
 }
開發者ID:xxdf,項目名稱:showtimes,代碼行數:18,代碼來源:TestOldPHPAPI.php

示例11: callFunction

 public function callFunction($function)
 {
     /** @var \ReflectionFunction $reflectionFunction */
     $reflectionFunction = new \ReflectionFunction($function);
     $signatureParams = $reflectionFunction->getParameters();
     $calledFunctionArgs = $this->resolveParams($signatureParams);
     $reflectionFunction->invokeArgs($calledFunctionArgs);
 }
開發者ID:marcyniu,項目名稱:ai,代碼行數:8,代碼來源:Container.php

示例12: execute

 /**
  * @param $method
  * @param array $args
  * @param bool $singleton
  * @return mixed
  * @throws \Exception
  */
 public function execute($method, array $args = array(), $singleton = true)
 {
     if (is_array($method) && count($method) >= 2) {
         list($class, $name) = $method;
         $reflection = new \ReflectionMethod($class, $name);
     } elseif (is_callable($method)) {
         $reflection = new \ReflectionFunction($method);
     } else {
         throw new \RuntimeException();
     }
     $parameters = $reflection->getParameters();
     $args = $this->getReflectionValues($parameters, $args, $singleton);
     if ($reflection instanceof \ReflectionFunction) {
         return $reflection->invokeArgs($args);
     } else {
         return $reflection->invokeArgs($class, $args);
     }
 }
開發者ID:AdamaDodoCisse,項目名稱:Electrode,代碼行數:25,代碼來源:FIC.php

示例13: prepareArgs

 private function prepareArgs($sql, $arguments = null)
 {
     if ($arguments != null && count($arguments) > 0) {
         $sprintfargs = array_merge(array($sql), $arguments);
         $sprintf = new \ReflectionFunction('sprintf');
         $sql = $sprintf->invokeArgs($sprintfargs);
     }
     return $sql;
 }
開發者ID:picon,項目名稱:picon-framework,代碼行數:9,代碼來源:DataBaseTemplate.php

示例14: invoke_function

 /**
  * 
  * @param string $callback
  * @param array $params
  * @return mixed
  */
 public static function invoke_function($callback, array $params = NULL)
 {
     $class = new ReflectionFunction($callback);
     if (empty($params)) {
         return $class->invoke();
     } else {
         return $class->invokeArgs($params);
     }
 }
開發者ID:ZerGabriel,項目名稱:cms-1,代碼行數:15,代碼來源:callback.php

示例15: processController

 /**
  * Execute the active controller
  */
 public function processController()
 {
     // closure
     if (is_callable($this->controller)) {
         $func = new \ReflectionFunction($this->controller);
         return $func->invokeArgs($this->controller_args);
     } else {
         return Controller::execute($this->controller, $this->controller_args);
     }
 }
開發者ID:Kuzat,項目名稱:kofradia,代碼行數:13,代碼來源:Route.php


注:本文中的ReflectionFunction::invokeArgs方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。