From 33917e87ae1bc19a313cdf4483623c95e3c1cd47 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 11 Sep 2015 13:20:59 +0200 Subject: [PATCH] removed code that supports obsolete versions of PHP --- lib/Twig/Environment.php | 9 +++------ lib/Twig/Node/For.php | 3 +-- test/Twig/Tests/Node/ForTest.php | 8 ++++---- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/Twig/Environment.php b/lib/Twig/Environment.php index f0f6298a28..3bc42a5a33 100644 --- a/lib/Twig/Environment.php +++ b/lib/Twig/Environment.php @@ -1293,13 +1293,10 @@ protected function writeCacheFile($file, $content) } $tmpFile = tempnam($dir, basename($file)); - if (false !== @file_put_contents($tmpFile, $content)) { - // rename does not work on Win32 before 5.2.6 - if (@rename($tmpFile, $file) || (@copy($tmpFile, $file) && unlink($tmpFile))) { - @chmod($file, 0666 & ~umask()); + if ((false !== @file_put_contents($tmpFile, $content)) && @rename($tmpFile, $file)) { + @chmod($file, 0666 & ~umask()); - return; - } + return; } throw new RuntimeException(sprintf('Failed to write cache file "%s".', $file)); diff --git a/lib/Twig/Node/For.php b/lib/Twig/Node/For.php index 36e9de8d35..a8d199a510 100644 --- a/lib/Twig/Node/For.php +++ b/lib/Twig/Node/For.php @@ -39,8 +39,7 @@ public function compile(Twig_Compiler $compiler) { $compiler ->addDebugInfo($this) - // the (array) cast bypasses a PHP 5.2.6 bug - ->write("\$context['_parent'] = (array) \$context;\n") + ->write("\$context['_parent'] = \$context;\n") ->write("\$context['_seq'] = twig_ensure_traversable(") ->subcompile($this->getNode('seq')) ->raw(");\n") diff --git a/test/Twig/Tests/Node/ForTest.php b/test/Twig/Tests/Node/ForTest.php index b289592fb0..b2c6fa42fe 100644 --- a/test/Twig/Tests/Node/ForTest.php +++ b/test/Twig/Tests/Node/ForTest.php @@ -51,7 +51,7 @@ public function getTests() $tests[] = array($node, <<getVariableGetter('items')}); foreach (\$context['_seq'] as \$context["key"] => \$context["item"]) { echo {$this->getVariableGetter('foo')}; @@ -73,7 +73,7 @@ public function getTests() $tests[] = array($node, <<getVariableGetter('values')}); \$context['loop'] = array( 'parent' => \$context['_parent'], @@ -116,7 +116,7 @@ public function getTests() $tests[] = array($node, <<getVariableGetter('values')}); \$context['loop'] = array( 'parent' => \$context['_parent'], @@ -149,7 +149,7 @@ public function getTests() $tests[] = array($node, <<getVariableGetter('values')}); \$context['_iterated'] = false; \$context['loop'] = array(