mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-19 22:07:40 +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)
|
* 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
|
* allowed string operators as variables names in assignments
|
||||||
|
|
||||||
* 1.42.0 (2019-05-31)
|
* 1.42.0 (2019-05-31)
|
||||||
|
|||||||
@@ -943,6 +943,9 @@ function twig_in_filter($value, $compare)
|
|||||||
if ($value instanceof Markup) {
|
if ($value instanceof Markup) {
|
||||||
$value = (string) $value;
|
$value = (string) $value;
|
||||||
}
|
}
|
||||||
|
if ($compare instanceof Markup) {
|
||||||
|
$compare = (string) $compare;
|
||||||
|
}
|
||||||
|
|
||||||
if (\is_array($compare)) {
|
if (\is_array($compare)) {
|
||||||
return \in_array($value, $compare, \is_object($value) || \is_resource($value));
|
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' }}
|
{{ '5.5' in 125.5 ? 'KO' : 'OK' }}
|
||||||
|
|
||||||
{{ safe in ['foo', 'bar'] ? 'OK' : 'KO' }}
|
{{ safe in ['foo', 'bar'] ? 'OK' : 'KO' }}
|
||||||
|
{{ 'fo' in safe ? 'OK' : 'KO' }}
|
||||||
--DATA--
|
--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')]
|
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--
|
--EXPECT--
|
||||||
@@ -114,3 +115,4 @@ OK
|
|||||||
OK
|
OK
|
||||||
|
|
||||||
OK
|
OK
|
||||||
|
OK
|
||||||
|
|||||||
Reference in New Issue
Block a user