Move method so it's only called when necessary

This commit is contained in:
Tobias Schultze
2014-04-23 21:58:07 +02:00
parent 5b64c3c6d8
commit a28e0f11c8
+2 -2
View File
@@ -402,8 +402,6 @@ abstract class Twig_Template implements Twig_TemplateInterface
throw new Twig_Error_Runtime(sprintf('Impossible to invoke a method ("%s") on a %s variable ("%s")', $item, gettype($object), $object), -1, $this->getTemplateName());
}
$class = get_class($object);
// object property
if (Twig_Template::METHOD_CALL !== $type) {
if (isset($object->$item) || array_key_exists((string) $item, $object)) {
@@ -419,6 +417,8 @@ abstract class Twig_Template implements Twig_TemplateInterface
}
}
$class = get_class($object);
// object method
if (!isset(self::$cache[$class]['methods'])) {
self::$cache[$class]['methods'] = array_change_key_case(array_flip(get_class_methods($object)));