Merge branch '1.x' into 2.x

* 1.x:
  added support for "Twig\Markup" instances in the "in" test (again)
This commit is contained in:
Fabien Potencier
2019-06-03 18:38:09 +02:00
3 changed files with 6 additions and 0 deletions
+1
View File
@@ -246,6 +246,7 @@
* 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
@@ -925,6 +925,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(__DIR__), 'object' => new \stdClass(), 'resource' => opendir(__DIR__), 'safe' => new \Twig\Markup('foo', 'UTF-8')]
--EXPECT--
@@ -114,3 +115,4 @@ OK
OK
OK
OK