Problem/Motivation
Since Twig 3.11, there are 2 new tests: is sequence and is mapping.
UI Patterns 2. is supporting Drupal 10.3.4 and superior, so those tests are available:
- Drupal 9.5.1 > Twig 2.15 : https://git.drupalcode.org/project/drupal/-/blob/9.5.1/core/composer.json
- Drupal 10.3.4 > Twig 3.14 : https://git.drupalcode.org/project/drupal/-/blob/10.3.4/core/composer.json
- Drupal 11.0.3 > Twig 3.14 : https://git.drupalcode.org/project/drupal/-/blob/11.0.3/core/composer.json
- Drupal 11.1.0-dev > Twig 3.14 : https://git.drupalcode.org/project/drupal/-/blob/11.x/core/composer.json
There is no reason to use "is iterable" test in my opinion:
- On a slot, "is iterable" will always return true. A render array is a iterable, a strign is an iterable, a list of renderable is a renderable
- On a prop, we know the JSON data type of the variable: object for mapping, array for sequence
Proposed resolution
Detect is iterable test, raise this warning:
`is iterable` test is too ambiguous. Use `is sequence` or `is mapping`
Issue fork ui_patterns-3484830
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
smovs commentedHi guys!
I added a warning if the "is iterable" test is found.
I found a commented draft version of this test and made it work.
Please review the MR !265
Comment #5
mogtofu33 commentedLooks good, thanks!
Comment #7
pdureau commentedComment #8
mogtofu33 commented