Skip to content

Commit 2a43cf7

Browse files
committed
Do not restart the main process into PHPStan Turbo
The workers get Turbo on their command line, and they do the analysis. The restart cost every warm run time and gave no cold gain.
1 parent 1b99674 commit 2a43cf7

2 files changed

Lines changed: 2 additions & 5 deletions

File tree

‎bin/rector.php‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use Nette\Utils\Json;
77
use PHPStan\PharAutoloader;
88
use PHPStan\Turbo\TurboExtensionEnabler;
9-
use PHPStan\Turbo\TurboProcessRestarter;
109
use Rector\Bootstrap\AutoloadFileParameterResolver;
1110
use Rector\Bootstrap\RectorConfigsResolver;
1211
use Rector\ChangesReporting\Output\JsonOutputFormatter;
@@ -34,7 +33,7 @@
3433
$autoloadIncluder->includeDependencyOrRepositoryVendorAutoloadIfExists();
3534

3635
// PHPStan Turbo replaces php-parser classes, so it is activated before preload.php declares them.
37-
// The same single restart also turns Xdebug off.
36+
// The main process only gets Turbo when php.ini loads it; the workers get it from WorkerCommandLineFactory.
3837
$phpstanBootstrapFile = __DIR__ . '/../../../phpstan/phpstan/bootstrap.php';
3938
if (! class_exists(PharAutoloader::class) && is_file($phpstanBootstrapFile)) {
4039
// Rector installed as a dependency: the project autoloader that loads PHPStan comes after preload.php,
@@ -45,7 +44,6 @@
4544

4645
if (class_exists(PharAutoloader::class)) {
4746
$phpstanPharPath = dirname((string) new ReflectionClass(PharAutoloader::class)->getFileName()) . '/phpstan.phar';
48-
TurboProcessRestarter::restartIfSuitable($_SERVER['argv'], $phpstanPharPath, 'rector');
4947
TurboExtensionEnabler::trustOwnTypesIfSuitable($_SERVER['argv'], $phpstanPharPath);
5048
TurboExtensionEnabler::activateIfCompatible($phpstanPharPath);
5149
unset($phpstanPharPath);

‎src/Parallel/Command/WorkerCommandLineFactory.php‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@ private function shouldSkipOption(InputInterface $input, string $optionName): bo
142142
}
143143

144144
/**
145-
* Spawned workers do not inherit command-line -d options, so PHPStan Turbo is passed to them explicitly.
146-
* This also covers a main process that did not restart into Turbo, for example without pcntl.
145+
* The workers get PHPStan Turbo on their command line, so the main process needs no restart to enable it.
147146
*
148147
* @return string[]
149148
*/

0 commit comments

Comments
 (0)