Record top-level PHPStan errors in issue-bot results#5901
Merged
Conversation
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>>).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A crashing parallel worker (e.g. running out of memory) is reported by PHPStan as a top-level error in
$json['errors']withfile_errors === 0— not as a file-level message. The issue-bot'sRunCommandonly read$json['files'], so such a sample was recorded with zero errors, and any expected output (e.g.dumpType/assertTyperesults, 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:
RunCommand::extractErrors().$json['errors']asPlaygroundErrorentries (line -1, no identifier), so a child-process/bootstrap error is visible in the diff instead of masquerading as "no errors".array<hash, list<PlaygroundError>>), soevaluate/the diff keep working.Testing
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.runcommand against adumpTypesample with a forced worker OOM. Before this change the sample was recorded with 0 errors; after, it records theChild process error (exit code 255): PHP Fatal error: Allowed memory size … exhaustedentry, and the serialized results file has the same['phpVersion' => int, 'errors' => array<hash, list<PlaygroundError>>]shape as before.🤖 Generated with Claude Code