| Conditions | 7 |
| Paths | 18 |
| Total Lines | 35 |
| Code Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 7 | public static function getReflectionClasses(array $paths): \Generator |
||
| 8 | { |
||
| 9 | foreach ($paths as $path) { |
||
| 10 | $iterator = new \RegexIterator( |
||
| 11 | new \RecursiveIteratorIterator( |
||
| 12 | new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS), |
||
| 13 | \RecursiveIteratorIterator::LEAVES_ONLY |
||
| 14 | ), |
||
| 15 | '/^.+\.php$/i', |
||
| 16 | \RecursiveRegexIterator::GET_MATCH |
||
| 17 | ); |
||
| 18 | |||
| 19 | foreach ($iterator as $file) { |
||
| 20 | $sourceFile = $file[0]; |
||
| 21 | |||
| 22 | if (!preg_match('(^phar:)i', $sourceFile)) { |
||
| 23 | $sourceFile = realpath($sourceFile); |
||
| 24 | } |
||
| 25 | |||
| 26 | try { |
||
| 27 | require_once $sourceFile; |
||
| 28 | } catch (\Throwable $t) { |
||
| 29 | continue; |
||
| 30 | } |
||
| 31 | |||
| 32 | $includedFiles[$sourceFile] = true; |
||
| 33 | } |
||
| 34 | } |
||
| 35 | |||
| 36 | $declared = array_merge(get_declared_classes(), get_declared_interfaces()); |
||
| 37 | foreach ($declared as $className) { |
||
| 38 | $reflectionClass = new \ReflectionClass($className); |
||
| 39 | $sourceFile = $reflectionClass->getFileName(); |
||
| 40 | if (isset($includedFiles[$sourceFile])) { |
||
| 41 | yield $className => $reflectionClass; |
||
| 42 | } |
||
| 46 |