@param \ReflectionFunctionAbstract $controller
@param RequestParam                $annotation
@param string                      $type

@return HttpBadRequestException
13013
private function invalidScalarParameterException(\ReflectionFunctionAbstract $controller, RequestParam $annotation, string $type) : HttpBadRequestException
    {
        return new HttpBadRequestException(sprintf(
            '%s() received an invalid %s value for %s parameter "%s" (bound to $%s).',
            $this->reflectionTools->getFunctionName($controller),
            $type,
            $annotation->getParameterType(),
            $annotation->getName(),
            $annotation->getBindTo()
        ));
    }
340006
protected function _callAnnotation(Controller &$class, $annotation = [], $type = 'class', $annotationType = 'Before') {
        foreach ($annotation[$type] as $action => $annotationClasses) {
            foreach ($annotationClasses as $annotationClass) {
                if ($annotationClass['annotation'] == $annotationType) {
                    /** @var \Gcs\Framework\Core\Annotation\Annotations\Common\Before $instance */
                    $instance = $annotationClass['instance'];

                    $className = $instance->class;
                    $methodName = $instance->method;

                    if (method_exists($className, $methodName)) {
                        if ($className == get_class($class)) {
                            $class->$methodName();
                        }
                        else {
                            $reflectionMethod = new \ReflectionMethod($className, $methodName);
                            echo $reflectionMethod->invoke(new $className());
                        }
                    }
                    else {
                        throw new MissingMethodException('The method "' . $methodName . '" from the class "' . $className . '" does not exist');
                    }
                }
            }
        }
    }
960445
protected function invokeAction($type = self::MASTER_REQUEST)
    {
        $this->dispatch('frontcontroller.request');

        $request = $this->getRequest();
        $controllerResolver = $this->getApplication()->getContainer()->get('controller_resolver');
        $controller = $controllerResolver->getController($request);

        // logout Event dispatch
        if (
            null !== $request->get('logout')
            && true === $request->get('logout')
            && true === $this->getApplication()->getSecurityContext()->isGranted('IS_AUTHENTICATED_FULLY')
        ) {
            $this->dispatch('frontcontroller.request.logout');
        }

        if (null !== $controller) {
            $dispatcher = $this->application->getEventDispatcher();

            // dispatch kernel.controller event
            $event = new FilterControllerEvent($this, $controller, $request, $type);
            $dispatcher->dispatch(KernelEvents::CONTROLLER, $event);

            // a listener could have changed the controller
            $controller = $event->getController();

            $eventName = $this->getControllerActionEventName($controller[0], $request->attributes->get('_action'));
            $dispatcher->dispatch($eventName.'.precall', new Event\PreRequestEvent($request));

            // get controller action arguments
            $actionArguments = $controllerResolver->getArguments($request, $controller);

            $response = call_user_func_array($controller, $actionArguments);
            if (!($response instanceof Response)) {
                $this->application->warning(sprintf(
                    'Action %s from controller %s should return an object Response, got %s.',
                    $request->attributes->get('_action'),
                    get_class($controller[0]),
                    gettype($response)
                ));

                $response = new Response();
            }
            $dispatcher->dispatch($eventName.'.postcall', new Event\PostResponseEvent($response, $request));

            return $response;
        } else {
            throw new FrontControllerException(
                sprintf('Unknown action `%s`.', $request->attributes->get('_action')),
                FrontControllerException::BAD_REQUEST
            );
        }
    }
482845
protected function getStatusCode(Rest\Action $annotation, GetResponseForControllerResultEvent $event): int
    {
        if ($annotation->isAutoStatusCode()) {
            if (null === $event->getControllerResult()) {
                return Response::HTTP_NO_CONTENT;
            }

            if (in_array($event->getRequest()->getMethod(), [Request::METHOD_POST, Request::METHOD_PUT])) {
                return Response::HTTP_CREATED;
            }
        }

        return $annotation->getStatusCode();
    }
414304
protected final List<Parameter> getParameters(Type type, List<Annotation> annotations) {
        return getParameters(type, annotations, typesToSkip);
    }
1314316
public function implicitController($controller)
    {
        $container = $this->getContainer();
        $reflection = $container->getReflection()->setClass($controller);
        $methods = $reflection->getMethods('public', false, null);

        foreach ($methods as $key => $method) {
            if ($method !== '__construct') {
                list($uri, $verb, $method, $plain) = $this->getRoutesParameters($method, $controller, $reflection);
                $args = $this->getUriArguments($plain);

                if (!in_array($verb, $this->verbs)) {
                    throw new \RuntimeException("Invalid HTTP verb ($verb) exception.");
                }

                $classParam = ['controller' => $controller, 'method' => $method, 'args' => $args];

                $this->handleRoute($container, $classParam, $verb, $uri);
            }
        }
    }
391881
private function unknownParameterException(\ReflectionFunctionAbstract $controller, RequestParam $annotation) : HttpInternalServerErrorException
    {
        return new HttpInternalServerErrorException(sprintf(
            '%s() does not have a $%s parameter, please check your annotation.',
            $this->reflectionTools->getFunctionName($controller),
            $annotation->getBindTo()
        ));
    }
258020
private function getReflectionMethod($controller)
    {
        if (preg_match('#(.+)::([\w]+)#', $controller, $matches)) {
            $class = $matches[1];
            $method = $matches[2];
        } elseif (preg_match('#(.+):([\w]+)#', $controller, $matches)) {
            $controller = $matches[1];
            $method = $matches[2];
            if ($this->container->has($controller)) {
                $this->container->enterScope('request');
                $this->container->set('request', new Request);
                $class = get_class($this->container->get($controller));
                $this->container->leaveScope('request');
            }
        }

        if (isset($class) && isset($method)) {
            try {
                return new \ReflectionMethod($class, $method);
            } catch (\ReflectionException $e) {
            }
        }

        return null;
    }
1058358
public function getArguments(Request $request, $controller)
    {
        if (is_array($controller)) {
            $r = new \ReflectionMethod($controller[0], $controller[1]);
        } elseif (is_object($controller) && !$controller instanceof \Closure) {
            $r = new \ReflectionObject($controller);
            $r = $r->getMethod('__invoke');
        } else {
            $r = new \ReflectionFunction($controller);
        }

        return $this->doGetArguments($request, $controller, $r->getParameters());
    }
48719
protected void appendFunctionalInterfaceAnnotation(JvmGenericType type) {
		if (type != null && Utils.isFunctionalInterface(type, this.sarlSignatureProvider)
				&& this.annotationFinder.findAnnotation(type, FunctionalInterface.class) == null) {
			addAnnotationSafe(type, FunctionalInterface.class);
		}
	}
503598
public function resolve($annotation, $reflectionClass, $pack)
    {
        $app = $this->app;

        $snakeClass = implode('_',preg_split('/(?=[A-Z])/', $reflectionClass->getShortName(), -1, PREG_SPLIT_NO_EMPTY));
        $relativeNamespace = preg_replace('/'.$pack->getNameSpace().'/', '', $reflectionClass->getName(), 1);
        list($empty, $serviceDir, $serviceClass) = explode('\\', $relativeNamespace);
        $serviceKey = implode('.',[$pack->getPackName(),strtolower($serviceDir), strtolower($snakeClass)]);

        $class = $reflectionClass->getName();
        switch ($annotation->type) {
            case 'factory':
                $app[$serviceKey] = $app->factory(function () use ($class, $app, $pack) {
                    return new $class($app, $pack);
                });
            break;
            case 'shared':
                $app[$serviceKey] = function () use ($class, $app, $pack) {
                    return new $class($app, $pack);
                };
            break;
            case 'protected':
                $app[$serviceKey] = $app->protect(function () use ($class, $app, $pack) {
                    return new $class($app, $pack);
                });
            break;
        }

        $this->registerParameters($reflectionClass, $serviceKey);
    }
242883
public function initCron($src, $controller, $action) {
        if (!Config::config()['user']['debug']['maintenance']) {
            $this->_routeCron($src, $controller, $action);

            if ($this->_route == true) {
                $this->_setFunction($this->request->src);
                $this->_setEvent($this->request->src);
            }
        }
    }
777727
private function registerFilter($method, $type, $controller, $controllerService)
    {
        $app = $this->app;

        if ($type == 'before') {
            $callback = function (Request $request) use ($controllerService, $app, $method) {
                $service = $this->locateService($controllerService, $method);
                $method = $service['service_method'];
                $class = $service['service_class'];

                return $app[$class]->$method($request);
            };
        } else {
            $callback = function (Request $request, Response $response) use ($controllerService, $app, $method) {
                $service = $this->locateService($controllerService, $method);
                $method = $service['service_method'];
                $class = $service['service_class'];

                return $app[$class]->$method($request, $response);
            };
        }

        $controller->$type($callback);
    }
878693
public function evaluateAnnotation(
        Request $request,
        Annotation $annotation,
        ReflectionMethod $method
    ) {
        /**
         * Annotation is only loaded if is typeof WorkAnnotation.
         */
        if ($annotation instanceof ToJsonResponse) {

            /**
             * If JsonResponse annotation, set to true for future events.
             *
             * Also saves all needed info from annotation
             */
            $this->returnJson = true;
            $this->status = $annotation->getStatus() ?: $this->defaultStatus;
            $this->headers = $annotation->getHeaders() ?: $this->defaultHeaders;
        }
    }
1204399
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
    {
        $this->eventDispatcher = $this->container['internal.event_dispatcher'];

        $controllerListener = new ControllerListener();
        $controllerListener->setContainer($this->container);
        $this->attach(KernelEvents::FILTER_CONTROLLER, [$controllerListener, 'filterController'], 255);

        foreach ($this->container['event_listeners'] as $config) {
            try {
                $class = $this->container[$config['class']];
            } catch (\Exception $exception) {
                $class = new $config['class']();
                if ($class instanceof ContainerAwareInterface) {
                    $class->setContainer($this->container);
                }
            }

            $this->attach($config['event'], [$class, $config['method']], $config['priority']);
        }

        return $this->app->handle($request, $type, $catch);
    }
903588
@Override
    public void visit(SingleMemberAnnotationExpr anno, ControllerModel controller) {

        //org.wisdom.api.annotations.Path
        if(anno.getName().getName().equals(ANNOTATION_PATH)){
            controller.setBasePath(asString(anno.getMemberValue()));
        }
    }
660630
private function getDate(Request $request, Annotation $annotation, $type)
    {
        $nameMethod = 'get' . $type . 'Name';
        return $this->readValue(
                        $request,
                        $annotation->$nameMethod(),
                        $annotation->isRequired(),
                        $this->parseDate($annotation, 'default' . $type)
                )
                ->asDate(new DateRange(
                        $this->parseDate($annotation, "min{$type}Date"),
                        $this->parseDate($annotation, "max{$type}Date")
                )
        );
    }