Skip to content

Register PropertyExistsWithoutAssertRector in the composer-based set - #761

Merged
TomasVotruba merged 1 commit into
mainfrom
register-property-exists-rule
Aug 7, 2026
Merged

Register PropertyExistsWithoutAssertRector in the composer-based set#761
TomasVotruba merged 1 commit into
mainfrom
register-property-exists-rule

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Follow-up to #760, which was merged before this fix reached the branch.

PropertyExistsWithoutAssertRector was registered only in config/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 ComposerPackageConstraintInterface with a >=10.0 constraint, and its own docblock says "inherited from the PHPUnit 10.0 set", so composer-based.php is 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.1 RenameMethodRector both claim assertObjectHasAttribute():

produces
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:

-$this->assertObjectHasAttribute('someProperty', new stdClass());
+$this->assertObjectHasProperty('someProperty', new stdClass());

So assertObjectHasAttribute and assertObjectNotHasAttribute are 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:

-$this->assertClassHasAttribute('property', 'stdClass');
+$this->assertTrue(property_exists('stdClass', 'property'));

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.
@TomasVotruba
TomasVotruba merged commit 56d5cb0 into main Aug 7, 2026
7 checks passed
@TomasVotruba
TomasVotruba deleted the register-property-exists-rule branch August 7, 2026 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant