New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ext-ds Vector/Map not supported by the following filters: slice, first, last (infinite loop) #3857
Comments
Up |
Is Vector a traversable?
|
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. |
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. |
I don't understand why the |
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
The text was updated successfully, but these errors were encountered: