Extract the shared parameter-out type comparison into ParameterOutTypeCheck - #6238
Merged
Merged
Conversation
…eCheck ParameterOutAssignedTypeRule and ParameterOutExecutionEndTypeRule both compare what a by-ref parameter is left holding against the type its callers are promised, and both build the same message from it - the execution-end rule is the assigned-value rule with @param-out known to be present. The comparison, the level-dependent filtering, the function description and the message now live in one place. No behaviour change: the messages, identifiers and the tip are unchanged, and both rule tests keep their expectations - only how the rule is constructed differs. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Split out of #6227 as requested in #6227 (comment). Pure refactoring, no functional change.
ParameterOutAssignedTypeRuleandParameterOutExecutionEndTypeRuleboth compare what a by-ref parameter is left holding against the type its callers are promised, and both build the same message out of it. The execution-end rule is the assigned-value rule with@param-outknown to be present, so its message is what the other one produces when$isParamOutTypeis true - identical string, identicalparamOut.typeidentifier, and no tip either way.The comparison, the level-dependent
findTypeToCheck()filtering, the function description and the message now live inParameterOutTypeCheck. Each rule keeps only what is its own: finding the parameter that the assignment writes to, and walking the parameters at an execution end.Evidence that nothing changed:
tests/isnew ParameterOutTypeCheck(...)wrapping theRuleLevelHelper.build/phpstan.neon) reports no errors, phpcs is clean on the five touched files.Once this is in I will rebase #6227 on top of it, so that PR is left with just the variadic element-type comparison.