diff options
author | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-02 22:43:56 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-02 22:43:56 +0200 |
commit | 8069e235fd2971675ee5fc05026ffa9bce5cbbb7 (patch) | |
tree | 872eaed228b5e1b031c21770fba1701106a52a39 /inc/3rdparty/Twig/Node/Expression | |
parent | 45161a64026cec35fcf07659508143a6f55ddf57 (diff) | |
download | wallabag-8069e235fd2971675ee5fc05026ffa9bce5cbbb7.tar.gz wallabag-8069e235fd2971675ee5fc05026ffa9bce5cbbb7.tar.zst wallabag-8069e235fd2971675ee5fc05026ffa9bce5cbbb7.zip |
move Twig in 3rdparty
Diffstat (limited to 'inc/3rdparty/Twig/Node/Expression')
50 files changed, 1673 insertions, 0 deletions
diff --git a/inc/3rdparty/Twig/Node/Expression/Array.php b/inc/3rdparty/Twig/Node/Expression/Array.php new file mode 100644 index 00000000..1da785fe --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Array.php | |||
@@ -0,0 +1,86 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 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 | class Twig_Node_Expression_Array extends Twig_Node_Expression | ||
12 | { | ||
13 | protected $index; | ||
14 | |||
15 | public function __construct(array $elements, $lineno) | ||
16 | { | ||
17 | parent::__construct($elements, array(), $lineno); | ||
18 | |||
19 | $this->index = -1; | ||
20 | foreach ($this->getKeyValuePairs() as $pair) { | ||
21 | if ($pair['key'] instanceof Twig_Node_Expression_Constant && ctype_digit((string) $pair['key']->getAttribute('value')) && $pair['key']->getAttribute('value') > $this->index) { | ||
22 | $this->index = $pair['key']->getAttribute('value'); | ||
23 | } | ||
24 | } | ||
25 | } | ||
26 | |||
27 | public function getKeyValuePairs() | ||
28 | { | ||
29 | $pairs = array(); | ||
30 | |||
31 | foreach (array_chunk($this->nodes, 2) as $pair) { | ||
32 | $pairs[] = array( | ||
33 | 'key' => $pair[0], | ||
34 | 'value' => $pair[1], | ||
35 | ); | ||
36 | } | ||
37 | |||
38 | return $pairs; | ||
39 | } | ||
40 | |||
41 | public function hasElement(Twig_Node_Expression $key) | ||
42 | { | ||
43 | foreach ($this->getKeyValuePairs() as $pair) { | ||
44 | // we compare the string representation of the keys | ||
45 | // to avoid comparing the line numbers which are not relevant here. | ||
46 | if ((string) $key == (string) $pair['key']) { | ||
47 | return true; | ||
48 | } | ||
49 | } | ||
50 | |||
51 | return false; | ||
52 | } | ||
53 | |||
54 | public function addElement(Twig_Node_Expression $value, Twig_Node_Expression $key = null) | ||
55 | { | ||
56 | if (null === $key) { | ||
57 | $key = new Twig_Node_Expression_Constant(++$this->index, $value->getLine()); | ||
58 | } | ||
59 | |||
60 | array_push($this->nodes, $key, $value); | ||
61 | } | ||
62 | |||
63 | /** | ||
64 | * Compiles the node to PHP. | ||
65 | * | ||
66 | * @param Twig_Compiler A Twig_Compiler instance | ||
67 | */ | ||
68 | public function compile(Twig_Compiler $compiler) | ||
69 | { | ||
70 | $compiler->raw('array('); | ||
71 | $first = true; | ||
72 | foreach ($this->getKeyValuePairs() as $pair) { | ||
73 | if (!$first) { | ||
74 | $compiler->raw(', '); | ||
75 | } | ||
76 | $first = false; | ||
77 | |||
78 | $compiler | ||
79 | ->subcompile($pair['key']) | ||
80 | ->raw(' => ') | ||
81 | ->subcompile($pair['value']) | ||
82 | ; | ||
83 | } | ||
84 | $compiler->raw(')'); | ||
85 | } | ||
86 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/AssignName.php b/inc/3rdparty/Twig/Node/Expression/AssignName.php new file mode 100644 index 00000000..2ddea78c --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/AssignName.php | |||
@@ -0,0 +1,28 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | |||
13 | class Twig_Node_Expression_AssignName extends Twig_Node_Expression_Name | ||
14 | { | ||
15 | /** | ||
16 | * Compiles the node to PHP. | ||
17 | * | ||
18 | * @param Twig_Compiler A Twig_Compiler instance | ||
19 | */ | ||
20 | public function compile(Twig_Compiler $compiler) | ||
21 | { | ||
22 | $compiler | ||
23 | ->raw('$context[') | ||
24 | ->string($this->getAttribute('name')) | ||
25 | ->raw(']') | ||
26 | ; | ||
27 | } | ||
28 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Binary.php b/inc/3rdparty/Twig/Node/Expression/Binary.php new file mode 100644 index 00000000..9dd5de2c --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Binary.php | |||
@@ -0,0 +1,40 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | abstract class Twig_Node_Expression_Binary extends Twig_Node_Expression | ||
13 | { | ||
14 | public function __construct(Twig_NodeInterface $left, Twig_NodeInterface $right, $lineno) | ||
15 | { | ||
16 | parent::__construct(array('left' => $left, 'right' => $right), array(), $lineno); | ||
17 | } | ||
18 | |||
19 | /** | ||
20 | * Compiles the node to PHP. | ||
21 | * | ||
22 | * @param Twig_Compiler A Twig_Compiler instance | ||
23 | */ | ||
24 | public function compile(Twig_Compiler $compiler) | ||
25 | { | ||
26 | $compiler | ||
27 | ->raw('(') | ||
28 | ->subcompile($this->getNode('left')) | ||
29 | ->raw(' ') | ||
30 | ; | ||
31 | $this->operator($compiler); | ||
32 | $compiler | ||
33 | ->raw(' ') | ||
34 | ->subcompile($this->getNode('right')) | ||
35 | ->raw(')') | ||
36 | ; | ||
37 | } | ||
38 | |||
39 | abstract public function operator(Twig_Compiler $compiler); | ||
40 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Binary/Add.php b/inc/3rdparty/Twig/Node/Expression/Binary/Add.php new file mode 100644 index 00000000..0ef8e117 --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Binary/Add.php | |||
@@ -0,0 +1,18 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | class Twig_Node_Expression_Binary_Add extends Twig_Node_Expression_Binary | ||
13 | { | ||
14 | public function operator(Twig_Compiler $compiler) | ||
15 | { | ||
16 | return $compiler->raw('+'); | ||
17 | } | ||
18 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Binary/And.php b/inc/3rdparty/Twig/Node/Expression/Binary/And.php new file mode 100644 index 00000000..d5752ebb --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Binary/And.php | |||
@@ -0,0 +1,18 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | class Twig_Node_Expression_Binary_And extends Twig_Node_Expression_Binary | ||
13 | { | ||
14 | public function operator(Twig_Compiler $compiler) | ||
15 | { | ||
16 | return $compiler->raw('&&'); | ||
17 | } | ||
18 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Binary/BitwiseAnd.php b/inc/3rdparty/Twig/Node/Expression/Binary/BitwiseAnd.php new file mode 100644 index 00000000..9a46d845 --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Binary/BitwiseAnd.php | |||
@@ -0,0 +1,18 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | class Twig_Node_Expression_Binary_BitwiseAnd extends Twig_Node_Expression_Binary | ||
13 | { | ||
14 | public function operator(Twig_Compiler $compiler) | ||
15 | { | ||
16 | return $compiler->raw('&'); | ||
17 | } | ||
18 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Binary/BitwiseOr.php b/inc/3rdparty/Twig/Node/Expression/Binary/BitwiseOr.php new file mode 100644 index 00000000..058a20bf --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Binary/BitwiseOr.php | |||
@@ -0,0 +1,18 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | class Twig_Node_Expression_Binary_BitwiseOr extends Twig_Node_Expression_Binary | ||
13 | { | ||
14 | public function operator(Twig_Compiler $compiler) | ||
15 | { | ||
16 | return $compiler->raw('|'); | ||
17 | } | ||
18 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Binary/BitwiseXor.php b/inc/3rdparty/Twig/Node/Expression/Binary/BitwiseXor.php new file mode 100644 index 00000000..f4da73d4 --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Binary/BitwiseXor.php | |||
@@ -0,0 +1,18 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | class Twig_Node_Expression_Binary_BitwiseXor extends Twig_Node_Expression_Binary | ||
13 | { | ||
14 | public function operator(Twig_Compiler $compiler) | ||
15 | { | ||
16 | return $compiler->raw('^'); | ||
17 | } | ||
18 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Binary/Concat.php b/inc/3rdparty/Twig/Node/Expression/Binary/Concat.php new file mode 100644 index 00000000..f9a64627 --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Binary/Concat.php | |||
@@ -0,0 +1,18 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | class Twig_Node_Expression_Binary_Concat extends Twig_Node_Expression_Binary | ||
13 | { | ||
14 | public function operator(Twig_Compiler $compiler) | ||
15 | { | ||
16 | return $compiler->raw('.'); | ||
17 | } | ||
18 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Binary/Div.php b/inc/3rdparty/Twig/Node/Expression/Binary/Div.php new file mode 100644 index 00000000..e0797a61 --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Binary/Div.php | |||
@@ -0,0 +1,18 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | class Twig_Node_Expression_Binary_Div extends Twig_Node_Expression_Binary | ||
13 | { | ||
14 | public function operator(Twig_Compiler $compiler) | ||
15 | { | ||
16 | return $compiler->raw('/'); | ||
17 | } | ||
18 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Binary/Equal.php b/inc/3rdparty/Twig/Node/Expression/Binary/Equal.php new file mode 100644 index 00000000..7b1236d0 --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Binary/Equal.php | |||
@@ -0,0 +1,17 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2010 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 | class Twig_Node_Expression_Binary_Equal extends Twig_Node_Expression_Binary | ||
12 | { | ||
13 | public function operator(Twig_Compiler $compiler) | ||
14 | { | ||
15 | return $compiler->raw('=='); | ||
16 | } | ||
17 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Binary/FloorDiv.php b/inc/3rdparty/Twig/Node/Expression/Binary/FloorDiv.php new file mode 100644 index 00000000..7fbd0556 --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Binary/FloorDiv.php | |||
@@ -0,0 +1,29 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 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 | class Twig_Node_Expression_Binary_FloorDiv extends Twig_Node_Expression_Binary | ||
12 | { | ||
13 | /** | ||
14 | * Compiles the node to PHP. | ||
15 | * | ||
16 | * @param Twig_Compiler A Twig_Compiler instance | ||
17 | */ | ||
18 | public function compile(Twig_Compiler $compiler) | ||
19 | { | ||
20 | $compiler->raw('intval(floor('); | ||
21 | parent::compile($compiler); | ||
22 | $compiler->raw('))'); | ||
23 | } | ||
24 | |||
25 | public function operator(Twig_Compiler $compiler) | ||
26 | { | ||
27 | return $compiler->raw('/'); | ||
28 | } | ||
29 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Binary/Greater.php b/inc/3rdparty/Twig/Node/Expression/Binary/Greater.php new file mode 100644 index 00000000..a110bd92 --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Binary/Greater.php | |||
@@ -0,0 +1,17 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2010 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 | class Twig_Node_Expression_Binary_Greater extends Twig_Node_Expression_Binary | ||
12 | { | ||
13 | public function operator(Twig_Compiler $compiler) | ||
14 | { | ||
15 | return $compiler->raw('>'); | ||
16 | } | ||
17 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Binary/GreaterEqual.php b/inc/3rdparty/Twig/Node/Expression/Binary/GreaterEqual.php new file mode 100644 index 00000000..3754fed2 --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Binary/GreaterEqual.php | |||
@@ -0,0 +1,17 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2010 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 | class Twig_Node_Expression_Binary_GreaterEqual extends Twig_Node_Expression_Binary | ||
12 | { | ||
13 | public function operator(Twig_Compiler $compiler) | ||
14 | { | ||
15 | return $compiler->raw('>='); | ||
16 | } | ||
17 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Binary/In.php b/inc/3rdparty/Twig/Node/Expression/Binary/In.php new file mode 100644 index 00000000..788f9377 --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Binary/In.php | |||
@@ -0,0 +1,33 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2010 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 | class Twig_Node_Expression_Binary_In extends Twig_Node_Expression_Binary | ||
12 | { | ||
13 | /** | ||
14 | * Compiles the node to PHP. | ||
15 | * | ||
16 | * @param Twig_Compiler A Twig_Compiler instance | ||
17 | */ | ||
18 | public function compile(Twig_Compiler $compiler) | ||
19 | { | ||
20 | $compiler | ||
21 | ->raw('twig_in_filter(') | ||
22 | ->subcompile($this->getNode('left')) | ||
23 | ->raw(', ') | ||
24 | ->subcompile($this->getNode('right')) | ||
25 | ->raw(')') | ||
26 | ; | ||
27 | } | ||
28 | |||
29 | public function operator(Twig_Compiler $compiler) | ||
30 | { | ||
31 | return $compiler->raw('in'); | ||
32 | } | ||
33 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Binary/Less.php b/inc/3rdparty/Twig/Node/Expression/Binary/Less.php new file mode 100644 index 00000000..45fd3004 --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Binary/Less.php | |||
@@ -0,0 +1,17 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2010 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 | class Twig_Node_Expression_Binary_Less extends Twig_Node_Expression_Binary | ||
12 | { | ||
13 | public function operator(Twig_Compiler $compiler) | ||
14 | { | ||
15 | return $compiler->raw('<'); | ||
16 | } | ||
17 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Binary/LessEqual.php b/inc/3rdparty/Twig/Node/Expression/Binary/LessEqual.php new file mode 100644 index 00000000..e38e257c --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Binary/LessEqual.php | |||
@@ -0,0 +1,17 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2010 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 | class Twig_Node_Expression_Binary_LessEqual extends Twig_Node_Expression_Binary | ||
12 | { | ||
13 | public function operator(Twig_Compiler $compiler) | ||
14 | { | ||
15 | return $compiler->raw('<='); | ||
16 | } | ||
17 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Binary/Mod.php b/inc/3rdparty/Twig/Node/Expression/Binary/Mod.php new file mode 100644 index 00000000..9924114f --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Binary/Mod.php | |||
@@ -0,0 +1,18 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | class Twig_Node_Expression_Binary_Mod extends Twig_Node_Expression_Binary | ||
13 | { | ||
14 | public function operator(Twig_Compiler $compiler) | ||
15 | { | ||
16 | return $compiler->raw('%'); | ||
17 | } | ||
18 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Binary/Mul.php b/inc/3rdparty/Twig/Node/Expression/Binary/Mul.php new file mode 100644 index 00000000..c91529ca --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Binary/Mul.php | |||
@@ -0,0 +1,18 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | class Twig_Node_Expression_Binary_Mul extends Twig_Node_Expression_Binary | ||
13 | { | ||
14 | public function operator(Twig_Compiler $compiler) | ||
15 | { | ||
16 | return $compiler->raw('*'); | ||
17 | } | ||
18 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Binary/NotEqual.php b/inc/3rdparty/Twig/Node/Expression/Binary/NotEqual.php new file mode 100644 index 00000000..26867ba2 --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Binary/NotEqual.php | |||
@@ -0,0 +1,17 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2010 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 | class Twig_Node_Expression_Binary_NotEqual extends Twig_Node_Expression_Binary | ||
12 | { | ||
13 | public function operator(Twig_Compiler $compiler) | ||
14 | { | ||
15 | return $compiler->raw('!='); | ||
16 | } | ||
17 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Binary/NotIn.php b/inc/3rdparty/Twig/Node/Expression/Binary/NotIn.php new file mode 100644 index 00000000..f347b7b6 --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Binary/NotIn.php | |||
@@ -0,0 +1,33 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2010 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 | class Twig_Node_Expression_Binary_NotIn extends Twig_Node_Expression_Binary | ||
12 | { | ||
13 | /** | ||
14 | * Compiles the node to PHP. | ||
15 | * | ||
16 | * @param Twig_Compiler A Twig_Compiler instance | ||
17 | */ | ||
18 | public function compile(Twig_Compiler $compiler) | ||
19 | { | ||
20 | $compiler | ||
21 | ->raw('!twig_in_filter(') | ||
22 | ->subcompile($this->getNode('left')) | ||
23 | ->raw(', ') | ||
24 | ->subcompile($this->getNode('right')) | ||
25 | ->raw(')') | ||
26 | ; | ||
27 | } | ||
28 | |||
29 | public function operator(Twig_Compiler $compiler) | ||
30 | { | ||
31 | return $compiler->raw('not in'); | ||
32 | } | ||
33 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Binary/Or.php b/inc/3rdparty/Twig/Node/Expression/Binary/Or.php new file mode 100644 index 00000000..adba49c6 --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Binary/Or.php | |||
@@ -0,0 +1,18 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | class Twig_Node_Expression_Binary_Or extends Twig_Node_Expression_Binary | ||
13 | { | ||
14 | public function operator(Twig_Compiler $compiler) | ||
15 | { | ||
16 | return $compiler->raw('||'); | ||
17 | } | ||
18 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Binary/Power.php b/inc/3rdparty/Twig/Node/Expression/Binary/Power.php new file mode 100644 index 00000000..b2c59040 --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Binary/Power.php | |||
@@ -0,0 +1,33 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2010 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 | class Twig_Node_Expression_Binary_Power extends Twig_Node_Expression_Binary | ||
12 | { | ||
13 | /** | ||
14 | * Compiles the node to PHP. | ||
15 | * | ||
16 | * @param Twig_Compiler A Twig_Compiler instance | ||
17 | */ | ||
18 | public function compile(Twig_Compiler $compiler) | ||
19 | { | ||
20 | $compiler | ||
21 | ->raw('pow(') | ||
22 | ->subcompile($this->getNode('left')) | ||
23 | ->raw(', ') | ||
24 | ->subcompile($this->getNode('right')) | ||
25 | ->raw(')') | ||
26 | ; | ||
27 | } | ||
28 | |||
29 | public function operator(Twig_Compiler $compiler) | ||
30 | { | ||
31 | return $compiler->raw('**'); | ||
32 | } | ||
33 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Binary/Range.php b/inc/3rdparty/Twig/Node/Expression/Binary/Range.php new file mode 100644 index 00000000..bea4f2a6 --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Binary/Range.php | |||
@@ -0,0 +1,33 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2010 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 | class Twig_Node_Expression_Binary_Range extends Twig_Node_Expression_Binary | ||
12 | { | ||
13 | /** | ||
14 | * Compiles the node to PHP. | ||
15 | * | ||
16 | * @param Twig_Compiler A Twig_Compiler instance | ||
17 | */ | ||
18 | public function compile(Twig_Compiler $compiler) | ||
19 | { | ||
20 | $compiler | ||
21 | ->raw('range(') | ||
22 | ->subcompile($this->getNode('left')) | ||
23 | ->raw(', ') | ||
24 | ->subcompile($this->getNode('right')) | ||
25 | ->raw(')') | ||
26 | ; | ||
27 | } | ||
28 | |||
29 | public function operator(Twig_Compiler $compiler) | ||
30 | { | ||
31 | return $compiler->raw('..'); | ||
32 | } | ||
33 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Binary/Sub.php b/inc/3rdparty/Twig/Node/Expression/Binary/Sub.php new file mode 100644 index 00000000..d4463991 --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Binary/Sub.php | |||
@@ -0,0 +1,18 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | class Twig_Node_Expression_Binary_Sub extends Twig_Node_Expression_Binary | ||
13 | { | ||
14 | public function operator(Twig_Compiler $compiler) | ||
15 | { | ||
16 | return $compiler->raw('-'); | ||
17 | } | ||
18 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/BlockReference.php b/inc/3rdparty/Twig/Node/Expression/BlockReference.php new file mode 100644 index 00000000..647196eb --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/BlockReference.php | |||
@@ -0,0 +1,51 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | |||
13 | /** | ||
14 | * Represents a block call node. | ||
15 | * | ||
16 | * @author Fabien Potencier <fabien@symfony.com> | ||
17 | */ | ||
18 | class Twig_Node_Expression_BlockReference extends Twig_Node_Expression | ||
19 | { | ||
20 | public function __construct(Twig_NodeInterface $name, $asString = false, $lineno, $tag = null) | ||
21 | { | ||
22 | parent::__construct(array('name' => $name), array('as_string' => $asString, 'output' => false), $lineno, $tag); | ||
23 | } | ||
24 | |||
25 | /** | ||
26 | * Compiles the node to PHP. | ||
27 | * | ||
28 | * @param Twig_Compiler A Twig_Compiler instance | ||
29 | */ | ||
30 | public function compile(Twig_Compiler $compiler) | ||
31 | { | ||
32 | if ($this->getAttribute('as_string')) { | ||
33 | $compiler->raw('(string) '); | ||
34 | } | ||
35 | |||
36 | if ($this->getAttribute('output')) { | ||
37 | $compiler | ||
38 | ->addDebugInfo($this) | ||
39 | ->write("\$this->displayBlock(") | ||
40 | ->subcompile($this->getNode('name')) | ||
41 | ->raw(", \$context, \$blocks);\n") | ||
42 | ; | ||
43 | } else { | ||
44 | $compiler | ||
45 | ->raw("\$this->renderBlock(") | ||
46 | ->subcompile($this->getNode('name')) | ||
47 | ->raw(", \$context, \$blocks)") | ||
48 | ; | ||
49 | } | ||
50 | } | ||
51 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Call.php b/inc/3rdparty/Twig/Node/Expression/Call.php new file mode 100644 index 00000000..87b62deb --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Call.php | |||
@@ -0,0 +1,178 @@ | |||
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 | abstract class Twig_Node_Expression_Call extends Twig_Node_Expression | ||
12 | { | ||
13 | protected function compileCallable(Twig_Compiler $compiler) | ||
14 | { | ||
15 | $callable = $this->getAttribute('callable'); | ||
16 | |||
17 | $closingParenthesis = false; | ||
18 | if ($callable) { | ||
19 | if (is_string($callable)) { | ||
20 | $compiler->raw($callable); | ||
21 | } elseif (is_array($callable) && $callable[0] instanceof Twig_ExtensionInterface) { | ||
22 | $compiler->raw(sprintf('$this->env->getExtension(\'%s\')->%s', $callable[0]->getName(), $callable[1])); | ||
23 | } else { | ||
24 | $type = ucfirst($this->getAttribute('type')); | ||
25 | $compiler->raw(sprintf('call_user_func_array($this->env->get%s(\'%s\')->getCallable(), array', $type, $this->getAttribute('name'))); | ||
26 | $closingParenthesis = true; | ||
27 | } | ||
28 | } else { | ||
29 | $compiler->raw($this->getAttribute('thing')->compile()); | ||
30 | } | ||
31 | |||
32 | $this->compileArguments($compiler); | ||
33 | |||
34 | if ($closingParenthesis) { | ||
35 | $compiler->raw(')'); | ||
36 | } | ||
37 | } | ||
38 | |||
39 | protected function compileArguments(Twig_Compiler $compiler) | ||
40 | { | ||
41 | $compiler->raw('('); | ||
42 | |||
43 | $first = true; | ||
44 | |||
45 | if ($this->hasAttribute('needs_environment') && $this->getAttribute('needs_environment')) { | ||
46 | $compiler->raw('$this->env'); | ||
47 | $first = false; | ||
48 | } | ||
49 | |||
50 | if ($this->hasAttribute('needs_context') && $this->getAttribute('needs_context')) { | ||
51 | if (!$first) { | ||
52 | $compiler->raw(', '); | ||
53 | } | ||
54 | $compiler->raw('$context'); | ||
55 | $first = false; | ||
56 | } | ||
57 | |||
58 | if ($this->hasAttribute('arguments')) { | ||
59 | foreach ($this->getAttribute('arguments') as $argument) { | ||
60 | if (!$first) { | ||
61 | $compiler->raw(', '); | ||
62 | } | ||
63 | $compiler->string($argument); | ||
64 | $first = false; | ||
65 | } | ||
66 | } | ||
67 | |||
68 | if ($this->hasNode('node')) { | ||
69 | if (!$first) { | ||
70 | $compiler->raw(', '); | ||
71 | } | ||
72 | $compiler->subcompile($this->getNode('node')); | ||
73 | $first = false; | ||
74 | } | ||
75 | |||
76 | if ($this->hasNode('arguments') && null !== $this->getNode('arguments')) { | ||
77 | $callable = $this->hasAttribute('callable') ? $this->getAttribute('callable') : null; | ||
78 | |||
79 | $arguments = $this->getArguments($callable, $this->getNode('arguments')); | ||
80 | |||
81 | foreach ($arguments as $node) { | ||
82 | if (!$first) { | ||
83 | $compiler->raw(', '); | ||
84 | } | ||
85 | $compiler->subcompile($node); | ||
86 | $first = false; | ||
87 | } | ||
88 | } | ||
89 | |||
90 | $compiler->raw(')'); | ||
91 | } | ||
92 | |||
93 | protected function getArguments($callable, $arguments) | ||
94 | { | ||
95 | $parameters = array(); | ||
96 | $named = false; | ||
97 | foreach ($arguments as $name => $node) { | ||
98 | if (!is_int($name)) { | ||
99 | $named = true; | ||
100 | $name = $this->normalizeName($name); | ||
101 | } elseif ($named) { | ||
102 | throw new Twig_Error_Syntax(sprintf('Positional arguments cannot be used after named arguments for %s "%s".', $this->getAttribute('type'), $this->getAttribute('name'))); | ||
103 | } | ||
104 | |||
105 | $parameters[$name] = $node; | ||
106 | } | ||
107 | |||
108 | if (!$named) { | ||
109 | return $parameters; | ||
110 | } | ||
111 | |||
112 | if (!$callable) { | ||
113 | throw new LogicException(sprintf('Named arguments are not supported for %s "%s".', $this->getAttribute('type'), $this->getAttribute('name'))); | ||
114 | } | ||
115 | |||
116 | // manage named arguments | ||
117 | if (is_array($callable)) { | ||
118 | $r = new ReflectionMethod($callable[0], $callable[1]); | ||
119 | } elseif (is_object($callable) && !$callable instanceof Closure) { | ||
120 | $r = new ReflectionObject($callable); | ||
121 | $r = $r->getMethod('__invoke'); | ||
122 | } else { | ||
123 | $r = new ReflectionFunction($callable); | ||
124 | } | ||
125 | |||
126 | $definition = $r->getParameters(); | ||
127 | if ($this->hasNode('node')) { | ||
128 | array_shift($definition); | ||
129 | } | ||
130 | if ($this->hasAttribute('needs_environment') && $this->getAttribute('needs_environment')) { | ||
131 | array_shift($definition); | ||
132 | } | ||
133 | if ($this->hasAttribute('needs_context') && $this->getAttribute('needs_context')) { | ||
134 | array_shift($definition); | ||
135 | } | ||
136 | if ($this->hasAttribute('arguments') && null !== $this->getAttribute('arguments')) { | ||
137 | foreach ($this->getAttribute('arguments') as $argument) { | ||
138 | array_shift($definition); | ||
139 | } | ||
140 | } | ||
141 | |||
142 | $arguments = array(); | ||
143 | $pos = 0; | ||
144 | foreach ($definition as $param) { | ||
145 | $name = $this->normalizeName($param->name); | ||
146 | |||
147 | if (array_key_exists($name, $parameters)) { | ||
148 | if (array_key_exists($pos, $parameters)) { | ||
149 | throw new Twig_Error_Syntax(sprintf('Arguments "%s" is defined twice for %s "%s".', $name, $this->getAttribute('type'), $this->getAttribute('name'))); | ||
150 | } | ||
151 | |||
152 | $arguments[] = $parameters[$name]; | ||
153 | unset($parameters[$name]); | ||
154 | } elseif (array_key_exists($pos, $parameters)) { | ||
155 | $arguments[] = $parameters[$pos]; | ||
156 | unset($parameters[$pos]); | ||
157 | ++$pos; | ||
158 | } elseif ($param->isDefaultValueAvailable()) { | ||
159 | $arguments[] = new Twig_Node_Expression_Constant($param->getDefaultValue(), -1); | ||
160 | } elseif ($param->isOptional()) { | ||
161 | break; | ||
162 | } else { | ||
163 | throw new Twig_Error_Syntax(sprintf('Value for argument "%s" is required for %s "%s".', $name, $this->getAttribute('type'), $this->getAttribute('name'))); | ||
164 | } | ||
165 | } | ||
166 | |||
167 | foreach (array_keys($parameters) as $name) { | ||
168 | throw new Twig_Error_Syntax(sprintf('Unknown argument "%s" for %s "%s".', $name, $this->getAttribute('type'), $this->getAttribute('name'))); | ||
169 | } | ||
170 | |||
171 | return $arguments; | ||
172 | } | ||
173 | |||
174 | protected function normalizeName($name) | ||
175 | { | ||
176 | return strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'), array('\\1_\\2', '\\1_\\2'), $name)); | ||
177 | } | ||
178 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Conditional.php b/inc/3rdparty/Twig/Node/Expression/Conditional.php new file mode 100644 index 00000000..edcb1e2d --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Conditional.php | |||
@@ -0,0 +1,31 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | class Twig_Node_Expression_Conditional extends Twig_Node_Expression | ||
13 | { | ||
14 | public function __construct(Twig_Node_Expression $expr1, Twig_Node_Expression $expr2, Twig_Node_Expression $expr3, $lineno) | ||
15 | { | ||
16 | parent::__construct(array('expr1' => $expr1, 'expr2' => $expr2, 'expr3' => $expr3), array(), $lineno); | ||
17 | } | ||
18 | |||
19 | public function compile(Twig_Compiler $compiler) | ||
20 | { | ||
21 | $compiler | ||
22 | ->raw('((') | ||
23 | ->subcompile($this->getNode('expr1')) | ||
24 | ->raw(') ? (') | ||
25 | ->subcompile($this->getNode('expr2')) | ||
26 | ->raw(') : (') | ||
27 | ->subcompile($this->getNode('expr3')) | ||
28 | ->raw('))') | ||
29 | ; | ||
30 | } | ||
31 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Constant.php b/inc/3rdparty/Twig/Node/Expression/Constant.php new file mode 100644 index 00000000..a91dc698 --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Constant.php | |||
@@ -0,0 +1,23 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | class Twig_Node_Expression_Constant extends Twig_Node_Expression | ||
13 | { | ||
14 | public function __construct($value, $lineno) | ||
15 | { | ||
16 | parent::__construct(array(), array('value' => $value), $lineno); | ||
17 | } | ||
18 | |||
19 | public function compile(Twig_Compiler $compiler) | ||
20 | { | ||
21 | $compiler->repr($this->getAttribute('value')); | ||
22 | } | ||
23 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/ExtensionReference.php b/inc/3rdparty/Twig/Node/Expression/ExtensionReference.php new file mode 100644 index 00000000..00ac6701 --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/ExtensionReference.php | |||
@@ -0,0 +1,33 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 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 | * Represents an extension call node. | ||
14 | * | ||
15 | * @author Fabien Potencier <fabien@symfony.com> | ||
16 | */ | ||
17 | class Twig_Node_Expression_ExtensionReference extends Twig_Node_Expression | ||
18 | { | ||
19 | public function __construct($name, $lineno, $tag = null) | ||
20 | { | ||
21 | parent::__construct(array(), array('name' => $name), $lineno, $tag); | ||
22 | } | ||
23 | |||
24 | /** | ||
25 | * Compiles the node to PHP. | ||
26 | * | ||
27 | * @param Twig_Compiler A Twig_Compiler instance | ||
28 | */ | ||
29 | public function compile(Twig_Compiler $compiler) | ||
30 | { | ||
31 | $compiler->raw(sprintf("\$this->env->getExtension('%s')", $this->getAttribute('name'))); | ||
32 | } | ||
33 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Filter.php b/inc/3rdparty/Twig/Node/Expression/Filter.php new file mode 100644 index 00000000..207b062a --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Filter.php | |||
@@ -0,0 +1,36 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | class Twig_Node_Expression_Filter extends Twig_Node_Expression_Call | ||
13 | { | ||
14 | public function __construct(Twig_NodeInterface $node, Twig_Node_Expression_Constant $filterName, Twig_NodeInterface $arguments, $lineno, $tag = null) | ||
15 | { | ||
16 | parent::__construct(array('node' => $node, 'filter' => $filterName, 'arguments' => $arguments), array(), $lineno, $tag); | ||
17 | } | ||
18 | |||
19 | public function compile(Twig_Compiler $compiler) | ||
20 | { | ||
21 | $name = $this->getNode('filter')->getAttribute('value'); | ||
22 | $filter = $compiler->getEnvironment()->getFilter($name); | ||
23 | |||
24 | $this->setAttribute('name', $name); | ||
25 | $this->setAttribute('type', 'filter'); | ||
26 | $this->setAttribute('thing', $filter); | ||
27 | $this->setAttribute('needs_environment', $filter->needsEnvironment()); | ||
28 | $this->setAttribute('needs_context', $filter->needsContext()); | ||
29 | $this->setAttribute('arguments', $filter->getArguments()); | ||
30 | if ($filter instanceof Twig_FilterCallableInterface || $filter instanceof Twig_SimpleFilter) { | ||
31 | $this->setAttribute('callable', $filter->getCallable()); | ||
32 | } | ||
33 | |||
34 | $this->compileCallable($compiler); | ||
35 | } | ||
36 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Filter/Default.php b/inc/3rdparty/Twig/Node/Expression/Filter/Default.php new file mode 100644 index 00000000..1827c888 --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Filter/Default.php | |||
@@ -0,0 +1,43 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2011 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 | * Returns the value or the default value when it is undefined or empty. | ||
14 | * | ||
15 | * <pre> | ||
16 | * {{ var.foo|default('foo item on var is not defined') }} | ||
17 | * </pre> | ||
18 | * | ||
19 | * @author Fabien Potencier <fabien@symfony.com> | ||
20 | */ | ||
21 | class Twig_Node_Expression_Filter_Default extends Twig_Node_Expression_Filter | ||
22 | { | ||
23 | public function __construct(Twig_NodeInterface $node, Twig_Node_Expression_Constant $filterName, Twig_NodeInterface $arguments, $lineno, $tag = null) | ||
24 | { | ||
25 | $default = new Twig_Node_Expression_Filter($node, new Twig_Node_Expression_Constant('default', $node->getLine()), $arguments, $node->getLine()); | ||
26 | |||
27 | if ('default' === $filterName->getAttribute('value') && ($node instanceof Twig_Node_Expression_Name || $node instanceof Twig_Node_Expression_GetAttr)) { | ||
28 | $test = new Twig_Node_Expression_Test_Defined(clone $node, 'defined', new Twig_Node(), $node->getLine()); | ||
29 | $false = count($arguments) ? $arguments->getNode(0) : new Twig_Node_Expression_Constant('', $node->getLine()); | ||
30 | |||
31 | $node = new Twig_Node_Expression_Conditional($test, $default, $false, $node->getLine()); | ||
32 | } else { | ||
33 | $node = $default; | ||
34 | } | ||
35 | |||
36 | parent::__construct($node, $filterName, $arguments, $lineno, $tag); | ||
37 | } | ||
38 | |||
39 | public function compile(Twig_Compiler $compiler) | ||
40 | { | ||
41 | $compiler->subcompile($this->getNode('node')); | ||
42 | } | ||
43 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Function.php b/inc/3rdparty/Twig/Node/Expression/Function.php new file mode 100644 index 00000000..3e1f6b55 --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Function.php | |||
@@ -0,0 +1,35 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2010 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 | class Twig_Node_Expression_Function extends Twig_Node_Expression_Call | ||
12 | { | ||
13 | public function __construct($name, Twig_NodeInterface $arguments, $lineno) | ||
14 | { | ||
15 | parent::__construct(array('arguments' => $arguments), array('name' => $name), $lineno); | ||
16 | } | ||
17 | |||
18 | public function compile(Twig_Compiler $compiler) | ||
19 | { | ||
20 | $name = $this->getAttribute('name'); | ||
21 | $function = $compiler->getEnvironment()->getFunction($name); | ||
22 | |||
23 | $this->setAttribute('name', $name); | ||
24 | $this->setAttribute('type', 'function'); | ||
25 | $this->setAttribute('thing', $function); | ||
26 | $this->setAttribute('needs_environment', $function->needsEnvironment()); | ||
27 | $this->setAttribute('needs_context', $function->needsContext()); | ||
28 | $this->setAttribute('arguments', $function->getArguments()); | ||
29 | if ($function instanceof Twig_FunctionCallableInterface || $function instanceof Twig_SimpleFunction) { | ||
30 | $this->setAttribute('callable', $function->getCallable()); | ||
31 | } | ||
32 | |||
33 | $this->compileCallable($compiler); | ||
34 | } | ||
35 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/GetAttr.php b/inc/3rdparty/Twig/Node/Expression/GetAttr.php new file mode 100644 index 00000000..81a9b137 --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/GetAttr.php | |||
@@ -0,0 +1,53 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | class Twig_Node_Expression_GetAttr extends Twig_Node_Expression | ||
13 | { | ||
14 | public function __construct(Twig_Node_Expression $node, Twig_Node_Expression $attribute, Twig_Node_Expression_Array $arguments, $type, $lineno) | ||
15 | { | ||
16 | parent::__construct(array('node' => $node, 'attribute' => $attribute, 'arguments' => $arguments), array('type' => $type, 'is_defined_test' => false, 'ignore_strict_check' => false, 'disable_c_ext' => false), $lineno); | ||
17 | } | ||
18 | |||
19 | public function compile(Twig_Compiler $compiler) | ||
20 | { | ||
21 | if (function_exists('twig_template_get_attributes') && !$this->getAttribute('disable_c_ext')) { | ||
22 | $compiler->raw('twig_template_get_attributes($this, '); | ||
23 | } else { | ||
24 | $compiler->raw('$this->getAttribute('); | ||
25 | } | ||
26 | |||
27 | if ($this->getAttribute('ignore_strict_check')) { | ||
28 | $this->getNode('node')->setAttribute('ignore_strict_check', true); | ||
29 | } | ||
30 | |||
31 | $compiler->subcompile($this->getNode('node')); | ||
32 | |||
33 | $compiler->raw(', ')->subcompile($this->getNode('attribute')); | ||
34 | |||
35 | if (count($this->getNode('arguments')) || Twig_TemplateInterface::ANY_CALL !== $this->getAttribute('type') || $this->getAttribute('is_defined_test') || $this->getAttribute('ignore_strict_check')) { | ||
36 | $compiler->raw(', ')->subcompile($this->getNode('arguments')); | ||
37 | |||
38 | if (Twig_TemplateInterface::ANY_CALL !== $this->getAttribute('type') || $this->getAttribute('is_defined_test') || $this->getAttribute('ignore_strict_check')) { | ||
39 | $compiler->raw(', ')->repr($this->getAttribute('type')); | ||
40 | } | ||
41 | |||
42 | if ($this->getAttribute('is_defined_test') || $this->getAttribute('ignore_strict_check')) { | ||
43 | $compiler->raw(', '.($this->getAttribute('is_defined_test') ? 'true' : 'false')); | ||
44 | } | ||
45 | |||
46 | if ($this->getAttribute('ignore_strict_check')) { | ||
47 | $compiler->raw(', '.($this->getAttribute('ignore_strict_check') ? 'true' : 'false')); | ||
48 | } | ||
49 | } | ||
50 | |||
51 | $compiler->raw(')'); | ||
52 | } | ||
53 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/MethodCall.php b/inc/3rdparty/Twig/Node/Expression/MethodCall.php new file mode 100644 index 00000000..620b02bf --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/MethodCall.php | |||
@@ -0,0 +1,41 @@ | |||
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 | class Twig_Node_Expression_MethodCall extends Twig_Node_Expression | ||
12 | { | ||
13 | public function __construct(Twig_Node_Expression $node, $method, Twig_Node_Expression_Array $arguments, $lineno) | ||
14 | { | ||
15 | parent::__construct(array('node' => $node, 'arguments' => $arguments), array('method' => $method, 'safe' => false), $lineno); | ||
16 | |||
17 | if ($node instanceof Twig_Node_Expression_Name) { | ||
18 | $node->setAttribute('always_defined', true); | ||
19 | } | ||
20 | } | ||
21 | |||
22 | public function compile(Twig_Compiler $compiler) | ||
23 | { | ||
24 | $compiler | ||
25 | ->subcompile($this->getNode('node')) | ||
26 | ->raw('->') | ||
27 | ->raw($this->getAttribute('method')) | ||
28 | ->raw('(') | ||
29 | ; | ||
30 | $first = true; | ||
31 | foreach ($this->getNode('arguments')->getKeyValuePairs() as $pair) { | ||
32 | if (!$first) { | ||
33 | $compiler->raw(', '); | ||
34 | } | ||
35 | $first = false; | ||
36 | |||
37 | $compiler->subcompile($pair['value']); | ||
38 | } | ||
39 | $compiler->raw(')'); | ||
40 | } | ||
41 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Name.php b/inc/3rdparty/Twig/Node/Expression/Name.php new file mode 100644 index 00000000..3b8fae01 --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Name.php | |||
@@ -0,0 +1,88 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | class Twig_Node_Expression_Name extends Twig_Node_Expression | ||
13 | { | ||
14 | protected $specialVars = array( | ||
15 | '_self' => '$this', | ||
16 | '_context' => '$context', | ||
17 | '_charset' => '$this->env->getCharset()', | ||
18 | ); | ||
19 | |||
20 | public function __construct($name, $lineno) | ||
21 | { | ||
22 | parent::__construct(array(), array('name' => $name, 'is_defined_test' => false, 'ignore_strict_check' => false, 'always_defined' => false), $lineno); | ||
23 | } | ||
24 | |||
25 | public function compile(Twig_Compiler $compiler) | ||
26 | { | ||
27 | $name = $this->getAttribute('name'); | ||
28 | |||
29 | if ($this->getAttribute('is_defined_test')) { | ||
30 | if ($this->isSpecial()) { | ||
31 | $compiler->repr(true); | ||
32 | } else { | ||
33 | $compiler->raw('array_key_exists(')->repr($name)->raw(', $context)'); | ||
34 | } | ||
35 | } elseif ($this->isSpecial()) { | ||
36 | $compiler->raw($this->specialVars[$name]); | ||
37 | } elseif ($this->getAttribute('always_defined')) { | ||
38 | $compiler | ||
39 | ->raw('$context[') | ||
40 | ->string($name) | ||
41 | ->raw(']') | ||
42 | ; | ||
43 | } else { | ||
44 | // remove the non-PHP 5.4 version when PHP 5.3 support is dropped | ||
45 | // as the non-optimized version is just a workaround for slow ternary operator | ||
46 | // when the context has a lot of variables | ||
47 | if (version_compare(phpversion(), '5.4.0RC1', '>=')) { | ||
48 | // PHP 5.4 ternary operator performance was optimized | ||
49 | $compiler | ||
50 | ->raw('(isset($context[') | ||
51 | ->string($name) | ||
52 | ->raw(']) ? $context[') | ||
53 | ->string($name) | ||
54 | ->raw('] : ') | ||
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 | } | ||
62 | } else { | ||
63 | $compiler | ||
64 | ->raw('$this->getContext($context, ') | ||
65 | ->string($name) | ||
66 | ; | ||
67 | |||
68 | if ($this->getAttribute('ignore_strict_check')) { | ||
69 | $compiler->raw(', true'); | ||
70 | } | ||
71 | |||
72 | $compiler | ||
73 | ->raw(')') | ||
74 | ; | ||
75 | } | ||
76 | } | ||
77 | } | ||
78 | |||
79 | public function isSpecial() | ||
80 | { | ||
81 | return isset($this->specialVars[$this->getAttribute('name')]); | ||
82 | } | ||
83 | |||
84 | public function isSimple() | ||
85 | { | ||
86 | return !$this->isSpecial() && !$this->getAttribute('is_defined_test'); | ||
87 | } | ||
88 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Parent.php b/inc/3rdparty/Twig/Node/Expression/Parent.php new file mode 100644 index 00000000..dcf618c0 --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Parent.php | |||
@@ -0,0 +1,47 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | |||
13 | /** | ||
14 | * Represents a parent node. | ||
15 | * | ||
16 | * @author Fabien Potencier <fabien@symfony.com> | ||
17 | */ | ||
18 | class Twig_Node_Expression_Parent extends Twig_Node_Expression | ||
19 | { | ||
20 | public function __construct($name, $lineno, $tag = null) | ||
21 | { | ||
22 | parent::__construct(array(), array('output' => false, 'name' => $name), $lineno, $tag); | ||
23 | } | ||
24 | |||
25 | /** | ||
26 | * Compiles the node to PHP. | ||
27 | * | ||
28 | * @param Twig_Compiler A Twig_Compiler instance | ||
29 | */ | ||
30 | public function compile(Twig_Compiler $compiler) | ||
31 | { | ||
32 | if ($this->getAttribute('output')) { | ||
33 | $compiler | ||
34 | ->addDebugInfo($this) | ||
35 | ->write("\$this->displayParentBlock(") | ||
36 | ->string($this->getAttribute('name')) | ||
37 | ->raw(", \$context, \$blocks);\n") | ||
38 | ; | ||
39 | } else { | ||
40 | $compiler | ||
41 | ->raw("\$this->renderParentBlock(") | ||
42 | ->string($this->getAttribute('name')) | ||
43 | ->raw(", \$context, \$blocks)") | ||
44 | ; | ||
45 | } | ||
46 | } | ||
47 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/TempName.php b/inc/3rdparty/Twig/Node/Expression/TempName.php new file mode 100644 index 00000000..e6b058e8 --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/TempName.php | |||
@@ -0,0 +1,26 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2011 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 | class Twig_Node_Expression_TempName extends Twig_Node_Expression | ||
12 | { | ||
13 | public function __construct($name, $lineno) | ||
14 | { | ||
15 | parent::__construct(array(), array('name' => $name), $lineno); | ||
16 | } | ||
17 | |||
18 | public function compile(Twig_Compiler $compiler) | ||
19 | { | ||
20 | $compiler | ||
21 | ->raw('$_') | ||
22 | ->raw($this->getAttribute('name')) | ||
23 | ->raw('_') | ||
24 | ; | ||
25 | } | ||
26 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Test.php b/inc/3rdparty/Twig/Node/Expression/Test.php new file mode 100644 index 00000000..639f501a --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Test.php | |||
@@ -0,0 +1,32 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2010 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 | class Twig_Node_Expression_Test extends Twig_Node_Expression_Call | ||
12 | { | ||
13 | public function __construct(Twig_NodeInterface $node, $name, Twig_NodeInterface $arguments = null, $lineno) | ||
14 | { | ||
15 | parent::__construct(array('node' => $node, 'arguments' => $arguments), array('name' => $name), $lineno); | ||
16 | } | ||
17 | |||
18 | public function compile(Twig_Compiler $compiler) | ||
19 | { | ||
20 | $name = $this->getAttribute('name'); | ||
21 | $test = $compiler->getEnvironment()->getTest($name); | ||
22 | |||
23 | $this->setAttribute('name', $name); | ||
24 | $this->setAttribute('type', 'test'); | ||
25 | $this->setAttribute('thing', $test); | ||
26 | if ($test instanceof Twig_TestCallableInterface || $test instanceof Twig_SimpleTest) { | ||
27 | $this->setAttribute('callable', $test->getCallable()); | ||
28 | } | ||
29 | |||
30 | $this->compileCallable($compiler); | ||
31 | } | ||
32 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Test/Constant.php b/inc/3rdparty/Twig/Node/Expression/Test/Constant.php new file mode 100644 index 00000000..de55f5f5 --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Test/Constant.php | |||
@@ -0,0 +1,46 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2011 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 | * Checks if a variable is the exact same value as a constant. | ||
14 | * | ||
15 | * <pre> | ||
16 | * {% if post.status is constant('Post::PUBLISHED') %} | ||
17 | * the status attribute is exactly the same as Post::PUBLISHED | ||
18 | * {% endif %} | ||
19 | * </pre> | ||
20 | * | ||
21 | * @author Fabien Potencier <fabien@symfony.com> | ||
22 | */ | ||
23 | class Twig_Node_Expression_Test_Constant extends Twig_Node_Expression_Test | ||
24 | { | ||
25 | public function compile(Twig_Compiler $compiler) | ||
26 | { | ||
27 | $compiler | ||
28 | ->raw('(') | ||
29 | ->subcompile($this->getNode('node')) | ||
30 | ->raw(' === constant(') | ||
31 | ; | ||
32 | |||
33 | if ($this->getNode('arguments')->hasNode(1)) { | ||
34 | $compiler | ||
35 | ->raw('get_class(') | ||
36 | ->subcompile($this->getNode('arguments')->getNode(1)) | ||
37 | ->raw(')."::".') | ||
38 | ; | ||
39 | } | ||
40 | |||
41 | $compiler | ||
42 | ->subcompile($this->getNode('arguments')->getNode(0)) | ||
43 | ->raw('))') | ||
44 | ; | ||
45 | } | ||
46 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Test/Defined.php b/inc/3rdparty/Twig/Node/Expression/Test/Defined.php new file mode 100644 index 00000000..247b2e23 --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Test/Defined.php | |||
@@ -0,0 +1,54 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2011 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 | * Checks if a variable is defined in the current context. | ||
14 | * | ||
15 | * <pre> | ||
16 | * {# defined works with variable names and variable attributes #} | ||
17 | * {% if foo is defined %} | ||
18 | * {# ... #} | ||
19 | * {% endif %} | ||
20 | * </pre> | ||
21 | * | ||
22 | * @author Fabien Potencier <fabien@symfony.com> | ||
23 | */ | ||
24 | class Twig_Node_Expression_Test_Defined extends Twig_Node_Expression_Test | ||
25 | { | ||
26 | public function __construct(Twig_NodeInterface $node, $name, Twig_NodeInterface $arguments = null, $lineno) | ||
27 | { | ||
28 | parent::__construct($node, $name, $arguments, $lineno); | ||
29 | |||
30 | if ($node instanceof Twig_Node_Expression_Name) { | ||
31 | $node->setAttribute('is_defined_test', true); | ||
32 | } elseif ($node instanceof Twig_Node_Expression_GetAttr) { | ||
33 | $node->setAttribute('is_defined_test', true); | ||
34 | |||
35 | $this->changeIgnoreStrictCheck($node); | ||
36 | } else { | ||
37 | throw new Twig_Error_Syntax('The "defined" test only works with simple variables', $this->getLine()); | ||
38 | } | ||
39 | } | ||
40 | |||
41 | protected function changeIgnoreStrictCheck(Twig_Node_Expression_GetAttr $node) | ||
42 | { | ||
43 | $node->setAttribute('ignore_strict_check', true); | ||
44 | |||
45 | if ($node->getNode('node') instanceof Twig_Node_Expression_GetAttr) { | ||
46 | $this->changeIgnoreStrictCheck($node->getNode('node')); | ||
47 | } | ||
48 | } | ||
49 | |||
50 | public function compile(Twig_Compiler $compiler) | ||
51 | { | ||
52 | $compiler->subcompile($this->getNode('node')); | ||
53 | } | ||
54 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Test/Divisibleby.php b/inc/3rdparty/Twig/Node/Expression/Test/Divisibleby.php new file mode 100644 index 00000000..0aceb530 --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Test/Divisibleby.php | |||
@@ -0,0 +1,33 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2011 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 | * Checks if a variable is divisible by a number. | ||
14 | * | ||
15 | * <pre> | ||
16 | * {% if loop.index is divisibleby(3) %} | ||
17 | * </pre> | ||
18 | * | ||
19 | * @author Fabien Potencier <fabien@symfony.com> | ||
20 | */ | ||
21 | class Twig_Node_Expression_Test_Divisibleby extends Twig_Node_Expression_Test | ||
22 | { | ||
23 | public function compile(Twig_Compiler $compiler) | ||
24 | { | ||
25 | $compiler | ||
26 | ->raw('(0 == ') | ||
27 | ->subcompile($this->getNode('node')) | ||
28 | ->raw(' % ') | ||
29 | ->subcompile($this->getNode('arguments')->getNode(0)) | ||
30 | ->raw(')') | ||
31 | ; | ||
32 | } | ||
33 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Test/Even.php b/inc/3rdparty/Twig/Node/Expression/Test/Even.php new file mode 100644 index 00000000..d7853e89 --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Test/Even.php | |||
@@ -0,0 +1,32 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2011 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 | * Checks if a number is even. | ||
14 | * | ||
15 | * <pre> | ||
16 | * {{ var is even }} | ||
17 | * </pre> | ||
18 | * | ||
19 | * @author Fabien Potencier <fabien@symfony.com> | ||
20 | */ | ||
21 | class Twig_Node_Expression_Test_Even extends Twig_Node_Expression_Test | ||
22 | { | ||
23 | public function compile(Twig_Compiler $compiler) | ||
24 | { | ||
25 | $compiler | ||
26 | ->raw('(') | ||
27 | ->subcompile($this->getNode('node')) | ||
28 | ->raw(' % 2 == 0') | ||
29 | ->raw(')') | ||
30 | ; | ||
31 | } | ||
32 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Test/Null.php b/inc/3rdparty/Twig/Node/Expression/Test/Null.php new file mode 100644 index 00000000..1c83825a --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Test/Null.php | |||
@@ -0,0 +1,31 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2011 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 | * Checks that a variable is null. | ||
14 | * | ||
15 | * <pre> | ||
16 | * {{ var is none }} | ||
17 | * </pre> | ||
18 | * | ||
19 | * @author Fabien Potencier <fabien@symfony.com> | ||
20 | */ | ||
21 | class Twig_Node_Expression_Test_Null extends Twig_Node_Expression_Test | ||
22 | { | ||
23 | public function compile(Twig_Compiler $compiler) | ||
24 | { | ||
25 | $compiler | ||
26 | ->raw('(null === ') | ||
27 | ->subcompile($this->getNode('node')) | ||
28 | ->raw(')') | ||
29 | ; | ||
30 | } | ||
31 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Test/Odd.php b/inc/3rdparty/Twig/Node/Expression/Test/Odd.php new file mode 100644 index 00000000..421c19e8 --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Test/Odd.php | |||
@@ -0,0 +1,32 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2011 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 | * Checks if a number is odd. | ||
14 | * | ||
15 | * <pre> | ||
16 | * {{ var is odd }} | ||
17 | * </pre> | ||
18 | * | ||
19 | * @author Fabien Potencier <fabien@symfony.com> | ||
20 | */ | ||
21 | class Twig_Node_Expression_Test_Odd extends Twig_Node_Expression_Test | ||
22 | { | ||
23 | public function compile(Twig_Compiler $compiler) | ||
24 | { | ||
25 | $compiler | ||
26 | ->raw('(') | ||
27 | ->subcompile($this->getNode('node')) | ||
28 | ->raw(' % 2 == 1') | ||
29 | ->raw(')') | ||
30 | ; | ||
31 | } | ||
32 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Test/Sameas.php b/inc/3rdparty/Twig/Node/Expression/Test/Sameas.php new file mode 100644 index 00000000..b48905ee --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Test/Sameas.php | |||
@@ -0,0 +1,29 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2011 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 | * Checks if a variable is the same as another one (=== in PHP). | ||
14 | * | ||
15 | * @author Fabien Potencier <fabien@symfony.com> | ||
16 | */ | ||
17 | class Twig_Node_Expression_Test_Sameas extends Twig_Node_Expression_Test | ||
18 | { | ||
19 | public function compile(Twig_Compiler $compiler) | ||
20 | { | ||
21 | $compiler | ||
22 | ->raw('(') | ||
23 | ->subcompile($this->getNode('node')) | ||
24 | ->raw(' === ') | ||
25 | ->subcompile($this->getNode('arguments')->getNode(0)) | ||
26 | ->raw(')') | ||
27 | ; | ||
28 | } | ||
29 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Unary.php b/inc/3rdparty/Twig/Node/Expression/Unary.php new file mode 100644 index 00000000..c514388e --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Unary.php | |||
@@ -0,0 +1,30 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | abstract class Twig_Node_Expression_Unary extends Twig_Node_Expression | ||
13 | { | ||
14 | public function __construct(Twig_NodeInterface $node, $lineno) | ||
15 | { | ||
16 | parent::__construct(array('node' => $node), array(), $lineno); | ||
17 | } | ||
18 | |||
19 | public function compile(Twig_Compiler $compiler) | ||
20 | { | ||
21 | $compiler->raw('('); | ||
22 | $this->operator($compiler); | ||
23 | $compiler | ||
24 | ->subcompile($this->getNode('node')) | ||
25 | ->raw(')') | ||
26 | ; | ||
27 | } | ||
28 | |||
29 | abstract public function operator(Twig_Compiler $compiler); | ||
30 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Unary/Neg.php b/inc/3rdparty/Twig/Node/Expression/Unary/Neg.php new file mode 100644 index 00000000..2a3937ec --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Unary/Neg.php | |||
@@ -0,0 +1,18 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | class Twig_Node_Expression_Unary_Neg extends Twig_Node_Expression_Unary | ||
13 | { | ||
14 | public function operator(Twig_Compiler $compiler) | ||
15 | { | ||
16 | $compiler->raw('-'); | ||
17 | } | ||
18 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Unary/Not.php b/inc/3rdparty/Twig/Node/Expression/Unary/Not.php new file mode 100644 index 00000000..f94073cf --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Unary/Not.php | |||
@@ -0,0 +1,18 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | class Twig_Node_Expression_Unary_Not extends Twig_Node_Expression_Unary | ||
13 | { | ||
14 | public function operator(Twig_Compiler $compiler) | ||
15 | { | ||
16 | $compiler->raw('!'); | ||
17 | } | ||
18 | } | ||
diff --git a/inc/3rdparty/Twig/Node/Expression/Unary/Pos.php b/inc/3rdparty/Twig/Node/Expression/Unary/Pos.php new file mode 100644 index 00000000..04edb52a --- /dev/null +++ b/inc/3rdparty/Twig/Node/Expression/Unary/Pos.php | |||
@@ -0,0 +1,18 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2009 Fabien Potencier | ||
7 | * (c) 2009 Armin Ronacher | ||
8 | * | ||
9 | * For the full copyright and license information, please view the LICENSE | ||
10 | * file that was distributed with this source code. | ||
11 | */ | ||
12 | class Twig_Node_Expression_Unary_Pos extends Twig_Node_Expression_Unary | ||
13 | { | ||
14 | public function operator(Twig_Compiler $compiler) | ||
15 | { | ||
16 | $compiler->raw('+'); | ||
17 | } | ||
18 | } | ||