From c093eb9089be1b13b0d57120ad24f805e0215d87 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Tue, 7 Dec 2021 19:52:27 +0000 Subject: [PATCH] [TWIG] Update instanceof filter to be able to check for native types --- src/Twig/Runtime.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Twig/Runtime.php b/src/Twig/Runtime.php index 176a5addc9..9b07bf0d79 100644 --- a/src/Twig/Runtime.php +++ b/src/Twig/Runtime.php @@ -129,9 +129,9 @@ class Runtime implements RuntimeExtensionInterface, EventSubscriberInterface && (preg_match(pattern: $re_has_gecko, subject: $this->request->headers->get('User-Agent')) === 1); } - public function isInstanceOf($var, string $instance): bool + public function isInstanceOf($value, string $type): bool { - return $var instanceof $instance; + return (\function_exists($func = 'is_' . $type) && $func($value)) || $value instanceof $type; } public function handleOverrideTemplateImport(string $template, string $default_import): string