| Total Complexity | 7 |
| Total Lines | 65 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 15 | ||
| Bugs | 4 | Features | 0 |
| 1 | <?php |
||
| 13 | final class ReflectionMethod extends \ReflectionMethod implements Reader |
||
| 14 | { |
||
| 15 | /** @var ?WeavedInterface */ |
||
| 16 | private $object; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Set dependencies |
||
| 20 | */ |
||
| 21 | public function setObject(WeavedInterface $object): void |
||
| 22 | { |
||
| 23 | $this->object = $object; |
||
| 24 | } |
||
| 25 | |||
| 26 | 3 | /** |
|
| 27 | * @return ReflectionClass<object> |
||
| 28 | 3 | * |
|
| 29 | 3 | * @psalm-external-mutation-free |
|
| 30 | 3 | * @psalm-suppress MethodSignatureMismatch |
|
| 31 | */ |
||
| 32 | public function getDeclaringClass(): ReflectionClass |
||
| 33 | { |
||
| 34 | if (! is_object($this->object)) { |
||
| 35 | 2 | return new ReflectionClass($this->class); |
|
| 36 | } |
||
| 37 | 2 | ||
| 38 | 2 | $parencClass = (new \ReflectionClass($this->object))->getParentClass(); |
|
| 39 | assert($parencClass instanceof \ReflectionClass); |
||
| 40 | $originalClass = $parencClass->name; |
||
| 41 | 2 | ||
| 42 | 2 | return new ReflectionClass($originalClass); |
|
| 43 | 2 | } |
|
| 44 | |||
| 45 | 2 | /** |
|
| 46 | * {@inheritDoc} |
||
| 47 | * |
||
| 48 | * @psalm-suppress NoInterfaceProperties |
||
| 49 | */ |
||
| 50 | public function getAnnotations(): array |
||
| 51 | 2 | { |
|
| 52 | assert(class_exists($this->class)); |
||
| 53 | /** @var list<object> $annotations */ |
||
| 54 | 2 | $annotations = ServiceLocator::getReader()->getMethodAnnotations(new \ReflectionMethod($this->class, $this->name)); |
|
| 55 | 2 | ||
| 56 | 2 | return $annotations; |
|
|
|
|||
| 57 | 1 | } |
|
| 58 | |||
| 59 | /** |
||
| 60 | 1 | * @param class-string<T> $annotationName |
|
| 61 | * |
||
| 62 | * @return T|null |
||
| 63 | * |
||
| 64 | * @template T of object |
||
| 65 | * |
||
| 66 | 2 | * @psalm-suppress MoreSpecificImplementedParamType |
|
| 67 | */ |
||
| 68 | 2 | public function getAnnotation(string $annotationName) |
|
| 78 | } |
||
| 79 | } |
||
| 80 |