Skip to content

[CodeQuality][PHPUnit80] Return node when arg removed in place, so change is recorded - #810

Merged
TomasVotruba merged 1 commit into
mainfrom
tv-record-change-on-inplace-mutation
Oct 24, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
tv-record-change-on-inplace-mutation

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Two rules remove a method argument in place but then return null on some branches. The AST is mutated, yet the change is not reported through the returned node.

  • AssertCompareOnCountableWithMethodToAssertCountRector: the Countable method-call branch rewrites $node->args and renames the method, then fell through to return null. Now returns $node.
  • AssertEqualsParameterToSpecificMethodsTypeRector: refactor() unsets the max-depth arg (index 4) but could still return null via processAssertEqualsWithDelta(); that helper also unset the default delta arg then returned null. Both now return the mutated node.

Output is unchanged - the mutation was already applied in place and picked up by the printer content diff. The fix makes the rules report the change through the return value, which is the rule contract (refactor() returns the node when it changed it, null otherwise).

Full suite green against rector-src main and against the upcoming FileProcessor print-skip change (rectorphp/rector-src#8791), which relies on rules honoring that contract.

@TomasVotruba
TomasVotruba merged commit a6202f5 into main Oct 24, 2026
8 checks passed
@TomasVotruba
TomasVotruba deleted the tv-record-change-on-inplace-mutation branch October 24, 2026 09:08
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