Creates a parameters list from a `ReflectionMethod` instance.

@param  object $method A instance of `ReflectionMethod`.
@return string         The parameters definition list.
168667
protected static function _generateParameters($method)
    {
        $params = [];
        foreach ($method->getParameters() as $num => $parameter) {
            $name = $parameter->getName();
            $name = ($name && $name !== '...') ? $name : 'param' . $num;
            $params[] = "\${$name}";
        }
        return join(', ', $params);
    }
92986
private static function guessArgs(\ReflectionMethod $method)
    {
        $arguments = [];
        foreach ($method->getParameters() as $index => $parameter) {
            if (!$parameter->hasType()) {
                throw new InvalidArgumentException(\sprintf('Argument n°%s "$%s" on method "%s" cannot be auto-guessed as there is not type hint.', $index + 1, $parameter->getName(), $method->getName()));
            }

            try {
                $gqlType = self::resolveGraphqlTypeFromReflectionType($parameter->getType(), self::$validInputTypes, $parameter->isDefaultValueAvailable());
            } catch (\Exception $e) {
                throw new InvalidArgumentException(\sprintf('Argument n°%s "$%s" on method "%s" cannot be auto-guessed : %s".', $index + 1, $parameter->getName(), $method->getName(), $e->getMessage()));
            }

            $argumentConfig = [];
            if ($parameter->isDefaultValueAvailable()) {
                $argumentConfig['defaultValue'] = $parameter->getDefaultValue();
            }

            $argumentConfig['type'] = $gqlType;

            $arguments[$parameter->getName()] = $argumentConfig;
        }

        return $arguments;
    }
615644
private final function parseMethod(string $method): string
   {
       return static::GET === $method
           || static::POST === $method
           || static::PUT === $method
           || static::DELETE === $method
           || static::OPTIONS === $method
            ? $method
            : static::GET;
   }
623586
public function getParameters(string $class, string $method = null){
        if(!class_exists($class)){
            throw new \InvalidArgumentException();
        }

        if($method !== null && !method_exists($class, $method)){
            throw new \InvalidArgumentException();
        }

        if(!array_key_exists($class, $this->params)){
            $this->params[$class]   = [];
        }

        $method = $method === null ? "__construct" : $method;

        if(!array_key_exists($method, $this->params[$class])){
            if($method === "__construct" && !method_exists($class, $method)){
                $reflection = null;
            }else{
                $reflection = $this->getClass($class)->getMethod($method);
            }

            $this->params[$class][$method]  = $reflection === null
                ? []
                : $reflection->getParameters()
            ;
        }

        return $this->params[$class][$method];
    }
1023282
public static function getClassMethodArgs($class, string $method)
    {
        static $cache = null;

        if (null !== $cache && isset($cache[$class][$method])) {
            return $cache[$class][$method];
        }

        $reflector = new \ReflectionMethod($class, $method);
        $params = $reflector->getParameters();
        if (empty($params)) {
            $cache[$class][$method] = [];
            return [];
        }
        $args = [];
        foreach ($params as $param) {
            $args[$param->name] = [
                'optional' => $param->isOptional(),
                'variadic' => $param->isVariadic(),
            ];
            if ($param->isOptional() && $param->isDefaultValueAvailable()) {
                $args[$param->name]['default'] = $param->getDefaultValue();
            }
            if ($param->hasType()) {
                $args[$param->name]['type'] = (string)$param->getType();
            }
        }
        $cache[$class][$method] = $args;
        return $args;
    }
141139
public function getMappedMethod($method)
    {
        // Check if the method called is provided in the mapping.
        if (!array_key_exists($method, self::$validatorMapping)) {
            throw new Exception(sprintf(
                'Mapping for method "%s" not found, make sure it exists in the mapping file.',
                $method
            ));
        }

        return self::$validatorMapping[$method];
    }
879864
private static function getMethodParamTpls(\ReflectionMethod $method)
    {
        $result = [
            'args'      => [],
            'define'    => [],
            'call'      => [],
            'set_args'  => '',
        ];
        foreach($method->getParameters() as $i => $param)
        {
            // 数组参数，支持可变传参
            if(!$param->isVariadic())
            {
                $result['args'][] = static::getMethodParamArgsTpl($param);
            }
            // 方法参数定义
            $result['define'][] = static::getMethodParamDefineTpl($param);
            // 调用传参
            $result['call'][] = static::getMethodParamCallTpl($param);
            // 引用传参
            if($param->isPassedByReference())
            {
                $result['set_args'] .= '$__args__[' . $i . '] = &$' . $param->name . ';';
            }
        }
        foreach($result as $key => &$item)
        {
            if(is_array($item))
            {
                $item = implode(',', $item);
            }
        }
        // 调用如果参数为空处理
        if('' === $result['call'])
        {
            $result['call'] = '...func_get_args()';
        }
        return $result;
    }
743807
protected function getReflectionMethod($class, $method)
    {
        if (!isset($this->methodReflectors[$class])) {
            $this->methodReflectors[$class] = [];
        }
        if (!isset($this->methodReflectors[$class][$method])) {
            $this->methodReflectors[$class][$method] = new \ReflectionMethod($class, $method);
        }

        return $this->methodReflectors[$class][$method];
    }
833019
public static function getOrMethod($method)
    {
        if (! Str::contains(Str::lower($method), 'or')) {
            return 'or' . ucfirst($method);
        }

        return $method;
    }
523316
public static function invokeWithIocParams($obj, $method) {
        $method = new \ReflectionMethod(get_class($obj), $method);
        $args = [];
        if ($method->getNumberOfParameters() > 0) {
            $params = $method->getParameters();
            foreach ($params as $param) {
                $class = $param->getClass();
                if ($class) {
                    $className = $class->getName();
                    $bean = Ioc::get($className);
                    if (!$bean) {
                        $args[] = method_exists($className, 'instance') ? $className::instance() : new $className();
                    } else {
                        $args[] = $bean;
                    }
                } else {
                    $args[] = null;
                }
            }
        }
        $val = $method->invokeArgs($obj, $args);
        return $val;
    }
143175
protected function getSupportedParams($method)
    {
        $columns = [];

        if ($this->isEloquentBuilder()) {
            $model = $this->getHandler()->getModel();
            $columns = in_array(ApiHelper::class, class_uses($model))
                ? $model->$method()
                : $model->getFillable();
        }

        return $columns;
    }
787910
protected function dumpMethod(Method $method)
    {
        $builder = new MethodBuilder();

        $documentation = $method->getDescription()."\n\n";
        $signature = array();

        foreach ($method->getParameters() as $parameter) {
            $builder->addParameter($parameter->getName());
            $documentation .= "@param string $".$parameter->getName()." ".$parameter->getDescription()."\n\n";
            $signature[] = '$'.$parameter->getName();
        }

        $signature = implode(', ', $signature);

        if ($method->isAction()) {
            $documentation .= '@return \Selenium\Browser Fluid interface';

            $body  = '$this->driver->action("'.$method->getName().'"'. ($signature ? ', '.$signature : '') . ');'."\n";
            $body .= "\n";
            $body .= "return \$this;";

        } else {
            $returnType = $method->getReturnType();

            if ($returnType === 'boolean') {
                $getMethod = 'getBoolean';
            } elseif ($returnType === 'string') {
                $getMethod = 'getString';
            } elseif ($returnType === 'string[]') {
                $getMethod = 'getStringArray';
            } elseif ($returnType === 'number') {
                $getMethod = 'getNumber';
                $returnType = 'integer';

                if (0 === strpos($method->getReturnDescription(), 'of ')) {
                    $returnType .= ' number';
                }
            }

            $documentation .= '@return '.$returnType.' '.$method->getReturnDescription();

            $body = 'return $this->driver->'.$getMethod.'("'.$method->getName().'"'.($signature ? ', '.$signature : '').');';
        }

        $builder->setName($method->getName());
        $builder->setBody($body);
        $builder->setDocumentation($documentation);

        return $builder->buildCode();
    }
479666
private function isGetMethod(\ReflectionMethod $method)
    {
        return (
            0 === strpos($method->name, 'get') &&
            3 < strlen($method->name) &&
            0 === $method->getNumberOfRequiredParameters()
        );
    }
75957
public function getParameterType(
        ReflectionMethod $method,
        string $parameterName,
        ? string $default = null
    ) : ? string {
        $parameters = $method->getParameters();

        foreach ($parameters as $parameter) {
            if ($parameter->getName() === $parameterName) {
                $class = $parameter->getClass();

                return $class
                    ? $class->getName()
                    : $default;
            }
        }

        return $default;
    }
732247
public function getMethodAttribute($method)
    {
        if (is_array($method)) {
            return $method;
        } else {
            if (is_string($method)) {
                $method = (integer)$method;
            }
        }

        return VerbsMask::maskToArray($method);
    }
954971
public function getReflectionMethod(string $method)
    {
        if (!isset($this->reflectionMethod[$method])) {
            $this->reflectionMethod[$method] = new ReflectionMethod($this, $method);
        }

        return $this->reflectionMethod[$method];
    }
690892
public static function parseParameters(Method $method) : array
	{
		$taskName = NULL;
		if ($method->hasAnnotation(Parameters::TASK)) {
			$className = $method->getDeclaringClass()->getName();
			$methodName = $method->getName();
			$taskName = $className . ' - ' . $methodName;
		}

		$taskAnnotation = $method->getAnnotation(Parameters::TASK);

		$parameters = [
			static::TASK => is_string($taskAnnotation)
				? Parser::parseName($taskAnnotation)
				: $taskName,
			static::PERIOD => $method->hasAnnotation(Parameters::PERIOD)
				? Parser::parsePeriod((string) $method->getAnnotation(Parameters::PERIOD))
				: NULL,
			static::DAYS => $method->hasAnnotation(Parameters::DAYS)
				? Parser::parseDays((string) $method->getAnnotation(Parameters::DAYS))
				: NULL,
			static::TIME => $method->hasAnnotation(Parameters::TIME)
				? Parser::parseTimes((string) $method->getAnnotation(Parameters::TIME))
				: NULL,
		];

		return $parameters;
	}