blitz-php /
annotations
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * This file is part of Blitz PHP framework. |
||
| 5 | * |
||
| 6 | * (c) 2022 Dimitri Sitchet Tomkeu <[email protected]> |
||
| 7 | * |
||
| 8 | * For the full copyright and license information, please view |
||
| 9 | * the LICENSE file that was distributed with this source code. |
||
| 10 | */ |
||
| 11 | |||
| 12 | namespace BlitzPHP\Annotations; |
||
| 13 | |||
| 14 | use BlitzPHP\Traits\SingletonTrait; |
||
|
0 ignored issues
–
show
|
|||
| 15 | use mindplay\annotations\AnnotationCache; |
||
| 16 | use mindplay\annotations\AnnotationException; |
||
| 17 | use mindplay\annotations\Annotations; |
||
| 18 | use mindplay\annotations\IAnnotation; |
||
| 19 | use ReflectionClass; |
||
| 20 | use ReflectionMethod; |
||
| 21 | use ReflectionProperty; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Classe permettant de lire les differentes annotations |
||
| 25 | */ |
||
| 26 | class AnnotationReader |
||
| 27 | { |
||
| 28 | use SingletonTrait; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Constructeur |
||
| 32 | */ |
||
| 33 | protected function __construct() |
||
| 34 | { |
||
| 35 | $cacheDir = rtrim(sys_get_temp_dir(), '/\\') . DS . 'blitz-php' . DS . 'annotations'; |
||
|
0 ignored issues
–
show
|
|||
| 36 | if (! is_dir($cacheDir)) { |
||
| 37 | mkdir($cacheDir, 0777, true); |
||
| 38 | } |
||
| 39 | Annotations::$config['cache'] = new AnnotationCache($cacheDir); |
||
| 40 | AnnotationPackager::register(Annotations::getManager()); |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Inspecte les annotations appliquées à une classe donnée |
||
| 45 | * |
||
| 46 | * @param object|ReflectionClass|string $class Un nom de classe, un objet ou une instance de ReflectionClass |
||
| 47 | * @param string $type Un nom de classe/interface d'annotation facultatif - si spécifié, seules les annotations du type donné sont renvoyées. |
||
| 48 | * Alternativement, le préfixe avec "@" invoque la résolution de nom (vous permettant d'interroger par nom d'annotation.) |
||
| 49 | * |
||
| 50 | * @throws AnnotationException si un nom de classe donné n'est pas défini |
||
| 51 | * |
||
| 52 | * @return Annotation[] Instances d'annotation |
||
| 53 | */ |
||
| 54 | public static function fromClass($class, ?string $type = null) |
||
| 55 | { |
||
| 56 | return self::instance()->ofClass($class, $type); |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Inspecte les annotations appliquées à une méthode donnée |
||
| 61 | * |
||
| 62 | * @param object|ReflectionClass|ReflectionMethod|string $class Un nom de classe, un objet, une ReflectionClass ou une instance de ReflectionMethod |
||
| 63 | * @param string|null $method Le nom d'une méthode de la classe donnée (ou null, si le premier paramètre est une ReflectionMethod) |
||
| 64 | * @param string $type Un nom facultatif de classe/d'interface d'annotation - si spécifié, seules les annotations du type donné sont renvoyées. |
||
| 65 | * Alternativement, le préfixe avec "@" invoque la résolution de nom (vous permettant d'interroger par nom d'annotation.) |
||
| 66 | * |
||
| 67 | * @throws AnnotationException pour une méthode ou un nom de classe non défini |
||
| 68 | * |
||
| 69 | * @return IAnnotation[] liste des objets Annotation |
||
| 70 | */ |
||
| 71 | public static function fromMethod($class, ?string $method, ?string $type = null) |
||
| 72 | { |
||
| 73 | return self::instance()->ofMethod($class, $method, $type); |
||
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Inspecte les annotations appliquées à une propriété donnée |
||
| 78 | * |
||
| 79 | * @param object|ReflectionClass|ReflectionProperty|string $class Un nom de classe, un objet, une ReflectionClass ou une instance de ReflectionProperty |
||
| 80 | * @param string|null $property Le nom d'une propriété définie de la classe donnée (ou null, si le premier paramètre est une ReflectionProperty) |
||
| 81 | * @param string $type Un nom de classe/interface d'annotation facultatif - si spécifié, seules les annotations du type donné sont renvoyées. |
||
| 82 | * Alternativement, le préfixe avec "@" invoque la résolution de nom (vous permettant d'interroger par nom d'annotation.) |
||
| 83 | * |
||
| 84 | * @throws AnnotationException pour un nom de classe non défini |
||
| 85 | * |
||
| 86 | * @return IAnnotation[] liste des objets Annotation |
||
| 87 | */ |
||
| 88 | public static function formProperty($class, ?string $property, ?string $type = null) |
||
| 89 | { |
||
| 90 | return self::instance()->ofProperty($class, $property, $type); |
||
| 91 | } |
||
| 92 | |||
| 93 | /** |
||
| 94 | * Inspecte les annotations appliquées à une classe donnée |
||
| 95 | * |
||
| 96 | * @see self::fromClass() |
||
| 97 | * |
||
| 98 | * @param mixed $class |
||
| 99 | * @param mixed|null $type |
||
| 100 | */ |
||
| 101 | private function ofClass($class, $type = null) |
||
| 102 | { |
||
| 103 | return Annotations::ofClass($class, $type); |
||
| 104 | } |
||
| 105 | |||
| 106 | /** |
||
| 107 | * Inspecte les annotations appliquées à une méthode donnée |
||
| 108 | * |
||
| 109 | * @see self::fromMethod() |
||
| 110 | * |
||
| 111 | * @param mixed $class |
||
| 112 | * @param mixed|null $type |
||
| 113 | */ |
||
| 114 | private function ofMethod($class, ?string $method, $type = null) |
||
| 115 | { |
||
| 116 | return Annotations::ofMethod($class, $method, $type); |
||
| 117 | } |
||
| 118 | |||
| 119 | /** |
||
| 120 | * Inspecte les annotations appliquées à une proprieté donnée |
||
| 121 | * |
||
| 122 | * @see self::fromProperty() |
||
| 123 | * |
||
| 124 | * @param mixed $class |
||
| 125 | * @param mixed|null $type |
||
| 126 | */ |
||
| 127 | private function ofProperty($class, ?string $property, $type = null) |
||
| 128 | { |
||
| 129 | return Annotations::ofProperty($class, $property, $type); |
||
| 130 | } |
||
| 131 | } |
||
| 132 |
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