@@ -49,6 +49,7 @@ class AnnotationReader
4949{
5050 // In this mode, no exceptions will be thrown for incorrect annotations (unless the name of the annotation we are looking for is part of the docblock)
5151 public const LAX_MODE = 'LAX_MODE ' ;
52+
5253 // In this mode, exceptions will be thrown for any incorrect annotations.
5354 public const STRICT_MODE = 'STRICT_MODE ' ;
5455
@@ -86,7 +87,7 @@ public function __construct(private Reader $reader, private string $mode = self:
8687 *
8788 * @template T of object
8889 */
89- private function getClassAnnotation (ReflectionClass $ refClass , string $ annotationClass ): ? object
90+ private function getClassAnnotation (ReflectionClass $ refClass , string $ annotationClass ): object | null
9091 {
9192 try {
9293 $ attribute = $ refClass ->getAttributes ($ annotationClass )[0 ] ?? null ;
@@ -123,7 +124,7 @@ private function getClassAnnotation(ReflectionClass $refClass, string $annotatio
123124 *
124125 * @throws AnnotationException
125126 */
126- private function getMethodAnnotation (ReflectionMethod $ refMethod , string $ annotationClass ): ? object
127+ private function getMethodAnnotation (ReflectionMethod $ refMethod , string $ annotationClass ): object | null
127128 {
128129 $ cacheKey = $ refMethod ->getDeclaringClass ()->getName () . ':: ' . $ refMethod ->getName () . '_ ' . $ annotationClass ;
129130 if (array_key_exists ($ cacheKey , $ this ->methodAnnotationCache )) {
@@ -200,7 +201,7 @@ static function ($attribute) {
200201 },
201202 array_filter ($ refClass ->getAttributes (), static function ($ annotation ) use ($ annotationClass ): bool {
202203 return is_a ($ annotation ->getName (), $ annotationClass , true );
203- })
204+ }),
204205 );
205206
206207 $ toAddAnnotations [] = $ attributes ;
@@ -231,7 +232,7 @@ static function ($attribute) {
231232 *
232233 * @template T of object
233234 */
234- public function getTypeAnnotation (ReflectionClass $ refClass ): ? TypeInterface
235+ public function getTypeAnnotation (ReflectionClass $ refClass ): TypeInterface | null
235236 {
236237 try {
237238 $ type = $ this ->getClassAnnotation ($ refClass , Type::class)
@@ -276,7 +277,7 @@ public function getInputAnnotations(ReflectionClass $refClass): array
276277 *
277278 * @template T of object
278279 */
279- public function getExtendTypeAnnotation (ReflectionClass $ refClass ): ? ExtendType
280+ public function getExtendTypeAnnotation (ReflectionClass $ refClass ): ExtendType | null
280281 {
281282 try {
282283 $ extendType = $ this ->getClassAnnotation ($ refClass , ExtendType::class);
@@ -287,15 +288,13 @@ public function getExtendTypeAnnotation(ReflectionClass $refClass): ?ExtendType
287288 return $ extendType ;
288289 }
289290
290- public function getEnumTypeAnnotation (ReflectionClass $ refClass ): ? EnumType
291+ public function getEnumTypeAnnotation (ReflectionClass $ refClass ): EnumType | null
291292 {
292293 return $ this ->getClassAnnotation ($ refClass , EnumType::class);
293294 }
294295
295- /**
296- * @param class-string<AbstractRequest> $annotationClass
297- */
298- public function getRequestAnnotation (ReflectionMethod $ refMethod , string $ annotationClass ): ?AbstractRequest
296+ /** @param class-string<AbstractRequest> $annotationClass */
297+ public function getRequestAnnotation (ReflectionMethod $ refMethod , string $ annotationClass ): AbstractRequest |null
299298 {
300299 $ queryAnnotation = $ this ->getMethodAnnotation ($ refMethod , $ annotationClass );
301300 assert ($ queryAnnotation instanceof AbstractRequest || $ queryAnnotation === null );
@@ -318,15 +317,15 @@ public function getSourceFields(ReflectionClass $refClass): array
318317 return $ sourceFields ;
319318 }
320319
321- public function getFactoryAnnotation (ReflectionMethod $ refMethod ): ? Factory
320+ public function getFactoryAnnotation (ReflectionMethod $ refMethod ): Factory | null
322321 {
323322 $ factoryAnnotation = $ this ->getMethodAnnotation ($ refMethod , Factory::class);
324323 assert ($ factoryAnnotation instanceof Factory || $ factoryAnnotation === null );
325324
326325 return $ factoryAnnotation ;
327326 }
328327
329- public function getDecorateAnnotation (ReflectionMethod $ refMethod ): ? Decorate
328+ public function getDecorateAnnotation (ReflectionMethod $ refMethod ): Decorate | null
330329 {
331330 $ decorateAnnotation = $ this ->getMethodAnnotation ($ refMethod , Decorate::class);
332331 assert ($ decorateAnnotation instanceof Decorate || $ decorateAnnotation === null );
@@ -376,9 +375,7 @@ public function getParameterAnnotationsPerParameter(array $refParameters): array
376375 /** @var ParameterAnnotationInterface[] $parameterAnnotations */
377376 $ parameterAnnotations = $ this ->getMethodAnnotations ($ method , ParameterAnnotationInterface::class);
378377
379- /**
380- * @var array<string, array<int,ParameterAnnotations>> $parameterAnnotationsPerParameter
381- */
378+ /** @var array<string, array<int,ParameterAnnotations>> $parameterAnnotationsPerParameter */
382379 $ parameterAnnotationsPerParameter = [];
383380 foreach ($ parameterAnnotations as $ parameterAnnotation ) {
384381 $ parameterAnnotationsPerParameter [$ parameterAnnotation ->getTarget ()][] = $ parameterAnnotation ;
@@ -406,25 +403,21 @@ static function ($attribute) {
406403 },
407404 array_filter ($ attributes , static function ($ annotation ): bool {
408405 return is_a ($ annotation ->getName (), ParameterAnnotationInterface::class, true );
409- })
406+ }),
410407 ),
411408 ];
412409 }
413410
414411 return array_map (
415412 static function (array $ parameterAnnotations ): ParameterAnnotations {
416- /**
417- * @var ParameterAnnotationInterface[] $parameterAnnotations
418- */
413+ /** @var ParameterAnnotationInterface[] $parameterAnnotations */
419414 return new ParameterAnnotations ($ parameterAnnotations );
420415 },
421- $ parameterAnnotationsPerParameter
416+ $ parameterAnnotationsPerParameter,
422417 );
423418 }
424419
425- /**
426- * @throws AnnotationException
427- */
420+ /** @throws AnnotationException */
428421 public function getMiddlewareAnnotations (ReflectionMethod |ReflectionProperty $ reflection ): MiddlewareAnnotations
429422 {
430423 if ($ reflection instanceof ReflectionMethod) {
@@ -469,7 +462,7 @@ static function ($attribute) {
469462 },
470463 array_filter ($ attributes , static function ($ annotation ) use ($ annotationClass ): bool {
471464 return is_a ($ annotation ->getName (), $ annotationClass , true );
472- })
465+ }),
473466 ),
474467 ];
475468 } catch (AnnotationException $ e ) {
@@ -525,7 +518,7 @@ static function ($attribute) {
525518 },
526519 array_filter ($ attributes , static function ($ annotation ) use ($ annotationClass ): bool {
527520 return is_a ($ annotation ->getName (), $ annotationClass , true );
528- })
521+ }),
529522 ),
530523 ];
531524 } catch (AnnotationException $ e ) {
0 commit comments