From: Tobias Schultze Date: Wed, 23 Apr 2014 19:58:07 +0000 (+0200) Subject: Move method so it's only called when necessary X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=a28e0f11c84c9828d945c7278e9898a8249f2000;p=konrad%2Ftwig.git Move method so it's only called when necessary --- diff --git a/lib/Twig/Template.php b/lib/Twig/Template.php index 168a962..45a5349 100644 --- a/lib/Twig/Template.php +++ b/lib/Twig/Template.php @@ -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)));