Skip to content

Commit

Permalink
removed code that supports obsolete versions of PHP
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Sep 11, 2015
1 parent 4ff8b3f commit 33917e8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
9 changes: 3 additions & 6 deletions lib/Twig/Environment.php
Expand Up @@ -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));
Expand Down
3 changes: 1 addition & 2 deletions lib/Twig/Node/For.php
Expand Up @@ -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")
Expand Down
8 changes: 4 additions & 4 deletions test/Twig/Tests/Node/ForTest.php
Expand Up @@ -51,7 +51,7 @@ public function getTests()

$tests[] = array($node, <<<EOF
// line 1
\$context['_parent'] = (array) \$context;
\$context['_parent'] = \$context;
\$context['_seq'] = twig_ensure_traversable({$this->getVariableGetter('items')});
foreach (\$context['_seq'] as \$context["key"] => \$context["item"]) {
echo {$this->getVariableGetter('foo')};
Expand All @@ -73,7 +73,7 @@ public function getTests()

$tests[] = array($node, <<<EOF
// line 1
\$context['_parent'] = (array) \$context;
\$context['_parent'] = \$context;
\$context['_seq'] = twig_ensure_traversable({$this->getVariableGetter('values')});
\$context['loop'] = array(
'parent' => \$context['_parent'],
Expand Down Expand Up @@ -116,7 +116,7 @@ public function getTests()

$tests[] = array($node, <<<EOF
// line 1
\$context['_parent'] = (array) \$context;
\$context['_parent'] = \$context;
\$context['_seq'] = twig_ensure_traversable({$this->getVariableGetter('values')});
\$context['loop'] = array(
'parent' => \$context['_parent'],
Expand Down Expand Up @@ -149,7 +149,7 @@ public function getTests()

$tests[] = array($node, <<<EOF
// line 1
\$context['_parent'] = (array) \$context;
\$context['_parent'] = \$context;
\$context['_seq'] = twig_ensure_traversable({$this->getVariableGetter('values')});
\$context['_iterated'] = false;
\$context['loop'] = array(
Expand Down

0 comments on commit 33917e8

Please sign in to comment.