[Strict] Deprecate DisallowedEmptyRuleFixerRector - #8290
Merged
Conversation
… to dead-code set
The rule turns empty() into long isset()/comparison chains that are harder to read than the original. Refactoring the value to a single sole type is the better fix.
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.
Deprecates
DisallowedEmptyRuleFixerRector.The rule replaces a single
empty()with a chain ofisset()+ strict comparisons, driven by the inferred union type. The result is noisier than the input:final class SomeClass { private ?string $name; public function run(): bool { - return empty($this->name); + return ! isset($this->name) || $this->name === null || $this->name === ''; } }The real fix is not a longer check, but narrowing the value to a single sole type - then
empty()becomes a plain comparison the developer can write themselves:Removed along with the rule: its test suite, the now unused
ExactCompareFactory,UninitializedPropertyAnalyzerandAbstractFalsyScalarRuleFixerRector, and the rule registration inCodeQualityLevel.