Repository navigation
Report dead catch in a trait only when it is dead in every using class - #7016
Merged
Merged
Conversation
…ing using classes Amp-Thread-ID: https://ampcode.com/threads/T-01a1c0a4-c0b0-70ce-8c0d-0b905dea24c8
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.
CatchWithUnthrownExceptionRulenow follows the other constant-condition rules for code in traits: outside traits it reports directly, inside a trait it records the outcome throughConstantConditionInTraitHelper, andConstantConditionInTraitRulereports the dead catch only when it is dead in every class using the trait.CatchWithUnthrownExceptionNodeis emitted only for dead catch types, so the rule had no way to record "this catch is live here". This adds aCatchTypeNodevirtual node, emitted for every catch type withisThrown(), which the rule now listens to.CatchWithUnthrownExceptionNodeis still emitted for third-party rules and is deprecated in favour of the new node; its remaining construction inTryCatchHandleris in the baseline. The nativeTryCatchHandlerin turbo-ext emits the new node too.ConstantConditionInTraitHelperalso accepts aName(each catch type is keyed by its own name node, so the types of one multi-catch are tracked separately).Closes phpstan/phpstan#10315