Repository navigation
[Php71] Skip array dim fetch in BinaryOpBetweenNumberAndStringRector - #8862
Merged
Merged
Conversation
… element number type is phpdoc-only
Contributor
|
btw, I wonder why rector sees a different native type than phpstan does: |
Member
Author
|
Maybe trust docblock types option? But that would break many fixtures where docblocks are ignored |
Contributor
|
treat phpdoc option does not influence this example: https://phpstan.org/r/c118560b-908a-4684-98b2-e2165000d2d5 I guess there is some "shortcut" or other workaround in rector which prevents that rector sees the same type than phpstan does. but maybe thats something in the process of beeing resolved, since ondrej seem to strip most workarrounds in rector. thank you. |
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.
Fixes rectorphp/rector#9942
BinaryOpBetweenNumberAndStringRectorrewrote$where['adaid'] != ''to$where['adaid'] != 0when$wherecarried a@param array{adaid?: int}phpdoc shape.The number-side gate uses
getNativeType(), but for an array dim fetch on a known string key of a constant-array shape the resolver falls back to the phpdoc type, so a phpdocintleaks in as if it were a runtime guarantee. The element type is never guaranteed at runtime, so the rule should leave such code alone.Bail out when either operand is an
ArrayDimFetch. Added a skip fixture mirroring the reported case.