Document that reusing a non-rewindable iterator after destructuring is unsupported

This commit is contained in:
Fabien Potencier
2026-08-27 13:43:07 +02:00
parent 099fa3471a
commit 59f7d67848
+5
View File
@@ -1220,6 +1220,11 @@ iterator is consumed lazily: only as many values as there are slots in the
pattern are fetched (an empty slot consumes a value too), and the expression
returns the iterator itself.
Do not reuse a non-rewindable iterator (like a generator) after destructuring
it: Twig does not define the iteration state it is left in. A rewindable
iterator can be traversed again afterwards and restarts from the beginning,
according to its own behavior.
Object Destructuring
~~~~~~~~~~~~~~~~~~~~