mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-30 20:16:45 +00:00
Merge branch '1.x' into 2.x
* 1.x: fixed in test to support Twig_Markup instances
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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))) {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user