From: Fabien Potencier Date: Sat, 6 Aug 2011 08:44:55 +0000 (+0200) Subject: refactored code X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=26d8aff74675ab52f837fc60d2e1cebee8a39fda;p=web%2Fkonrad%2Ftwig.git refactored code --- diff --git a/lib/Twig/Node/Module.php b/lib/Twig/Node/Module.php index be9d834..970a50a 100644 --- a/lib/Twig/Node/Module.php +++ b/lib/Twig/Node/Module.php @@ -102,10 +102,6 @@ class Twig_Node_Module extends Twig_Node ->write("{\n") ->indent() ; - - if (null !== $this->getNode('parent')) { - $compiler->write("protected \$parent;\n\n"); - } } protected function compileConstructor(Twig_Compiler $compiler) diff --git a/lib/Twig/Template.php b/lib/Twig/Template.php index 3c6522a..e7a7770 100644 --- a/lib/Twig/Template.php +++ b/lib/Twig/Template.php @@ -20,6 +20,7 @@ abstract class Twig_Template implements Twig_TemplateInterface { static protected $cache = array(); + protected $parents; protected $env; protected $blocks; @@ -66,13 +67,13 @@ abstract class Twig_Template implements Twig_TemplateInterface return false; } elseif ($parent instanceof Twig_Template) { $name = $parent->getTemplateName(); - $this->parent[$name] = $parent; + $this->parents[$name] = $parent; $parent = $name; - } elseif (!isset($this->parent[$parent])) { - $this->parent[$parent] = $this->env->loadTemplate($parent); + } elseif (!isset($this->parents[$parent])) { + $this->parents[$parent] = $this->env->loadTemplate($parent); } - return $this->parent[$parent]; + return $this->parents[$parent]; } abstract protected function doGetParent(array $context); diff --git a/test/Twig/Tests/Node/ModuleTest.php b/test/Twig/Tests/Node/ModuleTest.php index dcaf27c..8300919 100644 --- a/test/Twig/Tests/Node/ModuleTest.php +++ b/test/Twig/Tests/Node/ModuleTest.php @@ -106,8 +106,6 @@ EOF /* foo.twig */ class __TwigTemplate_be925a7b06dda0dfdbd18a1509f7eb34 extends Twig_Template { - protected \$parent; - protected function doGetParent(array \$context) { return "layout.twig"; @@ -149,8 +147,6 @@ EOF /* foo.twig */ class __TwigTemplate_be925a7b06dda0dfdbd18a1509f7eb34 extends Twig_Template { - protected \$parent; - protected function doGetParent(array \$context) { return ((true) ? ("foo") : ("foo")); diff --git a/test/Twig/Tests/Node/SandboxedModuleTest.php b/test/Twig/Tests/Node/SandboxedModuleTest.php index d859283..b1852a5 100644 --- a/test/Twig/Tests/Node/SandboxedModuleTest.php +++ b/test/Twig/Tests/Node/SandboxedModuleTest.php @@ -117,8 +117,6 @@ EOF /* foo.twig */ class __TwigTemplate_be925a7b06dda0dfdbd18a1509f7eb34 extends Twig_Template { - protected \$parent; - protected function doGetParent(array \$context) { return "layout.twig";