From e9c329e577b08603d95318901839bd3babc90240 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 14 Dec 2010 07:54:51 +0100 Subject: [PATCH] fixed phpdoc, tweaked doc --- doc/03-Twig-for-Developers.markdown | 2 +- lib/Twig/NodeVisitor/Optimizer.php | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/doc/03-Twig-for-Developers.markdown b/doc/03-Twig-for-Developers.markdown index 377088e..3bc9f4b 100644 --- a/doc/03-Twig-for-Developers.markdown +++ b/doc/03-Twig-for-Developers.markdown @@ -226,7 +226,7 @@ Twig extensions are packages that adds new features to Twig. Using an extension is as simple as using the `addExtension()` method: [php] - $twig->addExtension(new Twig_Extension_Escaper()); + $twig->addExtension(new Twig_Extension_Sandbox()); Twig comes bundled with the following extensions: diff --git a/lib/Twig/NodeVisitor/Optimizer.php b/lib/Twig/NodeVisitor/Optimizer.php index 151ba7b..8dbaa08 100644 --- a/lib/Twig/NodeVisitor/Optimizer.php +++ b/lib/Twig/NodeVisitor/Optimizer.php @@ -70,15 +70,10 @@ class Twig_NodeVisitor_Optimizer implements Twig_NodeVisitorInterface } /** - * Optimizes "for" tag. + * Optimizes "for" tag by removing the "loop" variable creation whenever possible. * - * This method removes the creation of the "loop" variable when: - * - * * "loop" is not used in the "for" tag - * * and there is no include tag without the "only" attribute - * * and there is no inner-for tag (in which case we would need to check loop.parent usage) - * - * This method should be able to optimize for with inner-for tags. + * @param Twig_NodeInterface $node A Node + * @param Twig_Environment $env The current Twig environment */ protected function enterOptimizeFor($node, $env) { @@ -118,6 +113,12 @@ class Twig_NodeVisitor_Optimizer implements Twig_NodeVisitorInterface } } + /** + * Optimizes "for" tag by removing the "loop" variable creation whenever possible. + * + * @param Twig_NodeInterface $node A Node + * @param Twig_Environment $env The current Twig environment + */ protected function leaveOptimizeFor($node, $env) { if ($node instanceof Twig_Node_For) { -- 1.7.2.5