99 */
1010namespace SebastianBergmann \CodeCoverage \StaticAnalysis ;
1111
12- use function assert ;
1312use function crc32 ;
1413use function file_get_contents ;
1514use function file_put_contents ;
1615use function is_file ;
1716use function serialize ;
18- use GlobIterator ;
1917use SebastianBergmann \CodeCoverage \Util \Filesystem ;
20- use SplFileInfo ;
18+ use SebastianBergmann \ FileIterator \ Facade as FileIteratorFacade ;
2119
2220/**
2321 * @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
@@ -38,10 +36,6 @@ public function __construct(string $directory, FileAnalyser $analyser)
3836
3937 $ this ->analyser = $ analyser ;
4038 $ this ->directory = $ directory ;
41-
42- if (self ::$ cacheVersion === null ) {
43- $ this ->calculateCacheVersion ();
44- }
4539 }
4640
4741 public function classesIn (string $ filename ): array
@@ -150,19 +144,23 @@ private function write(string $filename, array $data): void
150144
151145 private function cacheFile (string $ filename ): string
152146 {
153- return $ this ->directory . DIRECTORY_SEPARATOR . hash ('sha256 ' , $ filename . crc32 (file_get_contents ($ filename )) . self ::$ cacheVersion );
147+ return $ this ->directory . DIRECTORY_SEPARATOR . hash ('sha256 ' , $ filename . crc32 (file_get_contents ($ filename )) . self ::cacheVersion () );
154148 }
155149
156- private function calculateCacheVersion (): void
150+ private static function cacheVersion (): string
157151 {
158- $ buffer = '' ;
152+ if (self ::$ cacheVersion !== null ) {
153+ return self ::$ cacheVersion ;
154+ }
159155
160- foreach (new GlobIterator (__DIR__ . '/*.php ' ) as $ file ) {
161- assert ($ file instanceof SplFileInfo);
156+ $ buffer = '' ;
162157
163- $ buffer .= file_get_contents ($ file ->getPathname ());
158+ foreach ((new FileIteratorFacade )->getFilesAsArray (__DIR__ , '.php ' ) as $ file ) {
159+ $ buffer .= file_get_contents ($ file );
164160 }
165161
166162 self ::$ cacheVersion = (string ) crc32 ($ buffer );
163+
164+ return self ::$ cacheVersion ;
167165 }
168166}
0 commit comments