当前位置: 首页>>代码示例>>PHP>>正文


PHP ReflectionMethod::getNumberOfParameters方法代码示例

本文整理汇总了PHP中ReflectionMethod::getNumberOfParameters方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionMethod::getNumberOfParameters方法的具体用法?PHP ReflectionMethod::getNumberOfParameters怎么用?PHP ReflectionMethod::getNumberOfParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ReflectionMethod的用法示例。


在下文中一共展示了ReflectionMethod::getNumberOfParameters方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadController

 /**
  * 
  * @global array $config
  * @param string $class naziv kotrolera koji se instancira
  * @param string $method metod koji se poziva
  * @param array $params parametri metode
  */
 public static function loadController($controller, $method, $params = array())
 {
     global $config;
     $path_to_controller = realpath("controllers/" . strtolower($controller) . "Controller.php");
     if (file_exists($path_to_controller)) {
         include_once $path_to_controller;
         $controller = strtolower($controller) . "Controller";
         $controller_instance = new $controller();
         if (!is_subclass_of($controller_instance, 'baseController')) {
             echo $config['Poruke']['noBaseCont'];
             die;
         }
         if (method_exists($controller_instance, $method)) {
             $refl = new ReflectionMethod(get_class($controller_instance), $method);
             $numParams = $refl->getNumberOfParameters();
             if ($numParams > 0 && count($params) < $numParams) {
                 echo $config['Poruke']['noParams'];
                 die;
             }
             call_user_func_array(array($controller_instance, $method), $params);
         } else {
             echo $config['Poruke']['noMethod'];
         }
     } else {
         echo $config['Poruke']['error404'];
     }
 }
开发者ID:tigar-bilderski,项目名称:repozaframework,代码行数:34,代码来源:Loader.php

示例2: dispatch

 public function dispatch()
 {
     $acao = self::sulfixo_controle . $this->paginaSolicitada;
     if (method_exists($this, $acao)) {
         $reflection = new ReflectionMethod($this, $acao);
         $qtdArgumentos = $reflection->getNumberOfParameters();
         $parametros = array();
         $i = 0;
         foreach ($_GET as $key => $value) {
             if (!empty($value) && $key != 'a' && $i <= $qtdArgumentos) {
                 $parametros[$i] = $value;
             }
             $i++;
         }
         if (count($parametros) < $qtdArgumentos) {
             $i = $qtdArgumentos - count($parametros);
             for ($index = 0; $index < $i; $index++) {
                 $parametros[$index + count($parametros) + 1] = '';
             }
         }
         call_user_func_array(array($this, $acao), $parametros);
     } else {
         $this->erro_404();
     }
 }
开发者ID:umbernardo,项目名称:banco_projetos,代码行数:25,代码来源:CupNucleo.php

示例3: run

 public static function run()
 {
     $currentPath = substr($_SERVER['REQUEST_URI'], 44);
     $currentMethod = $_SERVER['REQUEST_METHOD'];
     if (strpos($currentPath, '?') !== false) {
         $currentPath = explode('?', $currentPath);
         $currentPath = $currentPath[0];
     }
     foreach (static::$routes as $value) {
         $matches[] = array();
         if (preg_match($value['path'], $currentPath, $matches) === 0) {
             continue;
         }
         if ($currentMethod !== $value['method']) {
             continue;
         }
         unset($matches[0]);
         $controller = new $value['class']();
         $info = new \ReflectionMethod($controller, $value['function']);
         if ($info->getNumberOfParameters() !== count($matches)) {
             throw new \Exception('Numero de parametros incorrecto: ' . $value['class'] . '::' . $value['function']);
         }
         $response = $info->invokeArgs($controller, $matches);
         if (is_null($response)) {
             return;
         }
         if ($response instanceof View) {
             Response::view($response);
         }
         return;
     }
     // Lanzar 404
     App::abort(404, 'No se encuentra la ruta');
 }
开发者ID:albertomoreno,项目名称:web-newspaper,代码行数:34,代码来源:Router.php

示例4: isAutoloadMethod

 /**
  * @param \ReflectionMethod $method
  * @return bool
  */
 private function isAutoloadMethod(\ReflectionMethod $method)
 {
     if (strpos($method->getName(), KnotConsts::AUTOLOAD_METHOD_PREFIX) !== 0 || $method->getNumberOfParameters() != 1 || $method->getNumberOfRequiredParameters() != 1 || $method->isStatic() || $method->isAbstract() || !Extractor::instance()->has($method, KnotConsts::AUTOLOAD_ANNOTATIONS)) {
         return false;
     }
     return true;
 }
开发者ID:oktopost,项目名称:skeleton,代码行数:11,代码来源:MethodConnector.php

示例5: run

 /**
  * Runs the action.
  * The action method defined in the controller is invoked.
  * This method is required by {@link CAction}.
  */
 public function run()
 {
     $controller = $this->getController();
     $methodName = 'action' . $this->getId();
     $method = new ReflectionMethod($controller, $methodName);
     if (($n = $method->getNumberOfParameters()) > 0) {
         $params = array();
         foreach ($method->getParameters() as $i => $param) {
             $name = $param->getName();
             if (isset($_GET[$name])) {
                 if ($param->isArray()) {
                     $params[] = is_array($_GET[$name]) ? $_GET[$name] : array($_GET[$name]);
                 } else {
                     if (!is_array($_GET[$name])) {
                         $params[] = $_GET[$name];
                     } else {
                         throw new CHttpException(400, Yii::t('yii', 'Your request is invalid.'));
                     }
                 }
             } else {
                 if ($param->isDefaultValueAvailable()) {
                     $params[] = $param->getDefaultValue();
                 } else {
                     throw new CHttpException(400, Yii::t('yii', 'Your request is invalid.'));
                 }
             }
         }
         $method->invokeArgs($controller, $params);
     } else {
         $controller->{$methodName}();
     }
 }
开发者ID:IuriiP,项目名称:yii-tracker,代码行数:37,代码来源:CInlineAction.php

示例6: loadRules

 /**
  * Call this method to load all rules
  */
 public function loadRules()
 {
     $this->rules = [];
     foreach (get_class_methods($this) as $rule) {
         if (mb_substr($rule, 0, 6) === 'rule__') {
             $name = mb_substr($rule, 6);
             $method = new \ReflectionMethod($this, $rule);
             if (!$method->getNumberOfParameters() === 3) {
                 //the method expects too much/less arguments
                 $this->errorHandler->log('methods', "The method \"{$name}\" expects " . $method->getNumberOfParameters() . " but it should expect 3 arguments.");
                 continue;
             }
             $this->rules[] = ['name' => $name, 'class' => $method];
         }
     }
 }
开发者ID:sweetcode,项目名称:cake,代码行数:19,代码来源:Cake.class.php

示例7: gettersToArray

 public static function gettersToArray($object)
 {
     if (!is_object($object)) {
         throw new \InvalidArgumentException('$object must be an object.');
     }
     $result = [];
     // Iterate over all getters.
     foreach (get_class_methods($object) as $method) {
         if (strncmp('get', $method, 3) == 0) {
             $reflector = new \ReflectionMethod($object, $method);
             if ($reflector->isPublic() && $reflector->getNumberOfParameters() == 0) {
                 $key = lcfirst(substr($method, 3));
                 $value = $object->{$method}();
                 if (is_array($value)) {
                     foreach ($value as &$entry) {
                         if (is_object($entry)) {
                             $entry = static::gettersToArray($entry);
                         }
                     }
                 }
                 $result[$key] = is_object($value) ? static::gettersToArray($value) : $value;
             } elseif ($object instanceof Question && $method === 'getQuestions') {
                 for ($i = 0; $i < $object->getDimensions(); $i++) {
                     foreach ($object->getQuestions($i) as $question) {
                         $result['questions'][$i][] = self::gettersToArray($question);
                     }
                 }
             }
         }
     }
     return $result;
 }
开发者ID:sam-it,项目名称:ls2-jsonrpc-client,代码行数:32,代码来源:SerializeHelper.php

示例8: __construct

 public function __construct($class, $method)
 {
     parent::__construct();
     $ref = new ReflectionMethod($class, $method);
     $this->_ref = $ref;
     $this->_args = $ref->getParameters();
     $this->_args_cnt = $ref->getNumberOfParameters();
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:8,代码来源:MethodSpec.class.php

示例9: testSearchMethod

 public function testSearchMethod()
 {
     $et = new ExactTarget("", "");
     $this->assertTrue(method_exists('ExactTarget', 'search'), "search method exists");
     $method = new ReflectionMethod('ExactTarget', 'search');
     $num = $method->getNumberOfParameters();
     $this->assertEquals(2, $num, "has 2 function argument");
 }
开发者ID:nholdren,项目名称:marketingcloud,代码行数:8,代码来源:ExactTargetTest.php

示例10: getNumberOfParameters

 /**
  * Returns the number of parameters
  *
  * @return integer The number of parameters
  * @since PHP 5.0.3
  */
 public function getNumberOfParameters()
 {
     if ($this->reflectionSource instanceof ReflectionMethod) {
         return $this->reflectionSource->getNumberOfParameters();
     } else {
         return parent::getNumberOfParameters();
     }
 }
开发者ID:naderman,项目名称:ezc-reflection,代码行数:14,代码来源:method.php

示例11: methodListFromReflectionClassAndMethod

 /**
  * @return Method[]
  */
 public static function methodListFromReflectionClassAndMethod(Context $context, CodeBase $code_base, \ReflectionClass $class, \ReflectionMethod $reflection_method) : array
 {
     $reflection_method = new \ReflectionMethod($class->getName(), $reflection_method->name);
     $method = new Method($context, $reflection_method->name, new UnionType(), $reflection_method->getModifiers());
     $method->setNumberOfRequiredParameters($reflection_method->getNumberOfRequiredParameters());
     $method->setNumberOfOptionalParameters($reflection_method->getNumberOfParameters() - $reflection_method->getNumberOfRequiredParameters());
     $method->setFQSEN(FullyQualifiedMethodName::fromStringInContext($method->getName(), $context));
     return self::functionListFromFunction($method, $code_base);
 }
开发者ID:black-silence,项目名称:phan,代码行数:12,代码来源:FunctionFactory.php

示例12: runWithParams

 public function runWithParams($params)
 {
     $method = new ReflectionMethod($this, 'run');
     if ($method->getNumberOfParameters() > 0) {
         return $this->runWithParamsInternal($this, $method, $params);
     } else {
         return $this->run();
     }
 }
开发者ID:RandomCivil,项目名称:tiny-yii,代码行数:9,代码来源:CAction.php

示例13: setDefaultOptions

 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setRequired(array('fields'));
     $reflection = new \ReflectionMethod($resolver, 'setAllowedTypes');
     if ($reflection->getNumberOfParameters() === 2) {
         $resolver->setAllowedTypes('fields', 'array');
     } else {
         $resolver->setAllowedTypes(array('fields' => 'array'));
     }
 }
开发者ID:scaytrase,项目名称:symfony-storable-forms,代码行数:10,代码来源:TableRowType.php

示例14: elseif

 function resolve2($context, array $path)
 {
     $original_path = $path;
     $head = array_shift($path);
     $args = $path;
     $head = $this->translate($head);
     // If the head is empty, then the URL ended in a slash (/), assume
     // the index is implied
     if (!$head) {
         $head = 'index';
     }
     try {
         $method = new \ReflectionMethod($context, $head);
         // Ensure that the method is visible
         if (!$method->isPublic()) {
             return false;
         }
         // Check if argument count matches the rest of the URL
         if (count($args) < $method->getNumberOfRequiredParameters()) {
             // Not enough parameters in the URL
             return false;
         }
         if (count($args) > ($C = $method->getNumberOfParameters())) {
             // Too many parameters in the URL — pass as many as possible to the function
             $path = array_slice($args, $C);
             $args = array_slice($args, 0, $C);
         }
         // Try to call the method and see what kind of response we get
         $result = $method->invokeArgs($context, $args);
         if ($result instanceof View\BaseView) {
             return $result;
         } elseif (is_callable($result)) {
             // We have a callable to be considered the view. We're done.
             return new View\BoundView($result, $args);
         } elseif ($result instanceof Dispatcher) {
             // Delegate to a sub dispatcher
             return $result->resolve(implode('/', $path));
         } elseif (is_object($result)) {
             // Recurse forward with the remainder of the path
             return $this->resolve2($result, $path);
         }
         // From here, we assume that the call failed
     } catch (\ReflectionException $ex) {
         // No such method, try def() or recurse backwards
     } catch (Exception\ConditionFailed $ex) {
         // The matched method refused the request — recurse backwards
     }
     // Not able to dispatch the method. Try def()
     if ($head != 'def') {
         $path = array_merge(['def'], $original_path);
         return $this->resolve2($context, $path);
     }
     // Unable to dispatch the request
     return false;
 }
开发者ID:iHunt101,项目名称:phlite,代码行数:55,代码来源:MethodDispatcher.php

示例15: runWithParams

 /**
  * Выполняет действие с переданными параметрами запроса. Данный метод
  * вызывается методом {@link CController::runAction()}
  * @param array $params параметры запроса (имя => значение)
  * @return boolean верны ли параметры запроса
  * @since 1.1.7
  */
 public function runWithParams($params)
 {
     $methodName = 'action' . $this->getId();
     $controller = $this->getController();
     $method = new ReflectionMethod($controller, $methodName);
     if ($method->getNumberOfParameters() > 0) {
         return $this->runWithParamsInternal($controller, $method, $params);
     } else {
         return $controller->{$methodName}();
     }
 }
开发者ID:danish-ii,项目名称:yiiru,代码行数:18,代码来源:CInlineAction.php


注:本文中的ReflectionMethod::getNumberOfParameters方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。