| Conditions | 7 |
| Paths | 18 |
| Total Lines | 38 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 18 |
| CRAP Score | 7 |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | 17 | protected function getAvailableDeclarations(): iterable |
|
| 16 | { |
||
| 17 | 17 | $files = $this->getFiles(); |
|
| 18 | |||
| 19 | 17 | foreach ($files as $file) { |
|
| 20 | try { |
||
| 21 | 17 | require_once $file; |
|
| 22 | 1 | } catch (\Throwable) { |
|
| 23 | // Ignore syntax errors |
||
| 24 | } |
||
| 25 | } |
||
| 26 | |||
| 27 | 17 | $declarations = [...get_declared_classes(), ...get_declared_interfaces(), ...get_declared_traits()]; |
|
| 28 | |||
| 29 | 17 | $directories = $this->directories; |
|
| 30 | 17 | $isWindows = DIRECTORY_SEPARATOR === '\\'; |
|
| 31 | |||
| 32 | 17 | if ($isWindows) { |
|
| 33 | /** |
||
| 34 | * @psalm-var string[] $directories |
||
| 35 | */ |
||
| 36 | // @codeCoverageIgnoreStart |
||
| 37 | $directories = str_replace('/', '\\', $directories); |
||
| 38 | // @codeCoverageIgnoreEnd |
||
| 39 | } |
||
| 40 | |||
| 41 | 17 | foreach ($declarations as $declaration) { |
|
| 42 | 17 | $reflectionClass = self::$reflectionsCache[$declaration] ??= new \ReflectionClass($declaration); |
|
|
|
|||
| 43 | |||
| 44 | 17 | $matchedDirs = array_filter( |
|
| 45 | 17 | $directories, |
|
| 46 | 17 | static fn($directory) => $reflectionClass->getFileName() && str_starts_with($reflectionClass->getFileName(), $directory) |
|
| 47 | 17 | ); |
|
| 48 | |||
| 49 | 17 | if (count($matchedDirs) === 0) { |
|
| 50 | 17 | continue; |
|
| 51 | } |
||
| 52 | 17 | yield $reflectionClass->getName(); |
|
| 53 | } |
||
| 56 |