Fix flickering of trait errors deduplicated into the trait file#6071
Open
mabar wants to merge 2 commits into
Open
Fix flickering of trait errors deduplicated into the trait file#6071mabar wants to merge 2 commits into
mabar wants to merge 2 commits into
Conversation
Member
|
Do not modify existing test, add a new one instead please. |
Author
|
@ondrejmirtes Changed to be as close to original as possible, but I can't keep it identical because the test asserted the exact behavior this PR changes |
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.
Possible fix for phpstan/phpstan#14932
When a constant-condition error inside a trait is deduplicated and reported "directly in the trait", the reported error invisibly carried the file path of one of the classes using the trait — and which class was picked depended on the run type (cold, warm, partial).
Symptoms:
if.alwaysTruewhen found in traits isn't reported correctly through context of a user class phpstan#14932 (comment));ignoreErrorsentry for such an error matches only on the runs that happen to pick that class;--generate-baselinerecords a different path depending on which run generated it (usually dev vs CI, it depends on amount and timing of workers).With the proposed modifications, the error belongs to the trait file. Ignoring works by targeting the trait file's path, matches identically on every run, and survives adding or removing classes that use the trait.
--generate-baselinewrites the trait path as well.The first commit makes the winner deterministic - fixes the run-to-run flicker on its own, but still attributes the error to the alphabetically last class that uses the trait.
The second makes the attribution independent of the set of using classes. BC break for single-use traits, but necessary for multiple uses. Baseline now matches behavior of the CLI output.