mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-01 21:17:21 +00:00
fixed in test to support Twig_Markup instances
This commit is contained in:
committed by
Fabien Potencier
parent
26ae57d2e9
commit
8f00576edb
@@ -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
|
||||
|
||||
|
||||
@@ -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))) {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user