[TWIG] Update instanceof filter to be able to check for native types

This commit is contained in:
Hugo Sales 2021-12-07 19:52:27 +00:00
parent 26a324ee4b
commit c093eb9089
No known key found for this signature in database
GPG Key ID: 7D0C7EAFC9D835A0

View File

@ -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