The expression $rule->first('GenericArguments') of type null|object<Railt\Parser\Ast\NodeInterface> is not guaranteed to be traversable. How about adding an additional type check?
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
$collection=json_decode($data,true);if(!is_array($collection)){thrownew\RuntimeException('$collection must be an array.');}foreach($collectionas$item){/** ... */}
If you are sure that the expression is traversable, you might want to add a
doc comment cast to improve IDE auto-completion and static analysis:
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.