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 84d4fe5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 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,13 @@ public function __construct(
$purifiedConfigFiles[] = $purifiedConfigFile;
}

$cacheDirectory = SimpleParameterProvider::provideStringParameter(Option::CACHE_DIR);

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

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

// clear temporary files, after container is created
$filesystem = new Filesystem();
Expand Down
3 changes: 0 additions & 3 deletions src/DependencyInjection/LazyContainerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,6 @@ public function create(): RectorConfig

$rectorConfig->cacheDirectory(sys_get_temp_dir() . '/rector_cached_files');

// cache directory for PHPStan container
$rectorConfig->containerCacheDirectory(sys_get_temp_dir());

// make use of https://github.com/symplify/easy-parallel
$rectorConfig->singleton(Application::class, static function (): Application {
$application = new Application();
Expand Down

0 comments on commit 84d4fe5

Please sign in to comment.