Parses name of cron task.

@param string $annotation
@return string|null
358828
public static function parseName(string $annotation)
	{
		$name = Strings::trim($annotation);
		$name = Strings::length($name) > 0 ? $name : NULL;

		return $name;
	}
665464
public static function getClassAnnotations($className, $annotationClassName = null)
    {
        if(!isset(static::$annotations[$className]['Class']))
        {
            return [];
        }
        if(null === $annotationClassName)
        {
            return static::$annotations[$className]['Class'];
        }
        else
        {
            $result = [];
            foreach(static::$annotations[$className]['Class'] as $annotation)
            {
                if($annotation instanceof $annotationClassName)
                {
                    $result[] = $annotation;
                }
            }
            return $result;
        }
    }
894672
private static function collectTask(string $className, Task $objectAnnotation)
    {
        $name = $objectAnnotation->getName();
        $beanName = empty($name) ? $className : $name;
        $coroutine = $objectAnnotation->isCoroutine();

        self::$tasks['mapping'][$className] = $beanName;
        self::$tasks['task'][$beanName] = [
            $className,
            $coroutine
        ];
    }
246875
protected function getRouteConfig(Route $annotation)
    {
        return [
            $annotation->getName() => [
                'type' => $annotation->getType(),
                'options' => [
                    'route' => $annotation->getRoute(),
                    'defaults' => $annotation->getDefaults(),
                    'constraints' => $annotation->getConstraints()
                ],
                'priority' => (int) $annotation->getPriority(),
                'may_terminate' => (bool) $annotation->getMayTerminate(),
                'child_routes' => []
            ]
        ];
    }
324609
protected function getValidator($name, $annotation) {
        $validate = array();
        switch($name) {
            case 'NotBlank':
            case 'NotNull':
                $validate['type'] = "presence";
                break;
            case 'Email':
                $validate['type'] = "email";
                break;
            case 'Length':
                $validate['type'] = "length";
                $validate['max'] = (int)$annotation->max;
                $validate['min'] = (int)$annotation->min;
                break;
            case 'Regex':
                if ($annotation->match) {
                    $validate['type'] = "format";
                    $validate['matcher']['skipEncode'] = true;
                    $validate['matcher']['value'] = $annotation->pattern;
                }
                break;
            case 'MaxLength':
            case 'MinLength':
                $validate['type'] = "length";
                if ($name == "MaxLength") {
                    $validate['max'] = (int)$annotation->limit;
                } else {
                    $validate['min'] = (int)$annotation->limit;
                }
                break;
            case 'Choice':
                $validate['type'] = "inclusion";
                $validate['list'] = $annotation->choices;
                break;
            default:
                $validate['type'] = strtolower($name);
                $validate += get_object_vars($annotation);
                break;
        }
        return $validate;
    }
1106403
public function validatePropertyAnnotation($annotation)
    {
        if (!in_array($annotation, $this->propertyAnnotations)) {
            throw $this->getException(
                'The property annotation isn\'t valid ("%s" given, expecting one of following: %s)',
                [$annotation, implode(', ', $this->propertyAnnotations)]
            );
        }

        return $annotation;
    }
877512
public function parser(string $className, $objectAnnotation = null, string $propertyName = "", string $methodName = "", $propertyValue = null)
    {
        Collector::$methodAnnotations[$className][$methodName][] = get_class($objectAnnotation);
        return null;
    }
948815
protected function extractAnnotation(KernelEvent $event, $annotationClassName)
    {
        $controller = $this->resolver->getController($event->getRequest());
        $reflectionClass = new \ReflectionClass($controller[0]);
        $annot = $this->annotationReader->getMethodAnnotation($reflectionClass->getMethod(
            $controller[1]),
            $annotationClassName
        );

        if(!$annot) {
            $annot = $this->annotationReader->getClassAnnotation($reflectionClass, $annotationClassName);
        }

        return $annot;
    }
644651
private function normalizeAnnotation(Annotation $annotation)
    {
        return [
            'value' => $annotation->getValue(),
            'timestamp' => $annotation->getTimestamp(),
            'endpoint' => null !== $annotation->getHost() ? $this->normalizeEndpoint($annotation->getHost()) : null,
        ];
    }
305740
public function parse()
    {
        $annotations = ['rest' => []];
        foreach ($this->classes as $c) {
            $classAnnotations = $this->annotationsFromClass($c->getName())->toArray();
            if (isset($classAnnotations['rest'])) {
                $annotations['rest'] = array_merge($classAnnotations['rest'], $annotations['rest']);
            }
        }
        $annotations = new ConfigObject($annotations);

        $this->classDefaults = $annotations->get('rest', new ConfigObject([]));

        // get method annotations
        $annotations = ['rest' => [], 'param' => []];
        foreach ($this->classes as $c) {
            try {
                $methodAnnotations = $this->annotationsFromMethod($c->getName(), $this->method->name)->toArray();
            } catch (\Exception $e) {
                continue;
            }
            if (isset($methodAnnotations['rest']) && is_array($methodAnnotations['rest'])) {
                $annotations['rest'] = array_merge($methodAnnotations['rest'], $annotations['rest']);
            }
            if (isset($methodAnnotations['param'])) {
                if (is_array($methodAnnotations['param'])) {
                    $annotations['param'] = array_merge($methodAnnotations['param'], $annotations['param']);
                } else {
                    $annotations['param'][] = $methodAnnotations['param'];
                }

            }
        }

        $annotations = new ConfigObject($annotations);

        $restAnnotations = $annotations->get('rest', new ConfigObject([]));
        $paramAnnotations = $annotations->get('param', new ConfigObject([]));

        // check if we should ignore this method
        if ($restAnnotations->get('ignore', false) !== false) {
            return false;
        }

        // create ApiMethod instance
        $parsedMethod = new ParsedMethod($this->method->name);

        // method
        $parsedMethod->method = $this->getMethod($restAnnotations);
        // role
        $parsedMethod->role = $this->getRole($restAnnotations);
        // cache.ttl
        $parsedMethod->cache = $this->getCache($restAnnotations);
        // header.cache.expires
        $parsedMethod->header = $this->getHeader($restAnnotations);
        // default
        $parsedMethod->default = $this->getDefault($restAnnotations);
        // rateControl.ignore
        $parsedMethod->rateControl = $this->getRateControl($restAnnotations);

        // parse method parameters
        $parameterParser = new ParameterParser($this->method->getParameters(), $paramAnnotations);
        $parameters = $parameterParser->parse();
        foreach ($parameters as $p) {
            $parsedMethod->addParameter($p);
        }

        // build the url pattern
        if ($restAnnotations->get('url', false)) {
            // build url pattern using the provided rest.url pattern
            $urlPattern = $this->buildUrlPatternFromPattern($restAnnotations->get('url'), $parameters);
            $resourceNaming = true;
        } else {
            // build url pattern using method name and parameters
            $urlPattern = $this->buildUrlPatternStandard($this->method->name, $parameters);
            $resourceNaming = false;
        }

        $parsedMethod->setUrlPattern($urlPattern, $resourceNaming);

        return $parsedMethod;
    }
701146
public function getAnnotation($key) {
        if (is_array($key)) {
            $key = implode('_', $key);
        }

        if (array_key_exists($key, $this->annotations)) {
            return $this->annotations[$key];
        }
        else {
            return null;
        }
    }
1122989
private function getReturnsFromAnnotation(?Annotation $annotation): array
    {
        return $this->isFilledReturnAnnotation($annotation)
            ? explode('|', preg_split('~\\s+~', $annotation->getContent())[0])
            : [];
    }
901187
public function getClassAnnotations($className, $annotationClassName = null)
    {
        $className = $this->prepareClassReflectionForUsage($className);

        $annotationClassName = $annotationClassName === null ? null : $this->cleanClassName($annotationClassName);
        if (!isset($this->classReflectionData[$className][self::DATA_CLASS_ANNOTATIONS])) {
            return [];
        }
        if ($annotationClassName === null) {
            return $this->classReflectionData[$className][self::DATA_CLASS_ANNOTATIONS];
        }

        $annotations = [];
        foreach ($this->classReflectionData[$className][self::DATA_CLASS_ANNOTATIONS] as $annotation) {
            if ($annotation instanceof $annotationClassName) {
                $annotations[] = $annotation;
            }
        }

        return $annotations;
    }
368565
public static function parseDays(string $annotation)
	{
		static $validValues = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun',];

		$days = NULL;
		$annotation = Strings::trim($annotation);
		if (Strings::length($annotation)) {
			$days = static::translateToDayNames($annotation);
			$days = static::expandDaysRange($days);
			foreach ($days as $day) {
				if (!in_array($day, $validValues)) {
					throw new InvalidParameterException(
						"Given day parameter '" . $day . "' must be one from " . implode(', ', $validValues) . "."
					);
				}
			}
			$days = array_values(array_intersect($validValues, $days));
		}

		return $days ?: NULL;
	}
798047
private function create($annotation, $context)
    {
        $logger = $this->getLogger();
        $name = $annotation['name'];
        if (!$this->isValidName($name)) {
            return null;
        }
        $annotationClass = $this->resolveClassName($name, $context['declaringClass']);
        if (!$annotationClass) {
            if (isset($this->imports[$name])) {
                $annotationClass = $this->imports[$name];
            } else {
                $logger->warning("Unknown annotation '$name' at {$annotation['file']}:{$annotation['line']}");
                return null;
            }
        }
        if (!class_exists($annotationClass)) {
            $logger->warning("Annotation class '$annotationClass' does not exist"
                             ." at {$annotation['file']}:{$annotation['line']}");
            return null;
        }
        if (!is_subclass_of($annotationClass, Annotation::class)) {
            $logger->warning("Annotation class '$annotationClass' at {$annotation['file']}:{$annotation['line']}"
                             ." is not subclass of " . Annotation::class);
            return null;
        }
        $context['file'] = $annotation['file'];
        $context['line'] = $annotation['line'];
        $args = (new PhalconAnnotation($annotation))->getArguments() ?: [];
        return new $annotationClass($args, new Context($context));
    }
857197
private function parseAnnotation($line) {
		// Let's get the annotation text
		preg_match("/^[@]([a-zA-Z][a-zA-Z0-9]*)(.*)/", $line, $values);
		
		$annotationClass = isset($values[1])?$values[1]:null;
		$annotationParams = trim(isset($values[2])?$values[2]:null);
		
		$this->annotationsArrayAsString[$annotationClass][] = $annotationParams;		
	}
540047
public static function arrayValue($annotation)
    {
        $annotation = trim($annotation);
        $openingBrace = substr($annotation, 0, 1);

        // json-style data format
        if (in_array($openingBrace, ['{', '['])) {
            return json_decode($annotation, true);
        }

        // doctrine-style data format
        if ($openingBrace === '(') {
            preg_match_all('~(\w+)\s*?=\s*?"(.*?)"\s*?[,)]~', $annotation, $matches, PREG_SET_ORDER);
            $data = [];
            foreach ($matches as $item) {
                $data[$item[1]] = $item[2];
            }
            return $data;
        }
        return null;
    }