| @@ 8-35 (lines=28) @@ | ||
| 5 | use TwigJs\JsCompiler; |
|
| 6 | use TwigJs\TypeCompilerInterface; |
|
| 7 | ||
| 8 | class ConstantCompiler implements TypeCompilerInterface |
|
| 9 | { |
|
| 10 | public function getType() |
|
| 11 | { |
|
| 12 | return 'Twig_Node_Expression_Test_Constant'; |
|
| 13 | } |
|
| 14 | ||
| 15 | public function compile(JsCompiler $compiler, \Twig_NodeInterface $node) |
|
| 16 | { |
|
| 17 | if (!$node instanceof \Twig_Node_Expression_Test_Constant) { |
|
| 18 | throw new \RuntimeException( |
|
| 19 | sprintf( |
|
| 20 | '$node must be an instanceof of \Twig_Node_Expression_Test_Constant, but got "%s".', |
|
| 21 | get_class($node) |
|
| 22 | ) |
|
| 23 | ); |
|
| 24 | } |
|
| 25 | ||
| 26 | $compiler->subcompile( |
|
| 27 | new \Twig_Node_Expression_Test( |
|
| 28 | $node->getNode('node'), |
|
| 29 | $node->getAttribute('name'), |
|
| 30 | $node->hasNode('arguments') ? $node->getNode('arguments') : null, |
|
| 31 | $node->getLine() |
|
| 32 | ) |
|
| 33 | ); |
|
| 34 | } |
|
| 35 | } |
|
| 36 | ||
| @@ 8-35 (lines=28) @@ | ||
| 5 | use TwigJs\JsCompiler; |
|
| 6 | use TwigJs\TypeCompilerInterface; |
|
| 7 | ||
| 8 | class DefinedCompiler implements TypeCompilerInterface |
|
| 9 | { |
|
| 10 | public function getType() |
|
| 11 | { |
|
| 12 | return 'Twig_Node_Expression_Test_Defined'; |
|
| 13 | } |
|
| 14 | ||
| 15 | public function compile(JsCompiler $compiler, \Twig_NodeInterface $node) |
|
| 16 | { |
|
| 17 | if (!$node instanceof \Twig_Node_Expression_Test_Defined) { |
|
| 18 | throw new \RuntimeException( |
|
| 19 | sprintf( |
|
| 20 | '$node must be an instanceof of \Twig_Node_Expression_Test_Defined, but got "%s".', |
|
| 21 | get_class($node) |
|
| 22 | ) |
|
| 23 | ); |
|
| 24 | } |
|
| 25 | ||
| 26 | $compiler->subcompile( |
|
| 27 | new \Twig_Node_Expression_Test( |
|
| 28 | $node->getNode('node'), |
|
| 29 | $node->getAttribute('name'), |
|
| 30 | $node->hasNode('arguments') ? $node->getNode('arguments') : null, |
|
| 31 | $node->getLine() |
|
| 32 | ) |
|
| 33 | ); |
|
| 34 | } |
|
| 35 | } |
|
| 36 | ||
| @@ 8-35 (lines=28) @@ | ||
| 5 | use TwigJs\JsCompiler; |
|
| 6 | use TwigJs\TypeCompilerInterface; |
|
| 7 | ||
| 8 | class DivisiblebyCompiler implements TypeCompilerInterface |
|
| 9 | { |
|
| 10 | public function getType() |
|
| 11 | { |
|
| 12 | return 'Twig_Node_Expression_Test_Divisibleby'; |
|
| 13 | } |
|
| 14 | ||
| 15 | public function compile(JsCompiler $compiler, \Twig_NodeInterface $node) |
|
| 16 | { |
|
| 17 | if (!$node instanceof \Twig_Node_Expression_Test_Divisibleby) { |
|
| 18 | throw new \RuntimeException( |
|
| 19 | sprintf( |
|
| 20 | '$node must be an instanceof of \Twig_Node_Expression_Test_Divisibleby, but got "%s".', |
|
| 21 | get_class($node) |
|
| 22 | ) |
|
| 23 | ); |
|
| 24 | } |
|
| 25 | ||
| 26 | $compiler->subcompile( |
|
| 27 | new \Twig_Node_Expression_Test( |
|
| 28 | $node->getNode('node'), |
|
| 29 | $node->getAttribute('name'), |
|
| 30 | $node->hasNode('arguments') ? $node->getNode('arguments') : null, |
|
| 31 | $node->getLine() |
|
| 32 | ) |
|
| 33 | ); |
|
| 34 | } |
|
| 35 | } |
|
| 36 | ||
| @@ 8-35 (lines=28) @@ | ||
| 5 | use TwigJs\JsCompiler; |
|
| 6 | use TwigJs\TypeCompilerInterface; |
|
| 7 | ||
| 8 | class EvenCompiler implements TypeCompilerInterface |
|
| 9 | { |
|
| 10 | public function getType() |
|
| 11 | { |
|
| 12 | return 'Twig_Node_Expression_Test_Even'; |
|
| 13 | } |
|
| 14 | ||
| 15 | public function compile(JsCompiler $compiler, \Twig_NodeInterface $node) |
|
| 16 | { |
|
| 17 | if (!$node instanceof \Twig_Node_Expression_Test_Even) { |
|
| 18 | throw new \RuntimeException( |
|
| 19 | sprintf( |
|
| 20 | '$node must be an instanceof of \Twig_Node_Expression_Test_Even, but got "%s".', |
|
| 21 | get_class($node) |
|
| 22 | ) |
|
| 23 | ); |
|
| 24 | } |
|
| 25 | ||
| 26 | $compiler->subcompile( |
|
| 27 | new \Twig_Node_Expression_Test( |
|
| 28 | $node->getNode('node'), |
|
| 29 | $node->getAttribute('name'), |
|
| 30 | $node->hasNode('arguments') ? $node->getNode('arguments') : null, |
|
| 31 | $node->getLine() |
|
| 32 | ) |
|
| 33 | ); |
|
| 34 | } |
|
| 35 | } |
|
| 36 | ||
| @@ 8-35 (lines=28) @@ | ||
| 5 | use TwigJs\JsCompiler; |
|
| 6 | use TwigJs\TypeCompilerInterface; |
|
| 7 | ||
| 8 | class NullCompiler implements TypeCompilerInterface |
|
| 9 | { |
|
| 10 | public function getType() |
|
| 11 | { |
|
| 12 | return 'Twig_Node_Expression_Test_Null'; |
|
| 13 | } |
|
| 14 | ||
| 15 | public function compile(JsCompiler $compiler, \Twig_NodeInterface $node) |
|
| 16 | { |
|
| 17 | if (!$node instanceof \Twig_Node_Expression_Test_Null) { |
|
| 18 | throw new \RuntimeException( |
|
| 19 | sprintf( |
|
| 20 | '$node must be an instanceof of \Twig_Node_Expression_Test_Null, but got "%s".', |
|
| 21 | get_class($node) |
|
| 22 | ) |
|
| 23 | ); |
|
| 24 | } |
|
| 25 | ||
| 26 | $compiler->subcompile( |
|
| 27 | new \Twig_Node_Expression_Test( |
|
| 28 | $node->getNode('node'), |
|
| 29 | $node->getAttribute('name'), |
|
| 30 | $node->hasNode('arguments') ? $node->getNode('arguments') : null, |
|
| 31 | $node->getLine() |
|
| 32 | ) |
|
| 33 | ); |
|
| 34 | } |
|
| 35 | } |
|
| 36 | ||
| @@ 8-35 (lines=28) @@ | ||
| 5 | use TwigJs\JsCompiler; |
|
| 6 | use TwigJs\TypeCompilerInterface; |
|
| 7 | ||
| 8 | class OddCompiler implements TypeCompilerInterface |
|
| 9 | { |
|
| 10 | public function getType() |
|
| 11 | { |
|
| 12 | return 'Twig_Node_Expression_Test_Odd'; |
|
| 13 | } |
|
| 14 | ||
| 15 | public function compile(JsCompiler $compiler, \Twig_NodeInterface $node) |
|
| 16 | { |
|
| 17 | if (!$node instanceof \Twig_Node_Expression_Test_Odd) { |
|
| 18 | throw new \RuntimeException( |
|
| 19 | sprintf( |
|
| 20 | '$node must be an instanceof of \Twig_Node_Expression_Test_Odd, but got "%s".', |
|
| 21 | get_class($node) |
|
| 22 | ) |
|
| 23 | ); |
|
| 24 | } |
|
| 25 | ||
| 26 | $compiler->subcompile( |
|
| 27 | new \Twig_Node_Expression_Test( |
|
| 28 | $node->getNode('node'), |
|
| 29 | $node->getAttribute('name'), |
|
| 30 | $node->hasNode('arguments') ? $node->getNode('arguments') : null, |
|
| 31 | $node->getLine() |
|
| 32 | ) |
|
| 33 | ); |
|
| 34 | } |
|
| 35 | } |
|
| 36 | ||
| @@ 8-35 (lines=28) @@ | ||
| 5 | use TwigJs\JsCompiler; |
|
| 6 | use TwigJs\TypeCompilerInterface; |
|
| 7 | ||
| 8 | class SameasCompiler implements TypeCompilerInterface |
|
| 9 | { |
|
| 10 | public function getType() |
|
| 11 | { |
|
| 12 | return 'Twig_Node_Expression_Test_Sameas'; |
|
| 13 | } |
|
| 14 | ||
| 15 | public function compile(JsCompiler $compiler, \Twig_NodeInterface $node) |
|
| 16 | { |
|
| 17 | if (!$node instanceof \Twig_Node_Expression_Test_Sameas) { |
|
| 18 | throw new \RuntimeException( |
|
| 19 | sprintf( |
|
| 20 | '$node must be an instanceof of \Twig_Node_Expression_Test_Sameas, but got "%s".', |
|
| 21 | get_class($node) |
|
| 22 | ) |
|
| 23 | ); |
|
| 24 | } |
|
| 25 | ||
| 26 | $compiler->subcompile( |
|
| 27 | new \Twig_Node_Expression_Test( |
|
| 28 | $node->getNode('node'), |
|
| 29 | $node->getAttribute('name'), |
|
| 30 | $node->hasNode('arguments') ? $node->getNode('arguments') : null, |
|
| 31 | $node->getLine() |
|
| 32 | ) |
|
| 33 | ); |
|
| 34 | } |
|
| 35 | } |
|
| 36 | ||