1 | <?php |
||||
2 | |||||
3 | namespace Larapie\DataTransferObject\Resolvers; |
||||
4 | |||||
5 | use ReflectionProperty; |
||||
6 | use Doctrine\Common\Annotations\AnnotationReader; |
||||
7 | use Doctrine\Common\Annotations\AnnotationRegistry; |
||||
8 | |||||
9 | class AnnotationResolver |
||||
10 | { |
||||
11 | /** |
||||
12 | * @var ReflectionProperty |
||||
13 | */ |
||||
14 | protected $reflection; |
||||
15 | |||||
16 | /** @var ?Reader */ |
||||
0 ignored issues
–
show
|
|||||
17 | protected static $reader; |
||||
18 | |||||
19 | /** |
||||
20 | * TypeResolver constructor. |
||||
21 | * @param ReflectionProperty $reflection |
||||
22 | */ |
||||
23 | 36 | public function __construct(ReflectionProperty $reflection) |
|||
24 | { |
||||
25 | 36 | $this->reflection = $reflection; |
|||
26 | 36 | } |
|||
27 | |||||
28 | 36 | public function resolve(): array |
|||
29 | { |
||||
30 | 36 | $annotations = []; |
|||
31 | 36 | foreach (self::getReader()->getPropertyAnnotations($this->reflection) as $annotation) { |
|||
32 | 7 | $annotations[get_class($annotation)] = $annotation; |
|||
33 | } |
||||
34 | |||||
35 | 36 | return $annotations; |
|||
36 | } |
||||
37 | |||||
38 | 1 | public static function setReader() |
|||
39 | { |
||||
40 | //IMPLEMENTED LIKE THIS TO SUPPORT DOCTRINE\ANNOTATIONS v1.* & v2.* |
||||
41 | |||||
42 | 1 | if (class_exists(AnnotationRegistry::class)) { |
|||
43 | 1 | AnnotationRegistry::registerUniqueLoader('class_exists'); |
|||
0 ignored issues
–
show
The function
Doctrine\Common\Annotati...:registerUniqueLoader() has been deprecated: this method is deprecated and will be removed in doctrine/annotations 2.0
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This function has been deprecated. The supplier of the function has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead. ![]() |
|||||
44 | 1 | self::$reader = new AnnotationReader(); |
|||
0 ignored issues
–
show
It seems like
new Doctrine\Common\Annotations\AnnotationReader() of type Doctrine\Common\Annotations\AnnotationReader is incompatible with the declared type Larapie\DataTransferObject\Resolvers\Reader|null of property $reader .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||||
45 | } else { |
||||
46 | self::$reader = new \Doctrine\Annotations\AnnotationReader(); |
||||
0 ignored issues
–
show
The type
Doctrine\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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
47 | } |
||||
48 | 1 | } |
|||
49 | |||||
50 | 36 | protected static function getReader() |
|||
51 | { |
||||
52 | 36 | if (self::$reader === null) { |
|||
53 | 1 | self::setReader(); |
|||
54 | } |
||||
55 | |||||
56 | 36 | return self::$reader; |
|||
57 | } |
||||
58 | } |
||||
59 |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths