Project

General

Profile

« Previous | Next » 

Revision 1852

Added by darkviper over 11 years ago

updated Twig template engine to stable version 1.11.1 step2

View differences:

Name.php
19 19

  
20 20
    public function __construct($name, $lineno)
21 21
    {
22
        parent::__construct(array(), array('name' => $name, 'is_defined_test' => false, 'ignore_strict_check' => false), $lineno);
22
        parent::__construct(array(), array('name' => $name, 'is_defined_test' => false, 'ignore_strict_check' => false, 'always_defined' => false), $lineno);
23 23
    }
24 24

  
25 25
    public function compile(Twig_Compiler $compiler)
......
34 34
            }
35 35
        } elseif ($this->isSpecial()) {
36 36
            $compiler->raw($this->specialVars[$name]);
37
        } elseif ($this->getAttribute('always_defined')) {
38
            $compiler
39
                ->raw('$context[')
40
                ->string($name)
41
                ->raw(']')
42
            ;
37 43
        } else {
38 44
            // remove the non-PHP 5.4 version when PHP 5.3 support is dropped
39 45
            // as the non-optimized version is just a workaround for slow ternary operator
40 46
            // when the context has a lot of variables
41
            if (version_compare(phpversion(), '5.4.0RC1', '>=') && ($this->getAttribute('ignore_strict_check') || !$compiler->getEnvironment()->isStrictVariables())) {
47
            if (version_compare(phpversion(), '5.4.0RC1', '>=')) {
42 48
                // PHP 5.4 ternary operator performance was optimized
43 49
                $compiler
44 50
                    ->raw('(isset($context[')
45 51
                    ->string($name)
46 52
                    ->raw(']) ? $context[')
47 53
                    ->string($name)
48
                    ->raw('] : null)')
54
                    ->raw('] : ')
49 55
                ;
56

  
57
                if ($this->getAttribute('ignore_strict_check') || !$compiler->getEnvironment()->isStrictVariables()) {
58
                    $compiler->raw('null)');
59
                } else {
60
                    $compiler->raw('$this->getContext($context, ')->string($name)->raw('))');
61
                }
50 62
            } else {
51 63
                $compiler
52 64
                    ->raw('$this->getContext($context, ')

Also available in: Unified diff