flow
flow copied to clipboard
Static analysis - avoid unnecessary counts
It would be nice to have static analysis detect following scenario as invalid:
$array = [];
if (\count($array)) {
foreach ($array as $element) {
// some logic
}
}
Since the array is not nullable foreach would do nothing, so count is unnecessary.
#Ref: https://github.com/flow-php/flow/pull/712#discussion_r1380182613