mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-30 12:06:56 +00:00
added support for "Twig\Markup" instances in the "in" test (again)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user