From 6a946960fdfc561d67ec8274d1c5959e8acd33e8 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 2 Mar 2018 08:15:18 -0800 Subject: [PATCH] improved performance by inlining constants --- lib/Twig/Extension/Core.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Twig/Extension/Core.php b/lib/Twig/Extension/Core.php index 6472a5b187..c37a9fe3b5 100644 --- a/lib/Twig/Extension/Core.php +++ b/lib/Twig/Extension/Core.php @@ -1432,10 +1432,10 @@ function twig_array_batch($items, $size, $fill = null) * * @internal */ -function twig_get_attribute(Twig_Environment $env, Twig_Source $source, $object, $item, array $arguments = array(), $type = Twig_Template::ANY_CALL, $isDefinedTest = false, $ignoreStrictCheck = false, $sandboxed = false) +function twig_get_attribute(Twig_Environment $env, Twig_Source $source, $object, $item, array $arguments = array(), $type = /* Twig_Template::ANY_CALL */ 'any', $isDefinedTest = false, $ignoreStrictCheck = false, $sandboxed = false) { // array - if (Twig_Template::METHOD_CALL !== $type) { + if (/* Twig_Template::METHOD_CALL */ 'method' !== $type) { $arrayItem = is_bool($item) || is_float($item) ? (int) $item : $item; if ((is_array($object) && (isset($object[$arrayItem]) || array_key_exists($arrayItem, $object))) @@ -1448,7 +1448,7 @@ function twig_get_attribute(Twig_Environment $env, Twig_Source $source, $object, return $object[$arrayItem]; } - if (Twig_Template::ARRAY_CALL === $type || !is_object($object)) { + if (/* Twig_Template::ARRAY_CALL */ 'array' === $type || !is_object($object)) { if ($isDefinedTest) { return false; } @@ -1467,7 +1467,7 @@ function twig_get_attribute(Twig_Environment $env, Twig_Source $source, $object, } else { $message = sprintf('Key "%s" for array with keys "%s" does not exist.', $arrayItem, implode(', ', array_keys($object))); } - } elseif (Twig_Template::ARRAY_CALL === $type) { + } elseif (/* Twig_Template::ARRAY_CALL */ 'array' === $type) { if (null === $object) { $message = sprintf('Impossible to access a key ("%s") on a null variable.', $item); } else { @@ -1508,7 +1508,7 @@ function twig_get_attribute(Twig_Environment $env, Twig_Source $source, $object, } // object property - if (Twig_Template::METHOD_CALL !== $type) { + if (/* Twig_Template::METHOD_CALL */ 'method' !== $type) { if (isset($object->$item) || array_key_exists((string) $item, $object)) { if ($isDefinedTest) { return true;