Returns an associative array value of annotation
Either JSON or Doctrine-annotation style allowed
Returns null if not a valid array data

@param $annotation
@return array|mixed|string
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;
    }
36903
protected function createAnnotationObjects(array $annotations)
    {
        $objects     = array();

        //var_dump($annotations);

        foreach ($annotations as $name => $args) {
            $name = ucfirst($name);
            $class = $this->defaultNamespace . $name . 'Annotation';

            if (in_array(strtolower($name), self::getExcludeAnnotationList())) {
                continue;
            }

            if (! array_key_exists($class, $objects)) {
                if (!class_exists($class)) {
                    if ($this->strict) {
                        throw new \Exception(sprintf('Annotation Class Not Found: %s', $class));
                    } else {
                        continue;
                    }
                }

                $objects[$name] = new $class();
            }
            //var_dump($args);
            foreach ($args as $key => $value) {
                $objects[$name]->set($key, $value);
            }
        }

        return $objects;
    }
460701
public static function fetchAnnotationsFromDocblock($annotation, $docblock)
    {
        if (preg_match_all(sprintf(self::$regex, $annotation), $docblock, $matched)) {
            return $matched[1];
        }
        return [];
    }
964521
public function parse() {
		$annotations = [];
		preg_match_all(self::ANNOTATION_PATTERN, $this->rawDocComment, $found);
		foreach ($found[1] as $key => $value) {
			$arg = null;
			if (!empty($found[2][$key])) {
				$arg = substr(trim($found[2][$key]), 1, -1);
			}
			$annotations[] = new Annotation($value, $this->parseValue($found[3][$key]), $arg);
		}
		return $annotations;
	}
189503
protected function filterContractAnnotation(array $annotations): array
    {
        $contractAnnotations = [];

        foreach ($annotations as $annotation) {
            $annotationClass = \get_class($annotation);

            if (\in_array($annotationClass, $this->expectedAnnotationTypes, true)) {
                $contractAnnotations[] = $annotation;
            }
        }

        return $contractAnnotations;
    }
106506
public static function readProperty( $property , $annotation = null ) {

		$ref = $property instanceof ReflectionProperty ? $property : new ReflectionProperty( $property[0] , $property[1] );

		return $annotation ? static::reader()->getPropertyAnnotation( $ref , $annotation ) : static::reader()->getPropertyAnnotations( $ref );

	}
393477
protected function validateByAnnotation($data, $annotation)
    {
        $args = [];
        foreach($annotation->args as $arg)
        {
            $value = $this->getArgValue($data, $arg, $annotation);
            if($value instanceof ValidateValue)
            {
                $value = $this->getArgValue($data, $value->value, $annotation, false);
            }
            $args[] = $value;
        }
        $callable = $annotation->callable;
        if(is_array($callable) && isset($callable[0]) && '$this' === $callable[0])
        {
            $callable[0] = $this;
        }
        $result = call_user_func_array($callable, $args);
        if($annotation->inverseResult)
        {
            return !$result;
        }
        else
        {
            return $result;
        }
    }
952886
public function getAnnotation($name)
    {
        $returnValue = array();
        
        if (isset($this->annotations[$name])) {
            $returnValue = array(
                'name' => $name,
                'value' => $this->annotations[$name]
            );
        } else {
            $returnValue = null;
        }
        
        return (array) $returnValue;
    }
537437
static function getAnnotation($name, $class, $method = NULL, $nullable = TRUE)
	{
		try {
			NULL === $method or $annotation = self::getMethodAnnotation($method, $name, $class);
			isset($annotation) or $annotation = self::getClassAnnotation($class, $name);
		} catch (ReflectionException $e) {
			$annotation = NULL;
		}

		return !$nullable && NULL === $annotation
			? self::annotationClass($name)
			: $annotation;
	}
936873
private function getHeader(ConfigObject $annotations)
    {
        // headers status code depends on the request method type, unless it's forced on the class or method
        $successStatus = $annotations->get('header.status.success', false);
        if (!$successStatus) {
            $successStatus = $this->classDefaults->get('header.status.success', false);

            if (!$successStatus) {
                $method = strtolower($annotations->get('method', $this->classDefaults->get('method', 'get')));
                if ($method == 'post') {
                    $successStatus = 201;
                } else {
                    $successStatus = 200;
                }
            }
        }

        return [
            'cache'  => [
                'expires' => $annotations->get('header.cache.expires',
                    $this->classDefaults->get('header.cache.expires', 0))
            ],
            'status' => [
                'success'      => $successStatus,
                'error'        => $annotations->get('header.status.error',
                    $this->classDefaults->get('header.status.error', 404)),
                'errorMessage' => $annotations->get('header.status.errorMessage',
                    $this->classDefaults->get('header.status.errorMessage', ''))
            ]
        ];
    }
332783
private function getLabels($annotations)
    {
        $it = $this->getAnnotations()->filter($annotations)
            ->is(Label::class)
            ->onProperties();
        $labels = [];
        foreach ($it as $annotation) {
            $labels[$annotation->getPropertyName()] = $annotation->value;
        }
        return $labels;
    }
1061540
public static function getAnnotation($object, $annotationClass)
    {
        return AnnotationManager::getClassAnnotations(BeanFactory::getObjectClass($object), $annotationClass)[0] ?? null;
    }
232204
public static function createFromString($annotation) {
		preg_match('/^\@mixin (.+)\s*(.+)?$/', $annotation, $matches);
		if ($matches) {
			return static::create('@mixin', $matches[1]);
		}

		preg_match('/^(\@property|\@method|\@var|\@param) ([^ ]+) (.+)$/', $annotation, $matches);
		if (!$matches) {
			return null;
		}
		return static::create($matches[1], $matches[2], $matches[3]);
	}
962149
protected function generateAttributeOptionsArray(Annotation $annotation)
    {
        $options = [];

        // length option
        if ($annotation->type == 'string' || $annotation->type == 'char' || $annotation->type == 'binary') {
            $options['length'] = $annotation->length;
        }

        // fixed option
        if ($annotation->type == 'binary' && $annotation->length == 16) {
            $options['fixed'] = $annotation->fixed;
            $options['autoUuid'] = $annotation->autoUuid;
        }

        // unsigned and autoIncrement option
        if ($annotation->type == 'smallInteger' || $annotation->type == 'integer' || $annotation->type == 'bigInteger') {
            $options['unsigned'] = $annotation->unsigned;
            $options['autoIncrement'] = $annotation->autoIncrement;
        }

        // scale and precision option
        if ($annotation->type == 'decimal') {
            $options['scale'] = $annotation->scale;
            $options['precision'] = $annotation->precision;
        }

        return $options;
    }
1095306
protected function getGroups(array $annotations) :? array
    {
        if (empty($annotations)) {
            return [];
        }

        return array_values(array_unique(array_reduce($annotations, function ($carry, $annotation) {
            return array_merge($carry, $annotation->getGroups());
        }, [])));
    }
358828
public static function parseName(string $annotation)
	{
		$name = Strings::trim($annotation);
		$name = Strings::length($name) > 0 ? $name : NULL;

		return $name;
	}
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' => []
            ]
        ];
    }