Repository navigation
[CodeQuality] Add ExplicitNullableObjectInstanceRector, deprecate 4 nullable-object instanceof rules - #8636
Merged
Conversation
…able-object instanceof rules, deprecate them
Member
Author
|
These 4 rules do basically the same operation, nullable object + weak condition around it → |
…tNullableObjectInstanceRector rule test
…ge with fixtures ported from merged rules
Contributor
|
@TomasVotruba I already found this in the public docs, but it isn't released yet? |
Member
Author
|
That's because website deploys regularly with latest version to allow demo testing 👍 |
Contributor
Good to know! |
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.
Merges four rules that all rewrite an implicit nullable-object check into an explicit
instanceof, into a singleExplicitNullableObjectInstanceRector. Each old rule only differed in the input idiom; the output and the underlying factory are the same.Merged (now deprecated, kept as throwing stubs for BC):
ObjectExplicitBoolCompareRector-!$item/$itemFlipTypeControlToUseExclusiveTypeRector-$item === null/!== nullEmptyOnNullableObjectToInstanceOfRector-empty($item)/!empty($item)WhileNullableToInstanceofRector-while ($item !== null)/while ($item)All four produce
$item instanceof X(negated as needed) via the sharedNullableObjectToInstanceofFactory. The new rule subscribes to the union of their node types and dispatches by node, keeping each original detection and type-resolution path intact.BinaryOpNullableToInstanceofRector(&&/||) stays separate as requested.The rule is registered in
CodeQualityLevel; the two old entries there and the two inTypeDeclarationLevelare removed. Twotests/Issuesconfigs that pinned the old rules by class-string are repointed to the new rule.Fixtures cover every idiom (truthiness, null compare, empty, while/do-while) plus a nullable-scalar skip. Full suite green locally.