Skip to content

Spawn the PHPStan Pro worker instead of forking it - #6926

Merged
ondrejmirtes merged 1 commit into
phpstan:2.3.xfrom
ondrejmirtes:pro-spawn-fixer-worker
Nov 3, 2026
Merged

ondrejmirtes merged 1 commit into
phpstan:2.3.xfrom
ondrejmirtes:pro-spawn-fixer-worker

Conversation

@ondrejmirtes

Copy link
Copy Markdown
Member

FixerApplication runs for as long as PHPStan Pro does. Since #5663 it forks fixer:worker from itself when forking is supported. The forked worker inherits the container and config the process started with. When a config file changes, such as errors added to the baseline or an ignoreErrors entry removed, the file monitor notices and a reanalysis starts, but it still uses the old ignoreErrors and parameters. The errors PHPStan Pro just added to the baseline came back as reported.

This PR always spawns fixer:worker, so it reads the config files again on every analysis. The analysis inside it still forks its own workers through ParallelAnalyser, so the heavy work keeps the fork speedup. The extra cost is one container boot per analysis.

Changes:

  • FixerApplication::analyse() always uses SpawnedProcessPromise.
  • ForkedProcessPromise and the ProcessPromise interface are removed, because nothing else used them. FixerWorkerRunner stays as the worker logic behind FixerWorkerCommand.
  • The parent no longer validates ignoreErrors, because it only ever checked the startup config. fixer:worker already validates the current config.

Verified by running --pro with forking on (pcntl, no JIT):

  • Before: 2 errors added to phpstan-baseline.neon were reported again after the reanalysis.
  • After: they stay ignored. The reanalysis ran in a spawned fixer:worker, which forked its analysis worker.

FixerApplication runs for as long as PHPStan Pro does. A fixer:worker
forked from it inherited the container and the config it started with,
so an edit of a config file, like errors added to the baseline, was
noticed by the file monitor but the reanalysis still used the old
ignoreErrors and parameters.

A spawned fixer:worker reads the config files again on every analysis.
It still forks its own analysis workers where that is supported, see
ParallelAnalyser.

The validation of the ignoreErrors in FixerApplication is gone too: it
checked the config the process started with. fixer:worker validates the
current one.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1a198-fa57-7583-9394-63372a7e2fa8
@ondrejmirtes
ondrejmirtes merged commit f519a2f into phpstan:2.3.x Nov 3, 2026
651 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant