src/Annotation/Annotations.php
private function getAnnotations($class)
    {
        $parsed = $this->getParser()->parse($class);
        if (!is_array($parsed)) {
            return [];
        }
        $context = [
            'class' => $class,
            'declaringClass' => $class,
            'type' => Context::TYPE_CLASS,
            'name' => $class
        ];
        $annotations = [];
        if (!empty($parsed['class'])) {
            foreach ($parsed['class'] as $value) {
                $anno = $this->create($value, $context);
                if ($anno) {
                    $annotations[] = $anno;
                }
            }
        }
        $map = [
            'methods' => Context::TYPE_METHOD,
            'properties' => Context::TYPE_PROPERTY
        ];
        $reflection = new \ReflectionClass($class);
        foreach ($map as $type_name => $type) {
            if (!empty($parsed[$type_name])) {
                foreach ($parsed[$type_name] as $name => $values) {
                    $reflType = $type == 'method' ? $reflection->getMethod($name)
                               : $reflection->getProperty($name);
                    $context['type'] = $type;
                    $context['name'] = $name;
                    $context['declaringClass'] = $reflType->getDeclaringClass()->getName();
                    foreach ($values as $value) {
                        $anno = $this->create($value, $context);
                        if ($anno) {
                            $annotations[] = $anno;
                        }
                    }
                }
            }
        }
        return $annotations;
    }
private function getAnnotations($class)
    {
        $parsed = $this->getParser()->parse($class);
        if (!is_array($parsed)) {
            return [];
        }
        $context = [
            'class' => $class,
            'declaringClass' => $class,
            'type' => Context::TYPE_CLASS,
            'name' => $class
        ];
        $annotations = [];
        if (!empty($parsed['class'])) {
            foreach ($parsed['class'] as $value) {
                $anno = $this->create($value, $context);
                if ($anno) {
                    $annotations[] = $anno;
                }
            }
        }
        $map = [
            'methods' => Context::TYPE_METHOD,
            'properties' => Context::TYPE_PROPERTY
        ];
        $reflection = new \ReflectionClass($class);
        foreach ($map as $type_name => $type) {
            if (!empty($parsed[$type_name])) {
                foreach ($parsed[$type_name] as $name => $values) {
                    $reflType = $type == 'method' ? $reflection->getMethod($name)
                               : $reflection->getProperty($name);
                    $context['type'] = $type;
                    $context['name'] = $name;
                    $context['declaringClass'] = $reflType->getDeclaringClass()->getName();
                    foreach ($values as $value) {
                        $anno = $this->create($value, $context);
                        if ($anno) {
                            $annotations[] = $anno;
                        }
                    }
                }
            }
        }
        return $annotations;
    }
private function getAnnotations ( $ class ) { $ parsed = $ this -> getParser ( ) -> parse ( $ class ) ; if ( ! is_array ( $ parsed ) ) { return [ ] ; } $ context = [ 'class' => $ class , 'declaringClass' => $ class , 'type' => Context :: TYPE_CLASS , 'name' => $ class ] ; $ annotations = [ ] ; if ( ! empty ( $ parsed [ 'class' ] ) ) { foreach ( $ parsed [ 'class' ] as $ value ) { $ anno = $ this -> create ( $ value , $ context ) ; if ( $ anno ) { $ annotations [ ] = $ anno ; } } } $ map = [ 'methods' => Context :: TYPE_METHOD , 'properties' => Context :: TYPE_PROPERTY ] ; $ reflection = new \ ReflectionClass ( $ class ) ; foreach ( $ map as $ type_name => $ type ) { if ( ! empty ( $ parsed [ $ type_name ] ) ) { foreach ( $ parsed [ $ type_name ] as $ name => $ values ) { $ reflType = $ type == 'method' ? $ reflection -> getMethod ( $ name ) : $ reflection -> getProperty ( $ name ) ; $ context [ 'type' ] = $ type ; $ context [ 'name' ] = $ name ; $ context [ 'declaringClass' ] = $ reflType -> getDeclaringClass ( ) -> getName ( ) ; foreach ( $ values as $ value ) { $ anno = $ this -> create ( $ value , $ context ) ; if ( $ anno ) { $ annotations [ ] = $ anno ; } } } } } return $ annotations ; }
parse all annotations from class
parse all annotations from class