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: #712 (comment)