1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Gember\FileReflectorRoave; |
||
6 | |||
7 | use Gember\EventSourcing\Util\File\Reflector\ReflectionFailedException; |
||
8 | use Gember\EventSourcing\Util\File\Reflector\Reflector; |
||
9 | use ReflectionClass; |
||
10 | use Override; |
||
11 | |||
12 | final readonly class RoaveBetterReflectionReflector implements Reflector |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
13 | { |
||
14 | 2 | public function __construct( |
|
15 | private RoaveBetterReflectionFactory $factory, |
||
16 | 2 | ) {} |
|
17 | |||
18 | 2 | #[Override] |
|
19 | public function reflectClassFromFile(string $file): ReflectionClass |
||
20 | { |
||
21 | 2 | $reflector = $this->factory->createRoaveReflectorForFile($file); |
|
22 | |||
23 | 2 | foreach ($reflector->reflectAllClasses() as $reflectClass) { |
|
24 | 1 | return new ReflectionClass($reflectClass->getName()); |
|
25 | } |
||
26 | |||
27 | 1 | throw ReflectionFailedException::classNotFound($file); |
|
28 | } |
||
29 | } |
||
30 |