minor #1815 removed code that supports obsolete versions of PHP (fabpot)

This PR was merged into the 1.x branch.

Discussion
----------

removed code that supports obsolete versions of PHP

Commits
-------

33917e8 removed code that supports obsolete versions of PHP
This commit is contained in:
Fabien Potencier
2015-09-11 14:08:28 +02:00
3 changed files with 8 additions and 12 deletions
+3 -6
View File
@@ -1293,13 +1293,10 @@ class Twig_Environment
}
$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));
+1 -2
View File
@@ -39,8 +39,7 @@ class Twig_Node_For extends Twig_Node
{
$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")
+4 -4
View File
@@ -51,7 +51,7 @@ class Twig_Tests_Node_ForTest extends Twig_Test_NodeTestCase
$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')};
@@ -73,7 +73,7 @@ EOF
$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'],
@@ -116,7 +116,7 @@ EOF
$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'],
@@ -149,7 +149,7 @@ EOF
$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(