diff options
| author | Michael Save <savetheinternet@tinyboard.org> | 2012-04-09 20:52:26 +1000 |
|---|---|---|
| committer | Michael Save <savetheinternet@tinyboard.org> | 2012-04-09 20:52:26 +1000 |
| commit | 874b8cbf002e9d8bf0ff39671e1501165016320a (patch) | |
| tree | 1428acec23fef6c607e10fd355d88af31c2029ed /inc/contrib/Twig/Node/Expression | |
| parent | 69c9a9dd452299e0e8f7335966a1d0b4036df583 (diff) | |
inc/contrib -> inc/lib
Diffstat (limited to 'inc/contrib/Twig/Node/Expression')
39 files changed, 0 insertions, 1104 deletions
diff --git a/inc/contrib/Twig/Node/Expression/Array.php b/inc/contrib/Twig/Node/Expression/Array.php deleted file mode 100644 index 2d860823..00000000 --- a/inc/contrib/Twig/Node/Expression/Array.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2009 Fabien Potencier - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Array extends Twig_Node_Expression -{ - public function __construct(array $elements, $lineno) - { - parent::__construct($elements, array(), $lineno); - } - - /** - * Compiles the node to PHP. - * - * @param Twig_Compiler A Twig_Compiler instance - */ - public function compile(Twig_Compiler $compiler) - { - $compiler->raw('array('); - $first = true; - foreach ($this->nodes as $name => $node) { - if (!$first) { - $compiler->raw(', '); - } - $first = false; - - $compiler - ->repr($name) - ->raw(' => ') - ->subcompile($node) - ; - } - $compiler->raw(')'); - } -} diff --git a/inc/contrib/Twig/Node/Expression/AssignName.php b/inc/contrib/Twig/Node/Expression/AssignName.php deleted file mode 100644 index 67f12509..00000000 --- a/inc/contrib/Twig/Node/Expression/AssignName.php +++ /dev/null @@ -1,24 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2009 Fabien Potencier - * (c) 2009 Armin Ronacher - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -class Twig_Node_Expression_AssignName extends Twig_Node_Expression_Name -{ - /** - * Compiles the node to PHP. - * - * @param Twig_Compiler A Twig_Compiler instance - */ - public function compile(Twig_Compiler $compiler) - { - $compiler->raw(sprintf('$context[\'%s\']', $this->getAttribute('name'))); - } -} diff --git a/inc/contrib/Twig/Node/Expression/Binary.php b/inc/contrib/Twig/Node/Expression/Binary.php deleted file mode 100644 index 9dd5de2c..00000000 --- a/inc/contrib/Twig/Node/Expression/Binary.php +++ /dev/null @@ -1,40 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2009 Fabien Potencier - * (c) 2009 Armin Ronacher - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -abstract class Twig_Node_Expression_Binary extends Twig_Node_Expression -{ - public function __construct(Twig_NodeInterface $left, Twig_NodeInterface $right, $lineno) - { - parent::__construct(array('left' => $left, 'right' => $right), array(), $lineno); - } - - /** - * Compiles the node to PHP. - * - * @param Twig_Compiler A Twig_Compiler instance - */ - public function compile(Twig_Compiler $compiler) - { - $compiler - ->raw('(') - ->subcompile($this->getNode('left')) - ->raw(' ') - ; - $this->operator($compiler); - $compiler - ->raw(' ') - ->subcompile($this->getNode('right')) - ->raw(')') - ; - } - - abstract public function operator(Twig_Compiler $compiler); -} diff --git a/inc/contrib/Twig/Node/Expression/Binary/Add.php b/inc/contrib/Twig/Node/Expression/Binary/Add.php deleted file mode 100644 index 0ef8e117..00000000 --- a/inc/contrib/Twig/Node/Expression/Binary/Add.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2009 Fabien Potencier - * (c) 2009 Armin Ronacher - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Binary_Add extends Twig_Node_Expression_Binary -{ - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw('+'); - } -} diff --git a/inc/contrib/Twig/Node/Expression/Binary/And.php b/inc/contrib/Twig/Node/Expression/Binary/And.php deleted file mode 100644 index d5752ebb..00000000 --- a/inc/contrib/Twig/Node/Expression/Binary/And.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2009 Fabien Potencier - * (c) 2009 Armin Ronacher - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Binary_And extends Twig_Node_Expression_Binary -{ - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw('&&'); - } -} diff --git a/inc/contrib/Twig/Node/Expression/Binary/BitwiseAnd.php b/inc/contrib/Twig/Node/Expression/Binary/BitwiseAnd.php deleted file mode 100644 index 9a46d845..00000000 --- a/inc/contrib/Twig/Node/Expression/Binary/BitwiseAnd.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2009 Fabien Potencier - * (c) 2009 Armin Ronacher - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Binary_BitwiseAnd extends Twig_Node_Expression_Binary -{ - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw('&'); - } -} diff --git a/inc/contrib/Twig/Node/Expression/Binary/BitwiseOr.php b/inc/contrib/Twig/Node/Expression/Binary/BitwiseOr.php deleted file mode 100644 index 058a20bf..00000000 --- a/inc/contrib/Twig/Node/Expression/Binary/BitwiseOr.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2009 Fabien Potencier - * (c) 2009 Armin Ronacher - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Binary_BitwiseOr extends Twig_Node_Expression_Binary -{ - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw('|'); - } -} diff --git a/inc/contrib/Twig/Node/Expression/Binary/BitwiseXor.php b/inc/contrib/Twig/Node/Expression/Binary/BitwiseXor.php deleted file mode 100644 index f4da73d4..00000000 --- a/inc/contrib/Twig/Node/Expression/Binary/BitwiseXor.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2009 Fabien Potencier - * (c) 2009 Armin Ronacher - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Binary_BitwiseXor extends Twig_Node_Expression_Binary -{ - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw('^'); - } -} diff --git a/inc/contrib/Twig/Node/Expression/Binary/Concat.php b/inc/contrib/Twig/Node/Expression/Binary/Concat.php deleted file mode 100644 index f9a64627..00000000 --- a/inc/contrib/Twig/Node/Expression/Binary/Concat.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2009 Fabien Potencier - * (c) 2009 Armin Ronacher - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Binary_Concat extends Twig_Node_Expression_Binary -{ - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw('.'); - } -} diff --git a/inc/contrib/Twig/Node/Expression/Binary/Div.php b/inc/contrib/Twig/Node/Expression/Binary/Div.php deleted file mode 100644 index e0797a61..00000000 --- a/inc/contrib/Twig/Node/Expression/Binary/Div.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2009 Fabien Potencier - * (c) 2009 Armin Ronacher - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Binary_Div extends Twig_Node_Expression_Binary -{ - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw('/'); - } -} diff --git a/inc/contrib/Twig/Node/Expression/Binary/Equal.php b/inc/contrib/Twig/Node/Expression/Binary/Equal.php deleted file mode 100644 index 7b1236d0..00000000 --- a/inc/contrib/Twig/Node/Expression/Binary/Equal.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2010 Fabien Potencier - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Binary_Equal extends Twig_Node_Expression_Binary -{ - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw('=='); - } -} diff --git a/inc/contrib/Twig/Node/Expression/Binary/FloorDiv.php b/inc/contrib/Twig/Node/Expression/Binary/FloorDiv.php deleted file mode 100644 index e86b1ea0..00000000 --- a/inc/contrib/Twig/Node/Expression/Binary/FloorDiv.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2009 Fabien Potencier - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Binary_FloorDiv extends Twig_Node_Expression_Binary -{ - /** - * Compiles the node to PHP. - * - * @param Twig_Compiler A Twig_Compiler instance - */ - public function compile(Twig_Compiler $compiler) - { - $compiler->raw('floor('); - parent::compile($compiler); - $compiler->raw(')'); - } - - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw('/'); - } -} diff --git a/inc/contrib/Twig/Node/Expression/Binary/Greater.php b/inc/contrib/Twig/Node/Expression/Binary/Greater.php deleted file mode 100644 index a110bd92..00000000 --- a/inc/contrib/Twig/Node/Expression/Binary/Greater.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2010 Fabien Potencier - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Binary_Greater extends Twig_Node_Expression_Binary -{ - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw('>'); - } -} diff --git a/inc/contrib/Twig/Node/Expression/Binary/GreaterEqual.php b/inc/contrib/Twig/Node/Expression/Binary/GreaterEqual.php deleted file mode 100644 index 3754fed2..00000000 --- a/inc/contrib/Twig/Node/Expression/Binary/GreaterEqual.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2010 Fabien Potencier - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Binary_GreaterEqual extends Twig_Node_Expression_Binary -{ - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw('>='); - } -} diff --git a/inc/contrib/Twig/Node/Expression/Binary/In.php b/inc/contrib/Twig/Node/Expression/Binary/In.php deleted file mode 100644 index 788f9377..00000000 --- a/inc/contrib/Twig/Node/Expression/Binary/In.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2010 Fabien Potencier - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Binary_In extends Twig_Node_Expression_Binary -{ - /** - * Compiles the node to PHP. - * - * @param Twig_Compiler A Twig_Compiler instance - */ - public function compile(Twig_Compiler $compiler) - { - $compiler - ->raw('twig_in_filter(') - ->subcompile($this->getNode('left')) - ->raw(', ') - ->subcompile($this->getNode('right')) - ->raw(')') - ; - } - - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw('in'); - } -} diff --git a/inc/contrib/Twig/Node/Expression/Binary/Less.php b/inc/contrib/Twig/Node/Expression/Binary/Less.php deleted file mode 100644 index 45fd3004..00000000 --- a/inc/contrib/Twig/Node/Expression/Binary/Less.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2010 Fabien Potencier - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Binary_Less extends Twig_Node_Expression_Binary -{ - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw('<'); - } -} diff --git a/inc/contrib/Twig/Node/Expression/Binary/LessEqual.php b/inc/contrib/Twig/Node/Expression/Binary/LessEqual.php deleted file mode 100644 index e38e257c..00000000 --- a/inc/contrib/Twig/Node/Expression/Binary/LessEqual.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2010 Fabien Potencier - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Binary_LessEqual extends Twig_Node_Expression_Binary -{ - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw('<='); - } -} diff --git a/inc/contrib/Twig/Node/Expression/Binary/Mod.php b/inc/contrib/Twig/Node/Expression/Binary/Mod.php deleted file mode 100644 index 9924114f..00000000 --- a/inc/contrib/Twig/Node/Expression/Binary/Mod.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2009 Fabien Potencier - * (c) 2009 Armin Ronacher - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Binary_Mod extends Twig_Node_Expression_Binary -{ - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw('%'); - } -} diff --git a/inc/contrib/Twig/Node/Expression/Binary/Mul.php b/inc/contrib/Twig/Node/Expression/Binary/Mul.php deleted file mode 100644 index c91529ca..00000000 --- a/inc/contrib/Twig/Node/Expression/Binary/Mul.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2009 Fabien Potencier - * (c) 2009 Armin Ronacher - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Binary_Mul extends Twig_Node_Expression_Binary -{ - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw('*'); - } -} diff --git a/inc/contrib/Twig/Node/Expression/Binary/NotEqual.php b/inc/contrib/Twig/Node/Expression/Binary/NotEqual.php deleted file mode 100644 index 26867ba2..00000000 --- a/inc/contrib/Twig/Node/Expression/Binary/NotEqual.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2010 Fabien Potencier - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Binary_NotEqual extends Twig_Node_Expression_Binary -{ - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw('!='); - } -} diff --git a/inc/contrib/Twig/Node/Expression/Binary/NotIn.php b/inc/contrib/Twig/Node/Expression/Binary/NotIn.php deleted file mode 100644 index f347b7b6..00000000 --- a/inc/contrib/Twig/Node/Expression/Binary/NotIn.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2010 Fabien Potencier - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Binary_NotIn extends Twig_Node_Expression_Binary -{ - /** - * Compiles the node to PHP. - * - * @param Twig_Compiler A Twig_Compiler instance - */ - public function compile(Twig_Compiler $compiler) - { - $compiler - ->raw('!twig_in_filter(') - ->subcompile($this->getNode('left')) - ->raw(', ') - ->subcompile($this->getNode('right')) - ->raw(')') - ; - } - - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw('not in'); - } -} diff --git a/inc/contrib/Twig/Node/Expression/Binary/Or.php b/inc/contrib/Twig/Node/Expression/Binary/Or.php deleted file mode 100644 index adba49c6..00000000 --- a/inc/contrib/Twig/Node/Expression/Binary/Or.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2009 Fabien Potencier - * (c) 2009 Armin Ronacher - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Binary_Or extends Twig_Node_Expression_Binary -{ - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw('||'); - } -} diff --git a/inc/contrib/Twig/Node/Expression/Binary/Power.php b/inc/contrib/Twig/Node/Expression/Binary/Power.php deleted file mode 100644 index b2c59040..00000000 --- a/inc/contrib/Twig/Node/Expression/Binary/Power.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2010 Fabien Potencier - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Binary_Power extends Twig_Node_Expression_Binary -{ - /** - * Compiles the node to PHP. - * - * @param Twig_Compiler A Twig_Compiler instance - */ - public function compile(Twig_Compiler $compiler) - { - $compiler - ->raw('pow(') - ->subcompile($this->getNode('left')) - ->raw(', ') - ->subcompile($this->getNode('right')) - ->raw(')') - ; - } - - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw('**'); - } -} diff --git a/inc/contrib/Twig/Node/Expression/Binary/Range.php b/inc/contrib/Twig/Node/Expression/Binary/Range.php deleted file mode 100644 index bea4f2a6..00000000 --- a/inc/contrib/Twig/Node/Expression/Binary/Range.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2010 Fabien Potencier - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Binary_Range extends Twig_Node_Expression_Binary -{ - /** - * Compiles the node to PHP. - * - * @param Twig_Compiler A Twig_Compiler instance - */ - public function compile(Twig_Compiler $compiler) - { - $compiler - ->raw('range(') - ->subcompile($this->getNode('left')) - ->raw(', ') - ->subcompile($this->getNode('right')) - ->raw(')') - ; - } - - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw('..'); - } -} diff --git a/inc/contrib/Twig/Node/Expression/Binary/Sub.php b/inc/contrib/Twig/Node/Expression/Binary/Sub.php deleted file mode 100644 index d4463991..00000000 --- a/inc/contrib/Twig/Node/Expression/Binary/Sub.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2009 Fabien Potencier - * (c) 2009 Armin Ronacher - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Binary_Sub extends Twig_Node_Expression_Binary -{ - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw('-'); - } -} diff --git a/inc/contrib/Twig/Node/Expression/BlockReference.php b/inc/contrib/Twig/Node/Expression/BlockReference.php deleted file mode 100644 index 174d9097..00000000 --- a/inc/contrib/Twig/Node/Expression/BlockReference.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2009 Fabien Potencier - * (c) 2009 Armin Ronacher - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -/** - * Represents a block call node. - * - * @package twig - * @author Fabien Potencier <fabien@symfony.com> - */ -class Twig_Node_Expression_BlockReference extends Twig_Node_Expression -{ - public function __construct(Twig_NodeInterface $name, $asString = false, $lineno, $tag = null) - { - parent::__construct(array('name' => $name), array('as_string' => $asString, 'output' => false), $lineno, $tag); - } - - /** - * Compiles the node to PHP. - * - * @param Twig_Compiler A Twig_Compiler instance - */ - public function compile(Twig_Compiler $compiler) - { - if ($this->getAttribute('as_string')) { - $compiler->raw('(string) '); - } - - if ($this->getAttribute('output')) { - $compiler - ->addDebugInfo($this) - ->write("\$this->displayBlock(") - ->subcompile($this->getNode('name')) - ->raw(", \$context, \$blocks);\n") - ; - } else { - $compiler - ->raw("\$this->renderBlock(") - ->subcompile($this->getNode('name')) - ->raw(", \$context, \$blocks)") - ; - } - } -} diff --git a/inc/contrib/Twig/Node/Expression/Conditional.php b/inc/contrib/Twig/Node/Expression/Conditional.php deleted file mode 100644 index edcb1e2d..00000000 --- a/inc/contrib/Twig/Node/Expression/Conditional.php +++ /dev/null @@ -1,31 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2009 Fabien Potencier - * (c) 2009 Armin Ronacher - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Conditional extends Twig_Node_Expression -{ - public function __construct(Twig_Node_Expression $expr1, Twig_Node_Expression $expr2, Twig_Node_Expression $expr3, $lineno) - { - parent::__construct(array('expr1' => $expr1, 'expr2' => $expr2, 'expr3' => $expr3), array(), $lineno); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler - ->raw('((') - ->subcompile($this->getNode('expr1')) - ->raw(') ? (') - ->subcompile($this->getNode('expr2')) - ->raw(') : (') - ->subcompile($this->getNode('expr3')) - ->raw('))') - ; - } -} diff --git a/inc/contrib/Twig/Node/Expression/Constant.php b/inc/contrib/Twig/Node/Expression/Constant.php deleted file mode 100644 index a91dc698..00000000 --- a/inc/contrib/Twig/Node/Expression/Constant.php +++ /dev/null @@ -1,23 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2009 Fabien Potencier - * (c) 2009 Armin Ronacher - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Constant extends Twig_Node_Expression -{ - public function __construct($value, $lineno) - { - parent::__construct(array(), array('value' => $value), $lineno); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler->repr($this->getAttribute('value')); - } -} diff --git a/inc/contrib/Twig/Node/Expression/ExtensionReference.php b/inc/contrib/Twig/Node/Expression/ExtensionReference.php deleted file mode 100644 index cb4efad0..00000000 --- a/inc/contrib/Twig/Node/Expression/ExtensionReference.php +++ /dev/null @@ -1,34 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2009 Fabien Potencier - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -/** - * Represents an extension call node. - * - * @package twig - * @author Fabien Potencier <fabien@symfony.com> - */ -class Twig_Node_Expression_ExtensionReference extends Twig_Node_Expression -{ - public function __construct($name, $lineno, $tag = null) - { - parent::__construct(array(), array('name' => $name), $lineno, $tag); - } - - /** - * Compiles the node to PHP. - * - * @param Twig_Compiler A Twig_Compiler instance - */ - public function compile(Twig_Compiler $compiler) - { - $compiler->raw(sprintf("\$this->env->getExtension('%s')", $this->getAttribute('name'))); - } -} diff --git a/inc/contrib/Twig/Node/Expression/Filter.php b/inc/contrib/Twig/Node/Expression/Filter.php deleted file mode 100644 index 101e6df0..00000000 --- a/inc/contrib/Twig/Node/Expression/Filter.php +++ /dev/null @@ -1,72 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2009 Fabien Potencier - * (c) 2009 Armin Ronacher - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Filter extends Twig_Node_Expression -{ - public function __construct(Twig_NodeInterface $node, Twig_Node_Expression_Constant $filterName, Twig_NodeInterface $arguments, $lineno, $tag = null) - { - parent::__construct(array('node' => $node, 'filter' => $filterName, 'arguments' => $arguments), array(), $lineno, $tag); - } - - public function compile(Twig_Compiler $compiler) - { - $name = $this->getNode('filter')->getAttribute('value'); - if (false === $filter = $compiler->getEnvironment()->getFilter($name)) { - throw new Twig_Error_Syntax(sprintf('The filter "%s" does not exist', $name), $this->getLine()); - } - - $node = $this->getNode('node'); - - // The default filter is intercepted when the filtered value - // is a name (like obj) or an attribute (like obj.attr) - // In such a case, it's compiled to {{ obj is defined ? obj|default('bar') : 'bar' }} - if ('default' === $name && ($node instanceof Twig_Node_Expression_Name || $node instanceof Twig_Node_Expression_GetAttr)) { - $compiler - ->raw('((') - ->subcompile(new Twig_Node_Expression_Test($node, 'defined', new Twig_Node(), $this->getLine())) - ->raw(') ? (') - ; - - $this->compileFilter($compiler, $filter); - - $compiler->raw(') : ('); - - if ($this->getNode('arguments')->hasNode(0)) { - $compiler->subcompile($this->getNode('arguments')->getNode(0)); - } else { - $compiler->string(''); - } - - $compiler->raw('))'); - } else { - $this->compileFilter($compiler, $filter); - } - } - - protected function compileFilter(Twig_Compiler $compiler, Twig_FilterInterface $filter) - { - $compiler - ->raw($filter->compile().'(') - ->raw($filter->needsEnvironment() ? '$this->env, ' : '') - ->raw($filter->needsContext() ? '$context, ' : '') - ->subcompile($this->getNode('node')) - ; - - foreach ($this->getNode('arguments') as $node) { - $compiler - ->raw(', ') - ->subcompile($node) - ; - } - - $compiler->raw(')'); - } -} diff --git a/inc/contrib/Twig/Node/Expression/Function.php b/inc/contrib/Twig/Node/Expression/Function.php deleted file mode 100644 index 3f457199..00000000 --- a/inc/contrib/Twig/Node/Expression/Function.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2010 Fabien Potencier - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Function extends Twig_Node_Expression -{ - public function __construct($name, Twig_NodeInterface $arguments, $lineno) - { - parent::__construct(array('arguments' => $arguments), array('name' => $name), $lineno); - } - - public function compile(Twig_Compiler $compiler) - { - $function = $compiler->getEnvironment()->getFunction($this->getAttribute('name')); - if (false === $function) { - throw new Twig_Error_Syntax(sprintf('The function "%s" does not exist', $this->getAttribute('name')), $this->getLine()); - } - - $compiler - ->raw($function->compile().'(') - ->raw($function->needsEnvironment() ? '$this->env' : '') - ; - - if ($function->needsContext()) { - $compiler->raw($function->needsEnvironment() ? ', $context' : '$context'); - } - - $first = true; - foreach ($this->getNode('arguments') as $node) { - if (!$first) { - $compiler->raw(', '); - } else { - if ($function->needsEnvironment() || $function->needsContext()) { - $compiler->raw(', '); - } - $first = false; - } - $compiler->subcompile($node); - } - - $compiler->raw(')'); - } -} diff --git a/inc/contrib/Twig/Node/Expression/GetAttr.php b/inc/contrib/Twig/Node/Expression/GetAttr.php deleted file mode 100644 index eb9e6050..00000000 --- a/inc/contrib/Twig/Node/Expression/GetAttr.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2009 Fabien Potencier - * (c) 2009 Armin Ronacher - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_GetAttr extends Twig_Node_Expression -{ - public function __construct(Twig_Node_Expression $node, Twig_Node_Expression $attribute, Twig_NodeInterface $arguments, $type, $lineno) - { - parent::__construct(array('node' => $node, 'attribute' => $attribute, 'arguments' => $arguments), array('type' => $type), $lineno); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler->raw('$this->getAttribute('); - - if ($this->hasAttribute('is_defined_test') && $compiler->getEnvironment()->isStrictVariables()) { - $compiler->subcompile(new Twig_Node_Expression_Filter( - $this->getNode('node'), - new Twig_Node_Expression_Constant('default', $this->getLine()), - new Twig_Node(), - $this->getLine() - )); - } else { - $compiler->subcompile($this->getNode('node')); - } - - $compiler - ->raw(', ') - ->subcompile($this->getNode('attribute')) - ->raw(', array(') - ; - - foreach ($this->getNode('arguments') as $node) { - $compiler - ->subcompile($node) - ->raw(', ') - ; - } - - $compiler - ->raw('), ') - ->repr($this->getAttribute('type')) - ->raw($this->hasAttribute('is_defined_test') ? ', true' : ', false') - ->raw(')'); - } -} diff --git a/inc/contrib/Twig/Node/Expression/Name.php b/inc/contrib/Twig/Node/Expression/Name.php deleted file mode 100644 index fceda2b7..00000000 --- a/inc/contrib/Twig/Node/Expression/Name.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2009 Fabien Potencier - * (c) 2009 Armin Ronacher - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Name extends Twig_Node_Expression -{ - public function __construct($name, $lineno) - { - parent::__construct(array(), array('name' => $name), $lineno); - } - - public function compile(Twig_Compiler $compiler) - { - static $specialVars = array( - '_self' => '$this', - '_context' => '$context', - '_charset' => '$this->env->getCharset()', - ); - - $name = $this->getAttribute('name'); - - if ($this->hasAttribute('is_defined_test')) { - if (isset($specialVars[$name])) { - $compiler->repr(true); - } else { - $compiler->raw('array_key_exists(')->repr($name)->raw(', $context)'); - } - } elseif (isset($specialVars[$name])) { - $compiler->raw($specialVars[$name]); - } else { - $compiler->raw(sprintf('$this->getContext($context, \'%s\')', $name)); - } - } -} diff --git a/inc/contrib/Twig/Node/Expression/Parent.php b/inc/contrib/Twig/Node/Expression/Parent.php deleted file mode 100644 index 5689fe45..00000000 --- a/inc/contrib/Twig/Node/Expression/Parent.php +++ /dev/null @@ -1,39 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2009 Fabien Potencier - * (c) 2009 Armin Ronacher - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -/** - * Represents a parent node. - * - * @package twig - * @author Fabien Potencier <fabien@symfony.com> - */ -class Twig_Node_Expression_Parent extends Twig_Node_Expression -{ - public function __construct($name, $lineno, $tag = null) - { - parent::__construct(array(), array('name' => $name), $lineno, $tag); - } - - /** - * Compiles the node to PHP. - * - * @param Twig_Compiler A Twig_Compiler instance - */ - public function compile(Twig_Compiler $compiler) - { - $compiler - ->raw("\$this->renderParentBlock(") - ->string($this->getAttribute('name')) - ->raw(", \$context, \$blocks)") - ; - } -} diff --git a/inc/contrib/Twig/Node/Expression/Test.php b/inc/contrib/Twig/Node/Expression/Test.php deleted file mode 100644 index ef35df6b..00000000 --- a/inc/contrib/Twig/Node/Expression/Test.php +++ /dev/null @@ -1,60 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2010 Fabien Potencier - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Test extends Twig_Node_Expression -{ - public function __construct(Twig_NodeInterface $node, $name, Twig_NodeInterface $arguments = null, $lineno) - { - parent::__construct(array('node' => $node, 'arguments' => $arguments), array('name' => $name), $lineno); - } - - public function compile(Twig_Compiler $compiler) - { - $testMap = $compiler->getEnvironment()->getTests(); - if (!isset($testMap[$this->getAttribute('name')])) { - throw new Twig_Error_Syntax(sprintf('The test "%s" does not exist', $this->getAttribute('name')), $this->getLine()); - } - - $name = $this->getAttribute('name'); - $node = $this->getNode('node'); - - // defined is a special case - if ('defined' === $name) { - if ($node instanceof Twig_Node_Expression_Name || $node instanceof Twig_Node_Expression_GetAttr) { - $node->setAttribute('is_defined_test', true); - $compiler->subcompile($node); - $node->removeAttribute('is_defined_test'); - } else { - throw new Twig_Error_Syntax('The "defined" test only works with simple variables', $this->getLine()); - } - return; - } - - $compiler - ->raw($testMap[$name]->compile().'(') - ->subcompile($node) - ; - - if (null !== $this->getNode('arguments')) { - $compiler->raw(', '); - - $max = count($this->getNode('arguments')) - 1; - foreach ($this->getNode('arguments') as $i => $arg) { - $compiler->subcompile($arg); - - if ($i != $max) { - $compiler->raw(', '); - } - } - } - - $compiler->raw(')'); - } -} diff --git a/inc/contrib/Twig/Node/Expression/Unary.php b/inc/contrib/Twig/Node/Expression/Unary.php deleted file mode 100644 index c514388e..00000000 --- a/inc/contrib/Twig/Node/Expression/Unary.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2009 Fabien Potencier - * (c) 2009 Armin Ronacher - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -abstract class Twig_Node_Expression_Unary extends Twig_Node_Expression -{ - public function __construct(Twig_NodeInterface $node, $lineno) - { - parent::__construct(array('node' => $node), array(), $lineno); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler->raw('('); - $this->operator($compiler); - $compiler - ->subcompile($this->getNode('node')) - ->raw(')') - ; - } - - abstract public function operator(Twig_Compiler $compiler); -} diff --git a/inc/contrib/Twig/Node/Expression/Unary/Neg.php b/inc/contrib/Twig/Node/Expression/Unary/Neg.php deleted file mode 100644 index 2a3937ec..00000000 --- a/inc/contrib/Twig/Node/Expression/Unary/Neg.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2009 Fabien Potencier - * (c) 2009 Armin Ronacher - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Unary_Neg extends Twig_Node_Expression_Unary -{ - public function operator(Twig_Compiler $compiler) - { - $compiler->raw('-'); - } -} diff --git a/inc/contrib/Twig/Node/Expression/Unary/Not.php b/inc/contrib/Twig/Node/Expression/Unary/Not.php deleted file mode 100644 index f94073cf..00000000 --- a/inc/contrib/Twig/Node/Expression/Unary/Not.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2009 Fabien Potencier - * (c) 2009 Armin Ronacher - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Unary_Not extends Twig_Node_Expression_Unary -{ - public function operator(Twig_Compiler $compiler) - { - $compiler->raw('!'); - } -} diff --git a/inc/contrib/Twig/Node/Expression/Unary/Pos.php b/inc/contrib/Twig/Node/Expression/Unary/Pos.php deleted file mode 100644 index 04edb52a..00000000 --- a/inc/contrib/Twig/Node/Expression/Unary/Pos.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2009 Fabien Potencier - * (c) 2009 Armin Ronacher - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -class Twig_Node_Expression_Unary_Pos extends Twig_Node_Expression_Unary -{ - public function operator(Twig_Compiler $compiler) - { - $compiler->raw('+'); - } -} |
