当前位置: 首页>>代码示例>>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;未经允许,请勿转载。