ext-ds Vector/Map not supported by the following filters: slice, first, last (infinite loop) #4294
Replies: 5 comments
-
Is Vector a traversable?
|
Beta Was this translation helpful? Give feedback.
-
Yes Vector and Map are both traversable and they also implement the \IteratorAggregate interface which end up in the following infinite loop
because the getIterator of Vector/Map always return an \IteratorAggregate. |
Beta Was this translation helpful? Give feedback.
-
Well, in userland, you cannot have an infinite loop there, because at some point, you need to reach a place actually implementing the iteration protocol. But for extensions, they might be able to override the iteration protocol without actually implementing Iterator. |
Beta Was this translation helpful? Give feedback.
-
I don't understand why the |
Beta Was this translation helpful? Give feedback.
-
We use ext-ds object in twig files and the slice/first or last filters get stuck when using it on Vector or Map.
Exemple:
{% set result = myVector|last %}
This is due to the following while loop in the twig_slice function (https://github.com/twigphp/Twig/blob/3.x/src/Extension/CoreExtension.php#L651):
And because
$item->getIterator()
return a Vector which implement \IteratorAggregate.I don't know if it can be fixed ?
Thank you in advance for your help
Beta Was this translation helpful? Give feedback.
All reactions