Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CodeQuality] Assert compare on countable #353

Merged

Conversation

peterfox
Copy link
Contributor

@peterfox peterfox commented Aug 3, 2024

Changes

  • Adds the new rule AssertCompareOnCountableWithMethodToAssertCountRector
  • Adds a test
  • Updates the docs

Why

Based on this PHPStan PHPUnit rule it will convert comparison on Countable objects with the count method to use the assertCount method instead.

Works with method and static method calls.

-$this->assertSame(1, $countable->count());
+$this->assertCount(1, $countable);

@peterfox peterfox force-pushed the feature/assert-compare-on-countable branch from 13d80b2 to 8746d9d Compare August 15, 2024 18:46
@TomasVotruba
Copy link
Member

Thank you 😊

@TomasVotruba TomasVotruba merged commit 93a04b0 into rectorphp:main Aug 16, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants