added support for "Twig\Markup" instances in the "in" test (again)

This commit is contained in:
Fabien Potencier
2019-06-03 18:20:06 +02:00
parent 51f33f75f9
commit 2218cfe26b
3 changed files with 6 additions and 0 deletions
+1
View File
@@ -1,5 +1,6 @@
* 1.42.1 (2019-XX-XX)
* added support for "Twig\Markup" instances in the "in" test (again)
* allowed string operators as variables names in assignments
* 1.42.0 (2019-05-31)
+3
View File
@@ -943,6 +943,9 @@ function twig_in_filter($value, $compare)
if ($value instanceof Markup) {
$value = (string) $value;
}
if ($compare instanceof Markup) {
$compare = (string) $compare;
}
if (\is_array($compare)) {
return \in_array($value, $compare, \is_object($value) || \is_resource($value));
+2
View File
@@ -56,6 +56,7 @@ Twig supports the in operator
{{ '5.5' in 125.5 ? 'KO' : 'OK' }}
{{ safe in ['foo', 'bar'] ? 'OK' : 'KO' }}
{{ 'fo' in safe ? 'OK' : 'KO' }}
--DATA--
return ['bar' => 'bar', 'foo' => ['bar' => 'bar'], 'dir_object' => new \SplFileInfo(dirname(__FILE__)), 'object' => new \stdClass(), 'resource' => opendir(dirname(__FILE__)), 'safe' => new \Twig\Markup('foo', 'UTF-8')]
--EXPECT--
@@ -114,3 +115,4 @@ OK
OK
OK
OK