summaryrefslogtreecommitdiff
path: root/inc/lib/Twig/Node/Expression/Test
diff options
context:
space:
mode:
authorAppleman1234 <applemansigloo@gmail.com>2022-09-25 13:22:40 +1000
committerAppleman1234 <applemansigloo@gmail.com>2022-09-25 13:22:40 +1000
commit92561d7f36508b7e0271926e417adf0e2e53916b (patch)
treea8588b4f70af276c5acf58836e33b1f6ff5c61e8 /inc/lib/Twig/Node/Expression/Test
parent6f1083e4b51fc9c4c594f6c72cf3d84ef4d0298b (diff)
Initial attempt a switch to composer and PHP-8.1 compatibility
Diffstat (limited to 'inc/lib/Twig/Node/Expression/Test')
-rw-r--r--inc/lib/Twig/Node/Expression/Test/Constant.php48
-rw-r--r--inc/lib/Twig/Node/Expression/Test/Defined.php61
-rw-r--r--inc/lib/Twig/Node/Expression/Test/Divisibleby.php35
-rw-r--r--inc/lib/Twig/Node/Expression/Test/Even.php34
-rw-r--r--inc/lib/Twig/Node/Expression/Test/Null.php33
-rw-r--r--inc/lib/Twig/Node/Expression/Test/Odd.php34
-rw-r--r--inc/lib/Twig/Node/Expression/Test/Sameas.php31
7 files changed, 0 insertions, 276 deletions
diff --git a/inc/lib/Twig/Node/Expression/Test/Constant.php b/inc/lib/Twig/Node/Expression/Test/Constant.php
deleted file mode 100644
index a51a4ba1..00000000
--- a/inc/lib/Twig/Node/Expression/Test/Constant.php
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Checks if a variable is the exact same value as a constant.
- *
- * <pre>
- * {% if post.status is constant('Post::PUBLISHED') %}
- * the status attribute is exactly the same as Post::PUBLISHED
- * {% endif %}
- * </pre>
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_Expression_Test_Constant extends Twig_Node_Expression_Test
-{
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->raw('(')
- ->subcompile($this->getNode('node'))
- ->raw(' === constant(')
- ;
-
- if ($this->getNode('arguments')->hasNode(1)) {
- $compiler
- ->raw('get_class(')
- ->subcompile($this->getNode('arguments')->getNode(1))
- ->raw(')."::".')
- ;
- }
-
- $compiler
- ->subcompile($this->getNode('arguments')->getNode(0))
- ->raw('))')
- ;
- }
-}
-
-class_alias('Twig_Node_Expression_Test_Constant', 'Twig\Node\Expression\Test\ConstantTest', false);
diff --git a/inc/lib/Twig/Node/Expression/Test/Defined.php b/inc/lib/Twig/Node/Expression/Test/Defined.php
deleted file mode 100644
index 2136c390..00000000
--- a/inc/lib/Twig/Node/Expression/Test/Defined.php
+++ /dev/null
@@ -1,61 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Checks if a variable is defined in the current context.
- *
- * <pre>
- * {# defined works with variable names and variable attributes #}
- * {% if foo is defined %}
- * {# ... #}
- * {% endif %}
- * </pre>
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_Expression_Test_Defined extends Twig_Node_Expression_Test
-{
- public function __construct(Twig_NodeInterface $node, $name, Twig_NodeInterface $arguments = null, $lineno)
- {
- if ($node instanceof Twig_Node_Expression_Name) {
- $node->setAttribute('is_defined_test', true);
- } elseif ($node instanceof Twig_Node_Expression_GetAttr) {
- $node->setAttribute('is_defined_test', true);
- $this->changeIgnoreStrictCheck($node);
- } elseif ($node instanceof Twig_Node_Expression_BlockReference) {
- $node->setAttribute('is_defined_test', true);
- } elseif ($node instanceof Twig_Node_Expression_Function && 'constant' === $node->getAttribute('name')) {
- $node->setAttribute('is_defined_test', true);
- } elseif ($node instanceof Twig_Node_Expression_Constant || $node instanceof Twig_Node_Expression_Array) {
- $node = new Twig_Node_Expression_Constant(true, $node->getTemplateLine());
- } else {
- throw new Twig_Error_Syntax('The "defined" test only works with simple variables.', $this->getTemplateLine());
- }
-
- parent::__construct($node, $name, $arguments, $lineno);
- }
-
- protected function changeIgnoreStrictCheck(Twig_Node_Expression_GetAttr $node)
- {
- $node->setAttribute('ignore_strict_check', true);
-
- if ($node->getNode('node') instanceof Twig_Node_Expression_GetAttr) {
- $this->changeIgnoreStrictCheck($node->getNode('node'));
- }
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $compiler->subcompile($this->getNode('node'));
- }
-}
-
-class_alias('Twig_Node_Expression_Test_Defined', 'Twig\Node\Expression\Test\DefinedTest', false);
diff --git a/inc/lib/Twig/Node/Expression/Test/Divisibleby.php b/inc/lib/Twig/Node/Expression/Test/Divisibleby.php
deleted file mode 100644
index a5d71961..00000000
--- a/inc/lib/Twig/Node/Expression/Test/Divisibleby.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Checks if a variable is divisible by a number.
- *
- * <pre>
- * {% if loop.index is divisible by(3) %}
- * </pre>
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_Expression_Test_Divisibleby extends Twig_Node_Expression_Test
-{
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->raw('(0 == ')
- ->subcompile($this->getNode('node'))
- ->raw(' % ')
- ->subcompile($this->getNode('arguments')->getNode(0))
- ->raw(')')
- ;
- }
-}
-
-class_alias('Twig_Node_Expression_Test_Divisibleby', 'Twig\Node\Expression\Test\DivisiblebyTest', false);
diff --git a/inc/lib/Twig/Node/Expression/Test/Even.php b/inc/lib/Twig/Node/Expression/Test/Even.php
deleted file mode 100644
index 7e198bea..00000000
--- a/inc/lib/Twig/Node/Expression/Test/Even.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Checks if a number is even.
- *
- * <pre>
- * {{ var is even }}
- * </pre>
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_Expression_Test_Even extends Twig_Node_Expression_Test
-{
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->raw('(')
- ->subcompile($this->getNode('node'))
- ->raw(' % 2 == 0')
- ->raw(')')
- ;
- }
-}
-
-class_alias('Twig_Node_Expression_Test_Even', 'Twig\Node\Expression\Test\EvenTest', false);
diff --git a/inc/lib/Twig/Node/Expression/Test/Null.php b/inc/lib/Twig/Node/Expression/Test/Null.php
deleted file mode 100644
index 3746e4cb..00000000
--- a/inc/lib/Twig/Node/Expression/Test/Null.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Checks that a variable is null.
- *
- * <pre>
- * {{ var is none }}
- * </pre>
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_Expression_Test_Null extends Twig_Node_Expression_Test
-{
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->raw('(null === ')
- ->subcompile($this->getNode('node'))
- ->raw(')')
- ;
- }
-}
-
-class_alias('Twig_Node_Expression_Test_Null', 'Twig\Node\Expression\Test\NullTest', false);
diff --git a/inc/lib/Twig/Node/Expression/Test/Odd.php b/inc/lib/Twig/Node/Expression/Test/Odd.php
deleted file mode 100644
index 0c6c099b..00000000
--- a/inc/lib/Twig/Node/Expression/Test/Odd.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Checks if a number is odd.
- *
- * <pre>
- * {{ var is odd }}
- * </pre>
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_Expression_Test_Odd extends Twig_Node_Expression_Test
-{
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->raw('(')
- ->subcompile($this->getNode('node'))
- ->raw(' % 2 == 1')
- ->raw(')')
- ;
- }
-}
-
-class_alias('Twig_Node_Expression_Test_Odd', 'Twig\Node\Expression\Test\OddTest', false);
diff --git a/inc/lib/Twig/Node/Expression/Test/Sameas.php b/inc/lib/Twig/Node/Expression/Test/Sameas.php
deleted file mode 100644
index e95ff1f2..00000000
--- a/inc/lib/Twig/Node/Expression/Test/Sameas.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Checks if a variable is the same as another one (=== in PHP).
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_Expression_Test_Sameas extends Twig_Node_Expression_Test
-{
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->raw('(')
- ->subcompile($this->getNode('node'))
- ->raw(' === ')
- ->subcompile($this->getNode('arguments')->getNode(0))
- ->raw(')')
- ;
- }
-}
-
-class_alias('Twig_Node_Expression_Test_Sameas', 'Twig\Node\Expression\Test\SameasTest', false);