Issues (12)

src/Mapping/Annotations.php (3 issues)

Labels
Severity
1
<?php declare(strict_types=1);
2
namespace SpareParts\Enum\Mapping;
3
4
use Doctrine\Common\Annotations\AnnotationReader;
0 ignored issues
show
The type Doctrine\Common\Annotations\AnnotationReader was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
5
use Doctrine\Common\Annotations\Reader;
0 ignored issues
show
The type Doctrine\Common\Annotations\Reader was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
7
class Annotations
8
{
9
    /** @var AnnotationsAnalyzer */
10
    static private $analyzer;
11
12
13
    /**
14
     * @return string[]
15
     * @throws \InvalidArgumentException
16
     */
17 2
    public static function loadEnumValues(string $classname): array
18
    {
19
        try {
20 2
            $reflection = new \ReflectionClass($classname);
21
        } catch (\ReflectionException $exception) {
22
            throw new \InvalidArgumentException("Problem with fetching reflection of class: `" . var_export($classname, true) . "`", 0, $exception);
23
        }
24
25 2
        $analyzer = static::getAnalyzer();
26 2
        $docblock = $reflection->getDocComment() ?: '';
27 2
        return $analyzer->analyzeValuesFromDocblock($docblock);
28
    }
29
30 2
    private static function getAnalyzer(): AnnotationsAnalyzer
31
    {
32 2
        if (!static::$analyzer) {
0 ignored issues
show
Since $analyzer is declared private, accessing it with static will lead to errors in possible sub-classes; you can either use self, or increase the visibility of $analyzer to at least protected.
Loading history...
33 1
            static::$analyzer = new AnnotationsAnalyzer();
34
        }
35 2
        return static::$analyzer;
36
    }
37
38
}