Call operator type specifying extensions for bitwise and arithmetic operators#5226
Open
Firehed wants to merge 1 commit intophpstan:2.1.xfrom
Open
Call operator type specifying extensions for bitwise and arithmetic operators#5226Firehed wants to merge 1 commit intophpstan:2.1.xfrom
Firehed wants to merge 1 commit intophpstan:2.1.xfrom
Conversation
…perators - Add extension calls to getBitwiseAndType, getBitwiseOrType, getBitwiseXorType - Move extension call to top of resolveCommonMath (before integer range optimization) - Remove duplicate extension call later in resolveCommonMath - Add TestBitwiseOperatorTypeSpecifyingExtension for testing bitwise extension calls - Add OperatorTypeSpecifyingExtensionTypeInferenceTest with tests for both bitwise (TestBitwiseOperand) and arithmetic (TestDecimal) operators This ensures operator type specifying extensions are called consistently for all supported operators, allowing custom types to specify operator return types. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
4 tasks
Contributor
Author
|
I believe the two failing tests are unrelated to this change based on other PRs I'm seeing and their associated error messages. |
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.
Summary
This PR ensures
OperatorTypeSpecifyingExtensionimplementations are called consistently for all supported binary operators:getBitwiseAndType,getBitwiseOrType,getBitwiseXorTyperesolveCommonMath(before integer range optimization)resolveCommonMathThis is prerequisite work for phpstan/phpstan#14288 (GMP operator type inference), split out per review feedback on #5223.
Testing approach
Per @ondrejmirtes' feedback:
This PR creates synthetic test extensions independent of any specific type (like GMP):
TestBitwiseOperand- A dummy fixture classTestBitwiseOperatorTypeSpecifyingExtension- ReturnsTestBitwiseOperandfor&,|,^operatorsTestDecimal+TestDecimalOperatorTypeSpecifyingExtensionfor arithmetic operatorsThe test verifies the resolver correctly invokes extensions for both bitwise and arithmetic operators. This ensures the resolver infrastructure remains tested even if specific extensions (like a future GMP extension) are removed.
Test plan
OperatorTypeSpecifyingExtensionTypeInferenceTestwith 8 assertionsGenerated with Claude Code