Skip to content

Record top-level PHPStan errors in issue-bot results#5901

Merged
ondrejmirtes merged 1 commit into
2.2.xfrom
worktree-issue-bot-toplevel-errors
Jun 20, 2026
Merged

Record top-level PHPStan errors in issue-bot results#5901
ondrejmirtes merged 1 commit into
2.2.xfrom
worktree-issue-bot-toplevel-errors

Conversation

@ondrejmirtes

Copy link
Copy Markdown
Member

A crashing parallel worker (e.g. running out of memory) is reported by PHPStan as a top-level error in $json['errors'] with file_errors === 0 — not as a file-level message. The issue-bot's RunCommand only read $json['files'], so such a sample was recorded with zero errors, and any expected output (e.g. dumpType/assertType results, or real rule errors) silently disappeared from the diff.

This makes the issue-bot misleading: a sample that actually failed to analyse looks like it "lost" its errors, indistinguishable from a genuine type-inference change.

This PR:

  • Extracts the result parsing into RunCommand::extractErrors().
  • Also records the top-level $json['errors'] as PlaygroundError entries (line -1, no identifier), so a child-process/bootstrap error is visible in the diff instead of masquerading as "no errors".
  • The results-file shape is unchanged (array<hash, list<PlaygroundError>>), so evaluate/the diff keep working.

Testing

  • New tests/Console/RunCommandTest.php: file-only (backward compat), top-level-only (the OOM case), mixed, hash-path replacement, and a results-file serialization round-trip.
  • End-to-end: ran the real run command against a dumpType sample with a forced worker OOM. Before this change the sample was recorded with 0 errors; after, it records the Child process error (exit code 255): PHP Fatal error: Allowed memory size … exhausted entry, and the serialized results file has the same ['phpVersion' => int, 'errors' => array<hash, list<PlaygroundError>>] shape as before.

🤖 Generated with Claude Code

A crashing parallel worker (e.g. out of memory) is reported by PHPStan as a
top-level error in $json['errors'] with file_errors === 0, not as a file
message. RunCommand only read $json['files'], so such a sample was recorded
with zero errors and any expected output silently disappeared from the diff.

Extract the result parsing into RunCommand::extractErrors() and also record
the top-level errors as PlaygroundError entries (line -1, no identifier). The
results file shape is unchanged (array<hash, list<PlaygroundError>>).
@ondrejmirtes ondrejmirtes merged commit 2cf0aef into 2.2.x Jun 20, 2026
282 checks passed
@ondrejmirtes ondrejmirtes deleted the worktree-issue-bot-toplevel-errors branch June 20, 2026 11:42
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