Recursively build the dependency list for the provided method.

@param \ReflectionMethod $method The method for which to obtain dependencies.

@return array An array containing the method dependencies.
@throws \InvalidArgumentException
493280
protected function getDependencies(\ReflectionMethod $method)
    {
        $dependencies = array();

        foreach ($method->getParameters() as $param) {
            $dependency = $param->getClass();

            if (is_null($dependency)) {
                if ($param->isOptional()) {
                    $dependencies[] = $param->getDefaultValue();
                    continue;
                }
            } else {
                $dependencies[] = $this->resolve($dependency->name);
                continue;
            }

            throw new \InvalidArgumentException('Could not resolve ' . $param->getName());
        }

        return $dependencies;
    }
1221213
protected function buildMethod(ReflectionMethod $method)
    {
        $argString = "";
        $paramString = "";
        $returnString = "";
        foreach ($method->getParameters() as $value) {
            $argString .= "\${$value->getName()}, ";
            $paramString .= $this->getParamString($value);
        }

        $methodReturn = $method->getReturnType();
        if (!is_null($methodReturn)) {
            if (!$methodReturn->isBuiltin()) {
                $this->useList[] = sprintf("%s", $methodReturn);
                $arr = explode("\\", $methodReturn);
                $methodReturn = array_pop($arr);
            }

            $returnString = ": {$methodReturn}";
        }

        $argString = trim($argString, ", ");
        $paramString = trim($paramString, ", ");
        $replaces = array(
            $method->getDocComment(),
            $method->getName(),
            $paramString,
            $returnString,
            $argString
        );
        return str_replace(self::METHOD_TPL_SEARCHES, $replaces, $this->template->getMethodTemplate());
    }
561588
protected function getDependencyMapping()
    {
        $constructor = (new ReflectionClass($this->className))
            ->getConstructor();

        $dependencies = [];

        if (!is_null($constructor)) {
            foreach ($constructor->getParameters() as $param) {
                $dependencies[$param->getClass()->getName()] = $param->getName();
            }
        }

        return $dependencies;
    }
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;
    }
727407
public function getVariables( $method )
	{
		if( !strlen( $method = trim( $method ) ) )
			return $this->methods;
		if( !array_key_exists( $method, $this->methods ) )
			throw new InvalidArgumentException( 'Method "'.$method.'" not found' );
		return $this->methods[$method]['variables'];
	}
1061566
public function getInMethod(string $method): array
    {
        if (isset($this->methodIndex[$method])) {
            return $this->methodIndex[$method];
        }

        return [];
    }
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];
    }
388701
public function setMethod($method)
    {
        // Allow null, otherwise expect an array or a string
        if (null !== $method && !is_array($method) && !is_string($method)) {
            throw new InvalidArgumentException('Expected an array or string. Got a '. gettype($method));
        }

        $this->method = $method;

        return $this;
    }
945961
public function setMethod($method)
	{
		if ($method === null || !is_array($method) || empty($method)) {
			throw new InvalidArgumentException('No method provided');
		}

		foreach ($method as $m) {
			if (!in_array($m, array('GET','POST','PUT','PATCH','DELETE'))) {
				throw new InvalidArgumentException('Method not allowed. allowed methods: GET, POST, PUT, PATCH, DELETE');
			}
		}

		$this->method = $method;

		return $this;
	}
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;
    }
943560
public function loadDependenciesByReflectionMethod(ReflectionMethod $reflectionMethod)
    {

        // initialize the array for the dependencies
        $dependencies = array();

        // load the object manager instance
        /** @var \AppserverIo\Psr\Di\ObjectManagerInterface $objectManager */
        $objectManager = $this->getNamingDirectory()->search(
            sprintf('php:global/%s/%s', $this->getApplication()->getUniqueName(), ObjectManagerInterface::IDENTIFIER)
        );

        // iterate over the constructor parameters
        /** @var \AppserverIo\Lang\Reflection\ParameterInterface $reflectionParameter */
        foreach ($reflectionMethod->getParameters() as $reflectionParameter) {
            $dependencies[] = $this->get($objectManager->getPreference($reflectionParameter->getType()));
        }

        // return the initialized dependencies
        return $dependencies;
    }
171572
protected function resolveClassMethodDependencies( array $parameters, $instance, $method )
	{
		if ( !method_exists( $instance, $method ) )
			return $parameters;

		return $this->resolveMethodDependencies( $parameters, new ReflectionMethod( $instance, $method ) );
	}
404984
public function getRunnerByMethod(\ReflectionMethod $method)
    {
        $class = new \ReflectionClass($method->class);
        $className = $class->name;

        if (!array_key_exists($className, $this->runnerMappings)) {
            return;
        }

        $methodName = $method->name;
        if (!array_key_exists($methodName, $this->runnerMappings[$className])) {
            return;
        }

        return $this->runnerMappings[$className][$methodName];
    }
58789
protected function renderMethodParameters($method)
    {
        $parameters = [];

        foreach ($method->getParameters() as $parameter) {
            if ($parameter->isPassedByReference()) {
                throw new InvalidArgumentException(sprintf(
                    'Parameter [%s] in %s->%s cannot declared as a reference.',
                    $parameter->getName(), $method->getDeclaringClass(), $method->getName()
                ));
            }

            $definition = $this->renderParameterTypeHint($parameter);
            $definition .= $parameter->isVariadic() ? '...' : '';
            $definition .= '$'.$parameter->getName();

            if (! $parameter->isVariadic()) {
                if ($parameter->isDefaultValueAvailable()) {
                    $definition .= ' = '.var_export($parameter->getDefaultValue(), true);
                } elseif ($parameter->isOptional()) {
                    $definition .= ' = null';
                }
            }

            $parameters[] = $definition;
        }

        return '('.implode(', ', $parameters).')';
    }
51356
public function addDependency(string $key, string $method): ComponentBuilder
    {
        $this->dependencies[$key] = $method;
        return $this;
    }
413373
private function getArguments(\ReflectionMethod $method)
    {
        $arguments = [];

        foreach ($method->getParameters() as $index => $parameter) {
            $argument = $this->getArgument($index, $parameter);

            if (null === $argument && false === $parameter->allowsNull()) {
                throw new Exception(
                    sprintf('Could not inject parameter #%d into "%s::__construct"', $index, $this->item)
                );
            }

            $arguments[] = $argument;
        }

        return $arguments;
    }
732563
public function getMethodAnnotations($method)
    {
        $reflector = new ReflectionClass($this->className);
        $doc = $reflector->getMethod($method)->getDocComment();
        $annotations = [];
        foreach ($this->filteringList as $filter) {
            preg_match_all('#@' . $filter . '(.*?)\n#s', $doc, $annotation);
            if (!empty($annotation[1])) {
                $annotations[$filter] = $annotation[1];
            }
        }
        return $annotations;
    }