Get function arguments for controler

@param mixed $paramMap   parameter map
@param mixed $matches    found matched variables
@param mixed $parameters route parameters
@param mixed $handlers   handler that should be executed

@return mixed
192560
private function getFunctionArgumentsControlers(
        $paramMap,
        $matches,
        $parameters,
        $handlers
    ) {
        $output  = [];
        $matches = array_values($matches);

        if (isset($parameters)) {
            foreach ($handlers as $placeholder) {
                if ($this->isPlaceholder($placeholder)) {
                    foreach ($parameters as $key => $parameterName) {
                        if ($parameterName[0][0] == $placeholder) {
                            unset($parameters[$key]);
                            unset($matches[$key]);
                        }
                    }
                }
            }

            $parameters = array_values($parameters);
            $matches    = array_values($matches);

            foreach ($parameters as $key => $valueName) {
                foreach ($paramMap as $possition => $value) {
                    if ($value == $valueName[1][0]) {
                        $output[] = $matches[$possition];
                    }
                }
            }
        }

        return $output;
    }
173356
private function extractParameters($matches, CompiledRoute $compiledRoute)
    {
        $params = [];
        foreach ($compiledRoute->getVariables() as $index => $var) {
            $params[$var['name']] = $matches[($index + 1)][0];
        }

        return $params;
    }
702402
private function getArgsFromParam($params, $exclude = array())
    {
        $pairs = array();

        foreach ($params as $name => $value) {
            if (in_array($name, $exclude)) {
                continue;
            }

            $pairs[$name] = $value;
        }

        return $pairs;
    }
11420
public function getCsrfToken(string $control, string $method, array $params): string
	{
		return Helpers::getCsrfToken($this->getSession(), $control, $method, $params);
	}
625850
public static function forFunction($function, array $functionParameters = []) : RouteMatch
    {
        try {
            $controller = new \ReflectionFunction($function);
        } catch (\ReflectionException $e) {
            throw RoutingException::invalidControllerFunction($e, $function);
        }

        return new self($controller, [], $functionParameters);
    }
146740
public function resolveFunctionParameters($callable, $parameters, $labels = false)
    {
        // method reflection
        $reflectionFunction = new ReflectionFunction($callable);

        // resolved array of parameters
        return $this->resolveParameters($reflectionFunction->getParameters(), $parameters, $labels);
    }
8965
public function handle(\ReflectionParameter $parameter)
    {
        $func = $parameter->getDeclaringFunction();
        $method = new \ReflectionMethod($parameter->getDeclaringClass()->name, $func->name);
        $parameter->getDeclaringFunction()->name;
        $annotations = $this->reader->getMethodAnnotations($method);
        foreach ($annotations as $annotation) {
            if ($annotation instanceof ResourceParam && $annotation->param === $parameter->name) {
                return $this->getResourceParam($annotation->uri);
            }
        }
        (new VoidParamHandler)->handle($parameter);
    }
1136768
public function trigger( $trigger, $params = [], $halt = false )
	{
		$keys = explode( '.', $trigger );
		$current = $this->triggers;
		$results = [];

		foreach ( $keys as $key )
		{
			$current = Arr::get( $current, $key );
			if ( !is_null( $current ) ) // && array_key_exists( '__hook_', $current ) )
			{
				foreach ( preg_grep_keys( "/__hook_[0-9]?/", $current ) as $hook )
				{
					if ( array_key_exists( $hook, $this->hooks ) )
					{
						$hook = $this->hooks[$hook];
						$result = BindingBuilder::call( $hook['callable'], is_array( $params ) ? $params : ['payload' => $params] );
						if ( !is_null( $result ) )
						{
							if ( $halt )
								return $result;
							else if ( is_array( $result ) )
								$results = array_merge_recursive( $results, $result );
							else
								$results[] = $result;
						}
					}
				}
			}
		}

		return $halt ? null : $results;
	}
753125
protected function getParameters($paramMapping)
    {
        $parameters = array();
        foreach ($paramMapping as $propertyName => $mapping) {
            $paramName = isset($mapping['fieldName']) ? $mapping['fieldName'] : $propertyName;
            $parameters[$paramName] = $propertyName;
        }
        return $parameters;
    }
699238
public function getCsrfToken($control, $method, $params): string
    {
        array_walk(
            $params,
            function (&$value) {
                if (is_object($value)) {
                    $value = $this->entityUnloader->filterOut($value);
                }
            }
        );

        return $this->nextrasGetCsrfToken($control, $method, $params);
    }
552294
private static Iterable<String> getParametersFromMap(final Map<String, String> paramMap, final boolean strict) {
        return Iterables.transform(paramMap.entrySet(), new Function<Map.Entry<String, String>, String>() {
            @Override public String apply(final Map.Entry<String, String> input) {
                return input == null ? null : ENTRY_JOINER.join(UriEscaper.escapeQueryParam(input.getKey(), strict),
                                                                UriEscaper.escapeQueryParam(input.getValue(), strict));
            }
        });
    }
636079
private function createCallbackFromString( $callFunc, $params ) {

		if ( is_string( $callFunc ) ) {
			$callFunc = function () use ( $callFunc, $params ) {
				$controllerParts    = explode( '@', $callFunc );
				$controllerParts[0] = explode( '\\', $controllerParts[0] );
				$hmvc               = '';
				$controllerPaths    = count( $controllerParts[0] );

				if ( $controllerPaths > 1 ) {

					foreach ( $controllerParts[0] as $idx => $controllerPart ) {

						if ( $idx == ( $controllerPaths - 1 ) ) {
							break;
						}

						$hmvc .= '\\' . $controllerPart;
					}

				}

				$controller = $hmvc . '\\Controllers\\' . $controllerParts[0][ $controllerPaths - 1 ];
				$c          = new \ReflectionClass( $controller );
				$c          = $c->newInstanceArgs( $params );

				return call_user_func_array( array( $c, $controllerParts[1] ), $this->route->getParams() );
			};

			return $callFunc;

		}

		return $callFunc;
	}
999359
private function handle($routes, $fireAfterRoutingCallback = false)
    {
        // Counter to keep track of the number of routes we've handled
        $handledRequest = 0;

        $i = 0;
        // Loop all routes
        foreach ($routes as $route) {
            if ($matches = $this->isPatternMatches($route['pattern'], true)) {
                if ($this->middleware) {
                    $this->handleMiddleware();
                }

                // Extract the matched URL (and only the parameters)
                $params = $this->extractParams($matches);
                array_unshift($params, $this);

                // call the handling function with the URL
                $this->handledRoute = call_user_func_array($route['fn'], $params);
                $this->container->set('response', $this->handledRoute);

                $handledRequest++;

                // If we need to quit, then quit
                if ($fireAfterRoutingCallback) {
                    // If a route was handled, perform the finish callback (if any)
                    $this->handle($this->afterRouter);
                }
            }
            $i++;
        }

        // Return the number of routes handled
        return $handledRequest;
    }
344195
static function resolveCallableWithArgs(callable $callable, $parameters)
    {
        if ($parameters instanceof \Traversable)
            $parameters = \Poirot\Std\cast($parameters)->toArray();


        $reflection       = self::makeReflectFromCallable($callable);
        $matchedArguments = self::resolveArgsForReflection($reflection, $parameters);

        if (!empty($parameters) && empty($matchedArguments))
            // In Case That Fun Has No Any Argument.
            // exp. func() { $args = func_get_args() ..
            $matchedArguments = $parameters;

        $callbackResolved = function() use ($callable, $matchedArguments) {
            return call_user_func_array($callable, $matchedArguments);
        };

        return $callbackResolved;
    }
820274
private function getParametersFromMatchString($matchString, $pattern)
    {
        $parameters = [];
        $parameterIndices = $this->getMatchStringParameterIndices($matchString, $pattern);

        foreach ($parameterIndices as $position => $parameterIndex) {
            $start = $parameterIndex['index'];
            $foo = $position + 1;

            if (isset($parameterIndices[$position + 1])) {
                $length = $parameterIndices[$foo]['index'] - $start - strlen($parameterIndices[$foo]['prefix']);

                $parameters[] = substr($matchString, $start, $length);
            } else {
                $parameter = substr($matchString, $start);

                if (!empty($parameter)) {
                    $parameters[] = $parameter;
                }
            }
        }

        return $parameters;
    }
126030
protected function execute($request_method, $url, $parameters = null)
	{
		$extra_options = array(
			CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
			CURLOPT_USERPWD => $this->_apiUsername . ':' . $this->_apiKey,
		);

		$url = 'https://www.browserstack.com/automate/' . $url;

		list($raw_results,) = $this->_curlService->execute($request_method, $url, $parameters, $extra_options);

		return json_decode($raw_results, true);
	}
441060
private function resolveControlerAction($matches, $parameters, $handler)
    {
        $controler = $handler['controler'];
        $action    = $handler['action'];
        $namespace = $this->resolveNamespace($parameters, $handler, $matches);

        if ($this->isPlaceholder($action)) {
            $transformed = $this->transformHandler($matches, $parameters, $handler);
            if ($this->isPlaceholder($controler)) {
                $controler = $namespace.'\\'.$transformed['controler'];
            } else {
                $controler = $namespace.'\\'.$controler;
            }

            return [
                $controler,
                $transformed['action']
            ];
        }

        return [
            $namespace.'\\'.$controler,
            $action
        ];
    }