From 4977bb5d1bbf9e584331f2b18ff3ab8b34dd9284 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 10 Jan 2017 07:15:15 -0800 Subject: [PATCH] removed obsolete code --- lib/Twig/Error/Loader.php | 7 +------ lib/Twig/Node/Expression/NullCoalesce.php | 2 +- lib/Twig/Test/NodeTestCase.php | 6 +----- test/Twig/Tests/Node/Expression/NullCoalesceTest.php | 11 +---------- 4 files changed, 4 insertions(+), 22 deletions(-) diff --git a/lib/Twig/Error/Loader.php b/lib/Twig/Error/Loader.php index dd514e703..3dcfe0d30 100644 --- a/lib/Twig/Error/Loader.php +++ b/lib/Twig/Error/Loader.php @@ -26,12 +26,7 @@ class Twig_Error_Loader extends Twig_Error { public function __construct($message, $lineno = -1, $source = null, Exception $previous = null) { - if (PHP_VERSION_ID < 50300) { - $this->previous = $previous; - Exception::__construct(''); - } else { - Exception::__construct('', 0, $previous); - } + Exception::__construct('', 0, $previous); $this->appendMessage($message); $this->setTemplateLine(false); } diff --git a/lib/Twig/Node/Expression/NullCoalesce.php b/lib/Twig/Node/Expression/NullCoalesce.php index a75a3d3bc..b20e649a4 100644 --- a/lib/Twig/Node/Expression/NullCoalesce.php +++ b/lib/Twig/Node/Expression/NullCoalesce.php @@ -30,7 +30,7 @@ class Twig_Node_Expression_NullCoalesce extends Twig_Node_Expression_Conditional * cases might be implemented as an optimizer node visitor, but has not been done * as benefits are probably not worth the added complexity. */ - if (PHP_VERSION_ID >= 70000 && $this->getNode('expr2') instanceof Twig_Node_Expression_Name) { + if ($this->getNode('expr2') instanceof Twig_Node_Expression_Name) { $this->getNode('expr2')->setAttribute('always_defined', true); $compiler ->raw('((') diff --git a/lib/Twig/Test/NodeTestCase.php b/lib/Twig/Test/NodeTestCase.php index 53334f19c..0a3bbee36 100644 --- a/lib/Twig/Test/NodeTestCase.php +++ b/lib/Twig/Test/NodeTestCase.php @@ -46,11 +46,7 @@ abstract class Twig_Test_NodeTestCase extends PHPUnit_Framework_TestCase { $line = $line > 0 ? "// line {$line}\n" : ''; - if (PHP_VERSION_ID >= 70000) { - return sprintf('%s($context["%s"] ?? null)', $line, $name, $name); - } - - return sprintf('%s(isset($context["%s"]) ? $context["%s"] : null)', $line, $name, $name); + return sprintf('%s($context["%s"] ?? null)', $line, $name, $name); } protected function getAttributeGetter() diff --git a/test/Twig/Tests/Node/Expression/NullCoalesceTest.php b/test/Twig/Tests/Node/Expression/NullCoalesceTest.php index a37490baf..01ddb79b1 100644 --- a/test/Twig/Tests/Node/Expression/NullCoalesceTest.php +++ b/test/Twig/Tests/Node/Expression/NullCoalesceTest.php @@ -13,19 +13,10 @@ class Twig_Tests_Node_Expression_NullCoalesceTest extends Twig_Test_NodeTestCase { public function getTests() { - $tests = array(); - $left = new Twig_Node_Expression_Name('foo', 1); $right = new Twig_Node_Expression_Constant(2, 1); $node = new Twig_Node_Expression_NullCoalesce($left, $right, 1); - if (PHP_VERSION_ID >= 70000) { - $tests[] = array($node, "((// line 1\n\$context[\"foo\"]) ?? (2))"); - } elseif (PHP_VERSION_ID >= 50400) { - $tests[] = array($node, "(((// line 1\narray_key_exists(\"foo\", \$context) && !(null === (isset(\$context[\"foo\"]) ? \$context[\"foo\"] : null)))) ? ((isset(\$context[\"foo\"]) ? \$context[\"foo\"] : null)) : (2))"); - } else { - $tests[] = array($node, "(((// line 1\narray_key_exists(\"foo\", \$context) && !(null === \$this->getContext(\$context, \"foo\")))) ? (\$this->getContext(\$context, \"foo\")) : (2))"); - } - return $tests; + return array(array($node, "((// line 1\n\$context[\"foo\"]) ?? (2))")); } }