fixed in test to support Twig_Markup instances

This commit is contained in:
Fabien Potencier
2015-08-15 22:55:05 +02:00
committed by Fabien Potencier
parent 26ae57d2e9
commit 8f00576edb
3 changed files with 10 additions and 1 deletions
+1
View File
@@ -1,5 +1,6 @@
* 1.39.2 (2019-XX-XX)
* added support for "Twig\Markup" instances in the "in" test
* fixed Lexer when using custom options containing the # char
* fixed "import" when macros are stored in a template string
+4
View File
@@ -935,6 +935,10 @@ function twig_sort_filter($array)
*/
function twig_in_filter($value, $compare)
{
if ($value instanceof Markup) {
$value = (string) $value;
}
if (\is_array($compare)) {
return \in_array($value, $compare, \is_object($value) || \is_resource($value));
} elseif (\is_string($compare) && (\is_string($value) || \is_int($value) || \is_float($value))) {
+5 -1
View File
@@ -73,8 +73,10 @@ TRUE
{{ 5.5 in 125.5 ? 'TRUE' : 'FALSE' }}
{{ 5.5 in '125.5' ? 'TRUE' : 'FALSE' }}
{{ '5.5' in 125.5 ? 'TRUE' : 'FALSE' }}
{{ safe in ['foo', 'bar'] ? 'TRUE' : 'FALSE' }}
--DATA--
return ['bar' => 'bar', 'foo' => ['bar' => 'bar'], 'dir_object' => new \SplFileInfo(dirname(__FILE__)), 'object' => new \stdClass(), 'resource' => opendir(dirname(__FILE__))]
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--
TRUE
TRUE
@@ -126,3 +128,5 @@ TRUE
FALSE
TRUE
FALSE
TRUE