I've had the case in my code base that the following code change was triggered :
/** @var string[] $array */
$array = $someObject->someMethod();
- if (count($array) > 0) {
+ if (is_countable($array) ? count($array) > 0 : 0) {
}
I was quite surprised by this proposition, as IMO a string[] doesn't need to be surrounded by is_countable (if the developer is misusing type hints/doc blocks, PHPStan should warn him).
I digged into it and even noticed there's a test Fixture that seems to affirm this behavior :
packages/Php71/tests/Rector/FuncCall/CountOnNullRector/Fixture/property_with_doc.php.inc
Isn't that weird ?
I've had the case in my code base that the following code change was triggered :
I was quite surprised by this proposition, as IMO a
string[]doesn't need to be surrounded byis_countable(if the developer is misusing type hints/doc blocks, PHPStan should warn him).I digged into it and even noticed there's a test Fixture that seems to affirm this behavior :
packages/Php71/tests/Rector/FuncCall/CountOnNullRector/Fixture/property_with_doc.php.incIsn't that weird ?