Parallel worker killed by a non-exception fatal (e.g. memory_limit) silently drops its chunk and the run still exits 0

Author: gigioneggiandoCreated Sep 19, 2026Updated Sep 20, 2026

Reported privately to @keradus, who asked me to file it here as a bug and tag @Wirone (original author of the parallel runner, #7777).

Summary. In parallel mode (the default), when a worker dies from a non-exception fatal — e.g. hitting memory_limit while tokenising a pathological file — it emits no WORKER_ERROR:: line. The exit callback treats a non-zero exit with zero WORKER_ERROR:: matches as nothing to report (src/Runner/Runner.php, ~497–511), so that worker's entire file chunk is silently skipped and the command still exits 0. In --sequential the same crash takes the process down with a non-zero exit, so the two modes disagree on whether a crash is an error.

Used as a CI lint gate (fix --dry-run), parallel mode therefore reports green for files that were never actually checked (fail-open) — the only security-adjacent angle; otherwise it's a plain reliability bug.

Repro (non-git install, php-cs-fixer available under /project):

  1. Create 14 clean PSR-12 files, plus one file with a huge flat literal array (~8 MB) that exhausts a worker's memory while tokenising.
  2. php -d memory_limit=256M vendor/bin/php-cs-fixer fix ./proj --dry-run --rules=@PSR12 → exit 0, Found 0 of 15 files ... — the pathological file's worker was killed and its chunk dropped silently.
  3. Same input with --sequential: → exit 255, Fatal error: Allowed memory size ... exhausted.

A self-contained container script (Dockerfile + the above) is available — happy to attach it here.

Suggested fix. Treat a worker's non-zero exit with no structured WORKER_ERROR:: as a hard failure of that chunk — surface it and make the overall exit code non-zero — so parallel mode fails closed like sequential mode.

Source: PHP-CS-Fixer/PHP-CS-Fixer