Skip to content

[CodeQuality] Add AssertClassToThisAssertRector#707

Merged
TomasVotruba merged 2 commits into
mainfrom
assert-class-to-this-assert
Jul 10, 2026
Merged

[CodeQuality] Add AssertClassToThisAssertRector#707
TomasVotruba merged 2 commits into
mainfrom
assert-class-to-this-assert

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Adds AssertClassToThisAssertRector to the code quality set.

Converts static PHPUnit\Framework\Assert::assert*() calls to $this->assert*() inside PHPUnit test classes.

The existing PreferPHPUnitThisCallRector only handles self::/static:: calls; fully-qualified Assert:: calls were not covered.

 use PHPUnit\Framework\Assert;
 use PHPUnit\Framework\TestCase;

 final class SomeTest extends TestCase
 {
     public function test()
     {
-        Assert::assertSame(1, 1);
+        $this->assertSame(1, 1);
     }
 }

Only rewrites when $this is usable — skips non-test classes, static methods, and static closures/arrow functions.

@TomasVotruba TomasVotruba merged commit d864c2a into main Jul 10, 2026
8 checks passed
@TomasVotruba TomasVotruba deleted the assert-class-to-this-assert branch July 10, 2026 09:53
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