checks if the annotation exists

@param  RoutingTable $annotations
@param  string       $entityAlias
@param  string       $method
@return boolean
546405
public static function exists(RoutingTable $annotations = null, $entityAlias, $method) {
        return !empty($annotations) && $annotations->get($entityAlias) !== null && $annotations->get($entityAlias)->$method() !== null;
    }
698341
public static function addMethodAnnotations($className, $methodName, ...$annotations)
    {
        if(isset(static::$annotations[$className]['Methods'][$methodName]))
        {
            static::$annotations[$className]['Methods'][$methodName] = array_merge(static::$annotations[$className]['Methods'][$methodName], $annotations);
        }
        else
        {
            static::$annotations[$className]['Methods'][$methodName] = $annotations;
        }
        foreach($annotations as $annotation)
        {
            static::$annotationRelation[get_class($annotation)]['Method'][] = [
                'type'      =>  'Method',
                'class'     =>  $className,
                'method'    =>  $methodName,
                'annotation'=>  $annotation,
            ];
        }
    }
140568
public static function create($method, DataSource $annotation = null) {
        Str::assert($method, 'method');

        $annotationStatusCodes = !empty($annotation) && $annotation->getStatusCodes() !== null ? $annotation->getStatusCodes() : array();
        return $annotationStatusCodes ?: self::$expectedStatusCodes[$method];
    }
1374600
public static function methodExists($objectInstance, $method, $name)
    {
        self::isString($method, 'method');
        self::notNull($objectInstance, 'objectInstance');
        self::isObject($objectInstance, 'objectInstance');

        if (method_exists($objectInstance, $method)) {
            return true;
        } else {
            throw new \InvalidArgumentException(
                sprintf(
                    Resources::ERROR_METHOD_NOT_FOUND,
                    $method,
                    $name
                )
            );
        }
    }
875729
private function getAdditionalParams(array &$params, $entityClass, $routeType, $entity = null)
    {
        if (in_array($routeType, self::$typesRequiringId) && !isset($params['id']) && !empty($entity)) {
            try {
                $params['id'] = $this->identifierAccessor->getValue($entity);
            } catch (MetadataException $ex) {
                throw new RouteException(
                    sprintf('Unable to generate URL or path for route "%s": "%s".', $routeType, $ex->getMessage())
                );
            }
        }

        $meta = $this->metadataManager->getMetadata($entityClass);

        if (!$meta->hasParent() || !in_array($routeType, self::$typesRequiringParentId)) {
            return;
        }

        $associationParam = $meta->getParent()->getAssociationParameterName();

        if (isset($params[$associationParam])) {
            return;
        }
        if (empty($entity)) {
            throw new RouteException(
                sprintf('Route "%s" for entity "%s" requires parameter "%s".', $routeType, $entityClass, $associationParam)
            );
        }

        $params[$associationParam] = $this->getParentEntityId($entity, $meta->getParent()->getAssociation(), $routeType);
    }
765988
@SafeVarargs
    private static void checkNoAnnotations(Method method, Class<? extends Annotation> foundAn,
            Class<? extends Annotation>... disallowedAn) {

        for (Class<? extends Annotation> an : disallowedAn) {
            if (method.isAnnotationPresent(an)) {
                throw new EventsException("Method " + Utils.methodToString(method)
                        + " marked with @" + foundAn.getSimpleName()
                        + " cannot be marked with @" + an.getSimpleName());
            }
        }
    }
1234339
public function addRoute(string $method, string $route, ...$callback)
    {
        $method = strtolower($method);
        $route = ltrim($route, '/');
        $group = rtrim($this->group, '/') . '/';
        $route = $group . $route;
        $scope = $this->middleware->count();
        $this->layer[$method][] = new Route(
            $method,
            $route,
            $callback,
            $scope,
            $this->group
        );

        return true;
    }
450725
public static function createFromTokens(array $tokens, $apiUrl, DataSource $annotation = null) {
        $id    = Identifier::create($tokens);
        $route = empty($annotation) || $annotation->getRoute() === null ? Table::create($tokens) : $annotation->getRoute();

        return self::create($route, $apiUrl, $id);
    }
1084264
public function matchRoute( string $method, string $uri )
  {
    # Make dispatcher
    $dispatcher = new \FastRoute\Dispatcher\GroupCountBased($this->routeCollector->getData());

    # Dispatch the requested METHOD and URI and see if a route matches
    $routeInfo = $dispatcher->dispatch($method, $uri);

    # Examine $RouteInfo response
    switch ($routeInfo[0])
    {
      # We found a route match
      case \FastRoute\Dispatcher::FOUND:
        # URLDecode each argument
        foreach ($routeInfo[2] as $idx=>$r)
        {
          $routeInfo[2][$idx] = \urldecode($r);
        }

        # Return the Handler + args
        return [
          'method'=>$method,
          'path'=>$uri,
          'handler'=>$routeInfo[1],
          'args'=>$routeInfo[2]
        ];
        break;

      # Nothing found
      case \FastRoute\Dispatcher::NOT_FOUND:
        return [];
        break;

      # This should never happen to us ...
      case \FastRoute\Dispatcher::METHOD_NOT_ALLOWED:
        return [];
        break;

      # Default we return empty
      default:
        return [];
        break;
    }
  }
840187
public function matches(AbstractAnnotation $annotation) {
		if (!$annotation instanceof self) {
			return false;
		}
		if ($annotation->getVariable() !== $this->variable) {
			return false;
		}

		return true;
	}
423455
protected function isIndirectFactoryMethod(MethodNode $method)
    {
        $primaryPrefixes = $method->findChildrenOfType('MemberPrimaryPrefix');
        if (count($primaryPrefixes) < 1) {
            return false;
        }

        $firstPrimaryPrefix = $primaryPrefixes[0];

        if ($firstPrimaryPrefix->getChild(0)->getName() === '$this' && $this->isMethodNameStartsWithCreate($firstPrimaryPrefix->getChild(1)->getName())) {
            return true;
        }

        if ($firstPrimaryPrefix->getChild(0)->getName() === '$this' && substr($firstPrimaryPrefix->getChild(1)->getName(), 0, 2) === '->') {
            if ($this->isMethodNameStartsWithCreate($primaryPrefixes[1]->getChild(0)->getName())) {
                return true;
            }
        }

        if ($firstPrimaryPrefix->getParent()->getName() === 'return' &&
            $this->isMethodNameStartsWithCreate($firstPrimaryPrefix->getChild(1)->getNode()->getImage()) &&
            $this->isStaticMethodCall($firstPrimaryPrefix)
        ) {
            return true;
        }

        foreach ($primaryPrefixes as $primaryPrefix) {
            if ($primaryPrefix->getParent()->getName() === 'return') {
                $returnNodeChildren = $primaryPrefix->findChildrenOfType('MethodPostfix');

                foreach ($returnNodeChildren as $returnNodeChild) {
                    if ($this->isMethodNameStartsWithCreate($returnNodeChild->getChild(0)->getName())) {
                        return true;
                    }
                }
            }
        }

        return false;
    }
1369769
private static function routeMatch(string $request_url, string $request_method, Route $route) :bool {

		// if the method is set for that route, and it doesn't match
		if(!$route->hasMethod($request_method)) {
			return false;
		}
		// if the url doesn't begin with the static segment or that route
		if(!$route->hasStaticUrlSegment($request_url)) {
			return false;
		}
		// if we've got a redirect, let's go for it
		$route->redirectIfItIsOne();
		// get a list of current request parameters, with numerical indexes
		$indexed_request_parameters = Request::getUrlIndexedParameters($route->staticSegment);
		// if restricttion against url parameters don't match
		if(!$route->validatesTheseParameters($indexed_request_parameters)) {
			return false;
		}
		// send the named parameters to the request class
		$route->sendNamedParametersToRequest($indexed_request_parameters);
		// deduce the dynamic action from the url parameters if necessary
		$route->deduceAction();
		// check if they match defined constraints
		return true;

	}
1057745
private boolean containsAnnotation(List<AnnotationExpr> annos, String annotationName) {
        for (AnnotationExpr anno : annos) {
            if (anno.getName().getName().equals(annotationName)) {
                return true;
            }
        }
        return false;
    }
1195775
public static function target($route, $controller, $method)
    {
        $content = self::traitTarget($route, $controller, $method);
        //
        self::addRoute($content);

        return true;
    }
801950
private function isMethodReadable(\ReflectionMethod $method)
    {
        // if method starts with _ - skip
        if ('_' === substr($method->getName(), 0, 1)) {
            return false;
        }

        $hasNoRouteMethod = (bool) $this->readMethodAnnotation($method, 'NoRoute');
        $hasNoRouteClass = (bool) $this->readClassAnnotation($method->getDeclaringClass(), 'NoRoute');

        $hasNoRoute = $hasNoRouteMethod || $hasNoRouteClass;
        // since NoRoute extends Route we need to exclude all the method NoRoute annotations
        $hasRoute = (bool) $this->readMethodAnnotation($method, 'Route') && !$hasNoRouteMethod;

        // if method has NoRoute annotation and does not have Route annotation - skip
        if ($hasNoRoute && !$hasRoute) {
            return false;
        }

        return true;
    }
556846
public function match($route, $method = 'GET', $options = [])
    {
        $this->count = 0;

        foreach ($this->routes as $routeItem) {
            $this->count++;

            if (!$this->matchOptions($routeItem, $method, $options)) {
                continue;
            }

            if ($this->matchRoute($route, $routeItem)) {
                return $routeItem;
            }
        }

        return false;
    }
334893
public function hasRoute(ServerRequestInterface $request, $withMethod = true)
    {
        $route = $this->findRoute($request->getUri(), $withMethod ? $request->getMethod() : null);
        return isset($route);
    }