Skip to content

Commit

Permalink
make sure PHPStan cache directory is configurable and created
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Aug 17, 2023
1 parent 4637080 commit 8b3c539
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/Config/RectorConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public function cacheDirectory(string $directoryPath): void
}

/**
* @info Rector no longer user compiled container, but Laravel lazy one.
* @info Rector no longer uses compiled container, but Laravel lazy one.
* This option is for PHPStan container in case the sys_get_temp_dir() is not available for the current user.
*/
public function containerCacheDirectory(string $directoryPath): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ public function __construct(
$purifiedConfigFiles[] = $purifiedConfigFile;
}

$cacheDirectory = SimpleParameterProvider::provideStringParameter(Option::CACHE_DIR);
$phpstanCacheDirectory = $cacheDirectory . '/phpstan-container-for-rector';

// make sure directory exists as PHPStan Nette container will not create it and crash
\Nette\Utils\FileSystem::createDir($phpstanCacheDirectory);

$containerFactory = new ContainerFactory(getcwd());
$this->container = $containerFactory->create(
sys_get_temp_dir() . '/phpstan-container-for-rector',
$additionalConfigFiles,
[]
);
$this->container = $containerFactory->create($phpstanCacheDirectory, $additionalConfigFiles, []);

// clear temporary files, after container is created
$filesystem = new Filesystem();
Expand Down

0 comments on commit 8b3c539

Please sign in to comment.