Adds AssertCountWithZeroToAssertEmptyRector rule#456
Adds AssertCountWithZeroToAssertEmptyRector rule#456TomasVotruba merged 4 commits intorectorphp:mainfrom
Conversation
|
Thanks Peter, this looks good 👍 We could add it to the code quality set, what do you think? |
|
Will do @TomasVotruba ! |
|
Lets ship it 😉 Thank you |
|
@peterfox It seems buggy on combine with - $this->assertCount(0, $this->bar->baz());
+ $this->assertNotInstanceOf(Collection::class, $this->bar->baz());
}
----------- end diff -----------
Applied rules:
* AssertCountWithZeroToAssertEmptyRector
* AssertEmptyNullableObjectToAssertInstanceofRectorthat cause error: I will check if that resolvable |
|
@peterfox I created new PR to skip union type on : |
|
I'm looking into this rule once again, as it actually creates less readable code. We ignore it completely on couple of projects. Also in $this->assertCount(1, ...);
$this->assertCount(5, ...);
$this->assertCount(0, ...);Saying that, I'll deprecate and remove this rule form the set, to promote higher quality code. Thanks for understanding 👍 |
Changes
Why
This is just a small but useful rector rule. It will convert use of
assertCountwith a first parameter of zero to beassertEmpty. Also handles thenotuse as well.