Merge branch '1.x' into 2.x

* 1.x:
  fixed in test to support Twig_Markup instances
This commit is contained in:
Fabien Potencier
2019-04-22 18:32:47 +02:00
3 changed files with 10 additions and 1 deletions
+1
View File
@@ -212,6 +212,7 @@
* 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
@@ -907,6 +907,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(__DIR__), 'object' => new \stdClass(), 'resource' => opendir(__DIR__)]
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--
TRUE
TRUE
@@ -126,3 +128,5 @@ TRUE
FALSE
TRUE
FALSE
TRUE