phpstan / phpstan-phpunit

PHPUnit extensions and rules for PHPStan
MIT License
468 stars 46 forks source link

fix assertEquals(false into assertFalse( #194

Closed gemal closed 1 year ago

gemal commented 1 year ago

there is: https://github.com/phpstan/phpstan-phpunit/blob/1.4.x/src/Rules/PHPUnit/AssertSameNullExpectedRule.php

if I made the same for: assertEquals(false, and turn it into assertFalse(

would that be accepted as a pull request?

ondrejmirtes commented 1 year ago

No, because they're not equivalent. assertEquals is for == false, but assertFalse is for === false.

gemal commented 1 year ago

What about: $this->assertEquals(null, $test); to $this->assertNull($test); and $this->assertEquals(true, $test); to $this->assertTrue($test); and $this->assertEquals(10, count($test)); to $this->assertCount(10, $test); would those apply for a pull request?

ondrejmirtes commented 1 year ago

I'd accept disallowing assertEquals completely and promoting assertSame instead, in phpstan-strict-rules. Similar to what https://github.com/phpstan/phpstan-strict-rules/blob/1.5.x/src/Rules/DisallowedConstructs/DisallowedLooseComparisonRule.php does.

ondrejmirtes commented 1 year ago

If you rewrite assertEquals about count to assertSame, the existing rule about changing assertSame to assertCount kicks in.

github-actions[bot] commented 1 year ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.