mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-20 14:36:57 +00:00
improved performance by inlining constants
This commit is contained in:
@@ -1432,10 +1432,10 @@ function twig_array_batch($items, $size, $fill = null)
|
|||||||
*
|
*
|
||||||
* @internal
|
* @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
|
// array
|
||||||
if (Twig_Template::METHOD_CALL !== $type) {
|
if (/* Twig_Template::METHOD_CALL */ 'method' !== $type) {
|
||||||
$arrayItem = is_bool($item) || is_float($item) ? (int) $item : $item;
|
$arrayItem = is_bool($item) || is_float($item) ? (int) $item : $item;
|
||||||
|
|
||||||
if ((is_array($object) && (isset($object[$arrayItem]) || array_key_exists($arrayItem, $object)))
|
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];
|
return $object[$arrayItem];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Twig_Template::ARRAY_CALL === $type || !is_object($object)) {
|
if (/* Twig_Template::ARRAY_CALL */ 'array' === $type || !is_object($object)) {
|
||||||
if ($isDefinedTest) {
|
if ($isDefinedTest) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1467,7 +1467,7 @@ function twig_get_attribute(Twig_Environment $env, Twig_Source $source, $object,
|
|||||||
} else {
|
} else {
|
||||||
$message = sprintf('Key "%s" for array with keys "%s" does not exist.', $arrayItem, implode(', ', array_keys($object)));
|
$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) {
|
if (null === $object) {
|
||||||
$message = sprintf('Impossible to access a key ("%s") on a null variable.', $item);
|
$message = sprintf('Impossible to access a key ("%s") on a null variable.', $item);
|
||||||
} else {
|
} else {
|
||||||
@@ -1508,7 +1508,7 @@ function twig_get_attribute(Twig_Environment $env, Twig_Source $source, $object,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// object property
|
// 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 (isset($object->$item) || array_key_exists((string) $item, $object)) {
|
||||||
if ($isDefinedTest) {
|
if ($isDefinedTest) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user