From a28e0f11c84c9828d945c7278e9898a8249f2000 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Wed, 23 Apr 2014 21:58:07 +0200 Subject: [PATCH] Move method so it's only called when necessary --- lib/Twig/Template.php | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) 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))); -- 1.7.2.5