Project

General

Profile

1
<?php
2

    
3
/*
4
 * This file is part of Twig.
5
 *
6
 * (c) 2012 Fabien Potencier
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

    
12
/**
13
 * Twig_NodeVisitor_VariableAnalyzer references all variables used in a template.
14
 *
15
 * @package twig
16
 * @author  Fabien Potencier <fabien@symfony.com>
17
 */
18
class Twig_NodeVisitor_VariableAnalyzer implements Twig_NodeVisitorInterface
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function enterNode(Twig_NodeInterface $node, Twig_Environment $env)
24
    {
25
        if ($node instanceof Twig_Node_Expression_Name) {
26
            print $node->getAttribute('name')."\n";
27
        }
28

    
29
        return $node;
30
    }
31

    
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env)
36
    {
37
        return $node;
38
    }
39

    
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function getPriority()
44
    {
45
        return 0;
46
    }
47
}
(5-5/5)