Skip to content

Commit

Permalink
Remove unnecessary IO
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm authored Sep 29, 2023
1 parent e3023e0 commit 65cda8b
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use PHPStan\File\FileReader;
use PHPStan\Internal\ComposerHelper;
use PHPStan\Php\PhpVersion;
use function array_filter;
use function array_key_exists;
use function array_map;
use function array_merge;
Expand Down Expand Up @@ -73,8 +72,6 @@ public function create(string $projectInstallationPath): ?SourceLocator
$this->packagePrefixPath($installedJsonDirectoryPath, $package, $vendorDirectory),
), $installed),
);
$classMapFiles = array_filter($classMapPaths, 'is_file');
$classMapDirectories = array_filter($classMapPaths, 'is_dir');
$filePaths = array_merge(
$this->prefixPaths($this->packageToFilePaths($composer), $projectInstallationPath . '/'),
$dev ? $this->prefixPaths($this->packageToFilePaths($composer, 'autoload-dev'), $projectInstallationPath . '/') : [],
Expand Down Expand Up @@ -111,16 +108,17 @@ public function create(string $projectInstallationPath): ?SourceLocator
)),
);

foreach ($classMapDirectories as $classMapDirectory) {
if (!is_dir($classMapDirectory)) {
$files = [];
foreach ($classMapPaths as $classMapPath) {
if (is_dir($classMapPath)) {
$locators[] = $this->optimizedDirectorySourceLocatorRepository->getOrCreate($classMapPath);
}
if (!is_file($classMapPath)) {
continue;
}
$locators[] = $this->optimizedDirectorySourceLocatorRepository->getOrCreate($classMapDirectory);
$files[] = $classMapPath;
}

$files = [];

foreach (array_merge($classMapFiles, $filePaths) as $file) {
foreach ($filePaths as $file) {
if (!is_file($file)) {
continue;
}
Expand Down

0 comments on commit 65cda8b

Please sign in to comment.