if ($thing instanceof \Countable || is_array($thing)) {
return count($thing);
}
+
+ if ($thing instanceof \IteratorAggregate) {
+ return iterator_count($thing);
+ }
return 1;
}
if ($thing instanceof \Countable || is_array($thing)) {
return count($thing);
}
+
+ if ($thing instanceof \IteratorAggregate) {
+ return iterator_count($thing);
+ }
return 1;
}
*
* <pre>
* {# evaluates to true if the foo variable is an array or a traversable object #}
- * {% if foo is traversable %}
+ * {% if foo is iterable %}
* {# ... #}
* {% endif %}
* </pre>