| Conditions | 7 |
| Paths | 8 |
| Total Lines | 22 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 27 | public static function getAllServices(): array |
||
| 28 | { |
||
| 29 | /** @var array<string,string> $services */ |
||
| 30 | $services = []; |
||
| 31 | if (get_parent_class(self::class) && |
||
| 32 | method_exists(get_parent_class(self::class), __FUNCTION__)) { |
||
| 33 | $services = parent::getLazyServices(); |
||
| 34 | } |
||
| 35 | $reflectionClass = new ReflectionClass(self::class); |
||
| 36 | foreach ($reflectionClass->getMethods() as $method) { |
||
| 37 | $reflectionAttributes = $method->getAttributes(AsLazyService::class); |
||
| 38 | if (!isset($reflectionAttributes[0])) { |
||
| 39 | continue; |
||
| 40 | } |
||
| 41 | // Allow to set in AsLazyService is of service |
||
| 42 | $returnType = $method->getReturnType(); |
||
| 43 | if (!$returnType instanceof ReflectionNamedType || $returnType->isBuiltin()) { |
||
| 44 | throw new \Exception(sprintf('%s must return class', $method->getName())); |
||
| 45 | } |
||
| 46 | $services[self::class . '::' . $method->getName()] = $returnType->getName(); |
||
| 47 | } |
||
| 48 | return $services; |
||
| 49 | } |
||
| 51 | } |