fixed previous commit

This commit is contained in:
Fabien Potencier
2011-10-29 15:12:58 +02:00
parent b3f472e479
commit cf6116c2a8
2 changed files with 23 additions and 3 deletions
+2 -2
View File
@@ -443,8 +443,8 @@ function twig_in_filter($value, $compare)
if (is_array($compare)) {
return in_array($value, $compare);
} elseif (is_string($compare)) {
if (!$compare) {
return empty($value);
if (!strlen((string) $value)) {
return empty($compare);
}
return false !== strpos($compare, (string) $value);
} elseif (is_object($compare) && $compare instanceof Traversable) {
+21 -1
View File
@@ -12,12 +12,27 @@ TRUE
{% else %}
TRUE
{% endif %}
{% if '' not in foo %}
{% if 'a' in bar %}
TRUE
{% endif %}
{% if 'c' not in bar %}
TRUE
{% endif %}
{% if '' not in bar %}
TRUE
{% endif %}
{% if '' in '' %}
TRUE
{% endif %}
{% if '0' not in '' %}
TRUE
{% endif %}
{% if 'a' not in '0' %}
TRUE
{% endif %}
{% if '0' in '0' %}
TRUE
{% endif %}
--DATA--
return array('bar' => 'bar', 'foo' => array('bar' => 'bar'))
--EXPECT--
@@ -26,3 +41,8 @@ TRUE
TRUE
TRUE
TRUE
TRUE
TRUE
TRUE
TRUE
TRUE