| 1 | <?php |
||
| 21 | */ |
||
| 22 | class AnnotatedReflectionMethod extends ReflectionMethod implements AnnotationAccess |
||
| 23 | { |
||
| 24 | /** |
||
| 25 | * Annotation reader |
||
| 26 | */ |
||
| 27 | private static ?Reader $annotationReader = null; |
||
|
|
|||
| 28 | |||
| 29 | /** |
||
| 30 | * Gets concrete annotation by name or null if the requested annotation does not exist. |
||
| 31 | */ |
||
| 32 | public function getAnnotation(string $annotationName): ?object |
||
| 33 | { |
||
| 34 | return self::getReader()->getMethodAnnotation($this, $annotationName); |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Gets all annotations applied to the current item. |
||
| 39 | */ |
||
| 40 | public function getAnnotations(): array |
||
| 41 | { |
||
| 42 | return self::getReader()->getMethodAnnotations($this); |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Returns an annotation reader |
||
| 47 | */ |
||
| 48 | private static function getReader(): Reader |
||
| 49 | { |
||
| 50 | if (self::$annotationReader === null) { |
||
| 51 | self::$annotationReader = AspectKernel::getInstance()->getContainer()->get('aspect.annotation.reader'); |
||
| 52 | } |
||
| 53 | |||
| 54 | return self::$annotationReader; |
||
| 55 | } |
||
| 56 | } |
||
| 57 |