Register PropertyExistsWithoutAssertRector in the composer-based set - #761
Merged
Conversation
The rule was only registered in the removed phpunit100 set, so it would have been dropped from every set. It already declares a ">=10.0" package constraint, so the composer-based set is its natural home. Its assertObjectHasAttribute() and assertObjectNotHasAttribute() handling is removed, as both have a direct replacement in assertObjectHasProperty() and assertObjectNotHasProperty(). Those renames are already covered by the ">=10.1" RenameMethodRector configuration in the same set, which would otherwise conflict with this rule.
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.
Follow-up to #760, which was merged before this fix reached the branch.
PropertyExistsWithoutAssertRectorwas registered only inconfig/sets/phpunit100.php. #760 removed that file, so the rule is currently in no set at all — it can only be reached by adding it by hand.The rule already implements
ComposerPackageConstraintInterfacewith a>=10.0constraint, and its own docblock says "inherited from the PHPUnit 10.0 set", socomposer-based.phpis where it belongs.The overlap this surfaced
Registering it exposed a conflict that already existed in the old
phpunit100.php, where both were registered side by side — it was simply never covered by a fixture. The rule and the set's>=10.1RenameMethodRectorboth claimassertObjectHasAttribute():RenameMethodRector,>=10.1$this->assertObjectHasProperty('someProperty', new stdClass())PropertyExistsWithoutAssertRector$this->assertTrue(property_exists(new stdClass(), 'someProperty'))Resolved in favour of the rename, since these two methods are the only ones in the rule's map that have a direct PHPUnit replacement:
So
assertObjectHasAttributeandassertObjectNotHasAttributeare dropped from the rule's map, and its fixture becomes a skip case that asserts they are left alone.What the rule still does
The remaining 7 methods have no direct replacement, so converting them to
property_exists()stays the only upgrade path: