twigphp / Twig

Twig, the flexible, fast, and secure template language for PHP
https://twig.symfony.com/
BSD 3-Clause "New" or "Revised" License
8.18k stars 1.25k forks source link

Add generics for LoopIterator #4356

Closed ruudk closed 1 month ago

ruudk commented 1 month ago

/cc @stof

stof commented 1 month ago

Technically, the LoopIterator accepts non-iterable values, which will then iterate over an EmptyIterator. However, I think this will often not be an expected behavior of the template (it is more likely part of the attempt of not failing when not using strict_variables) so I think it is fine to describe it that way (which would make twigstan report an error when passing a non-iterable value, while understanding the iterator type for meaningful usages)

fabpot commented 1 month ago

Thank you @ruudk.