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:

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`

Command icon 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

pdureau created an issue. See original summary.

smovs made their first commit to this issue’s fork.

smovs’s picture

Status: Active » Needs review

Hi 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

mogtofu33’s picture

Status: Needs review » Reviewed & tested by the community

Looks good, thanks!

  • pdureau committed c6a224bf on 2.0.x authored by smovs
    Issue #3484830 by smovs, pdureau, mogtofu33: Warning if "is iterable"...
pdureau’s picture

Status: Reviewed & tested by the community » Fixed
mogtofu33’s picture

Status: Fixed » Closed (fixed)