|
18 | 18 | use InvalidArgumentException; |
19 | 19 | use Iterator; |
20 | 20 | use RuntimeException; |
| 21 | +use SplFileInfo; |
21 | 22 | use Symfony\Component\Finder\Finder; |
22 | | -use function Humbug\PhpScoper\iterables_to_iterator; |
| 23 | +use function Humbug\PhpScoper\chain; |
23 | 24 |
|
24 | 25 | final class Configuration |
25 | 26 | { |
@@ -70,7 +71,7 @@ public static function load(string $path = null, array $paths = []): self |
70 | 71 |
|
71 | 72 | $finders = self::retrieveFinders($config); |
72 | 73 | $filesFromPaths = self::retrieveFilesFromPaths($paths); |
73 | | - $filesWithContents = self::retrieveFilesWithContents(iterables_to_iterator($filesFromPaths, ...$finders)); |
| 74 | + $filesWithContents = self::retrieveFilesWithContents(chain($filesFromPaths, ...$finders)); |
74 | 75 |
|
75 | 76 | return new self($path, $filesWithContents, $patchers, $whitelist); |
76 | 77 | } |
@@ -100,7 +101,7 @@ private function __construct( |
100 | 101 | public function withPaths(array $paths): self |
101 | 102 | { |
102 | 103 | $filesWithContents = self::retrieveFilesWithContents( |
103 | | - iterables_to_iterator( |
| 104 | + chain( |
104 | 105 | self::retrieveFilesFromPaths( |
105 | 106 | array_unique($paths) |
106 | 107 | ) |
@@ -310,14 +311,14 @@ private static function retrieveFilesWithContents(Iterator $files): array |
310 | 311 | { |
311 | 312 | return array_reduce( |
312 | 313 | iterator_to_array($files), |
313 | | - function (array $files, $fileInfo): array { |
314 | | - $file = (string) $fileInfo; |
| 314 | + function (array $files, SplFileInfo $fileInfo): array { |
| 315 | + $file = $fileInfo->getRealPath(); |
315 | 316 |
|
316 | | - if (false === file_exists($file)) { |
| 317 | + if (false === $file) { |
317 | 318 | throw new RuntimeException( |
318 | 319 | sprintf( |
319 | 320 | 'Could not find the file "%s".', |
320 | | - $file |
| 321 | + (string) $fileInfo |
321 | 322 | ) |
322 | 323 | ); |
323 | 324 | } |
|
0 commit comments