Skip to content

Commit

Permalink
Revert "New feature #15706: Support PHP 7.4"
Browse files Browse the repository at this point in the history
This reverts commit 3a73006.
  • Loading branch information
olleharstedt authored and eddylackmann committed Jan 27, 2020
1 parent b50b740 commit 52b5c7a
Show file tree
Hide file tree
Showing 179 changed files with 897 additions and 13,193 deletions.
5 changes: 0 additions & 5 deletions application/third_party/Twig/Autoloader.php
Expand Up @@ -49,11 +49,6 @@ public static function autoload($class)

if (is_file($file = dirname(__FILE__).'/../'.str_replace(array('_', "\0"), array('/', ''), $class).'.php')) {
require $file;
} else {
$file = str_replace('\\', '/', $file);
if (is_file($file)) {
require $file;
}
}
}
}
60 changes: 0 additions & 60 deletions application/third_party/Twig/Cache/CacheInterface.php

This file was deleted.

93 changes: 0 additions & 93 deletions application/third_party/Twig/Cache/FilesystemCache.php

This file was deleted.

42 changes: 0 additions & 42 deletions application/third_party/Twig/Cache/NullCache.php

This file was deleted.

57 changes: 25 additions & 32 deletions application/third_party/Twig/Compiler.php
Expand Up @@ -3,35 +3,30 @@
/*
* This file is part of Twig.
*
* (c) Fabien Potencier
* (c) Armin Ronacher
* (c) 2009 Fabien Potencier
* (c) 2009 Armin Ronacher
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Twig;

use Twig\Node\ModuleNode;

/**
* Compiles a node to PHP code.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class Compiler implements \Twig_CompilerInterface
class Twig_Compiler implements Twig_CompilerInterface
{
protected $lastLine;
protected $source;
protected $indentation;
protected $env;
protected $debugInfo = [];
protected $debugInfo = array();
protected $sourceOffset;
protected $sourceLine;
protected $filename;
private $varNameSalt = 0;

public function __construct(Environment $env)
public function __construct(Twig_Environment $env)
{
$this->env = $env;
}
Expand All @@ -49,7 +44,7 @@ public function getFilename()
/**
* Returns the environment instance related to this compiler.
*
* @return Environment
* @return Twig_Environment
*/
public function getEnvironment()
{
Expand All @@ -69,22 +64,22 @@ public function getSource()
/**
* Compiles a node.
*
* @param int $indentation The current indentation
* @param Twig_NodeInterface $node The node to compile
* @param int $indentation The current indentation
*
* @return $this
*/
public function compile(\Twig_NodeInterface $node, $indentation = 0)
public function compile(Twig_NodeInterface $node, $indentation = 0)
{
$this->lastLine = null;
$this->source = '';
$this->debugInfo = [];
$this->debugInfo = array();
$this->sourceOffset = 0;
// source code starts at 1 (as we then increment it when we encounter new lines)
$this->sourceLine = 1;
$this->indentation = $indentation;
$this->varNameSalt = 0;

if ($node instanceof ModuleNode) {
if ($node instanceof Twig_Node_Module) {
// to be removed in 2.0
$this->filename = $node->getTemplateName();
}
Expand All @@ -94,7 +89,7 @@ public function compile(\Twig_NodeInterface $node, $indentation = 0)
return $this;
}

public function subcompile(\Twig_NodeInterface $node, $raw = true)
public function subcompile(Twig_NodeInterface $node, $raw = true)
{
if (false === $raw) {
$this->source .= str_repeat(' ', $this->indentation * 4);
Expand Down Expand Up @@ -126,7 +121,7 @@ public function raw($string)
*/
public function write()
{
$strings = \func_get_args();
$strings = func_get_args();
foreach ($strings as $string) {
$this->source .= str_repeat(' ', $this->indentation * 4).$string;
}
Expand Down Expand Up @@ -173,22 +168,22 @@ public function string($value)
*/
public function repr($value)
{
if (\is_int($value) || \is_float($value)) {
if (false !== $locale = setlocale(LC_NUMERIC, '0')) {
if (is_int($value) || is_float($value)) {
if (false !== $locale = setlocale(LC_NUMERIC, 0)) {
setlocale(LC_NUMERIC, 'C');
}

$this->raw(var_export($value, true));
$this->raw($value);

if (false !== $locale) {
setlocale(LC_NUMERIC, $locale);
}
} elseif (null === $value) {
$this->raw('null');
} elseif (\is_bool($value)) {
} elseif (is_bool($value)) {
$this->raw($value ? 'true' : 'false');
} elseif (\is_array($value)) {
$this->raw('[');
} elseif (is_array($value)) {
$this->raw('array(');
$first = true;
foreach ($value as $key => $v) {
if (!$first) {
Expand All @@ -199,7 +194,7 @@ public function repr($value)
$this->raw(' => ');
$this->repr($v);
}
$this->raw(']');
$this->raw(')');
} else {
$this->string($value);
}
Expand All @@ -212,7 +207,7 @@ public function repr($value)
*
* @return $this
*/
public function addDebugInfo(\Twig_NodeInterface $node)
public function addDebugInfo(Twig_NodeInterface $node)
{
if ($node->getTemplateLine() != $this->lastLine) {
$this->write(sprintf("// line %d\n", $node->getTemplateLine()));
Expand All @@ -228,7 +223,7 @@ public function addDebugInfo(\Twig_NodeInterface $node)
} else {
$this->sourceLine += substr_count($this->source, "\n", $this->sourceOffset);
}
$this->sourceOffset = \strlen($this->source);
$this->sourceOffset = strlen($this->source);
$this->debugInfo[$this->sourceLine] = $node->getTemplateLine();

$this->lastLine = $node->getTemplateLine();
Expand Down Expand Up @@ -265,13 +260,13 @@ public function indent($step = 1)
*
* @return $this
*
* @throws \LogicException When trying to outdent too much so the indentation would become negative
* @throws LogicException When trying to outdent too much so the indentation would become negative
*/
public function outdent($step = 1)
{
// can't outdent by more steps than the current indentation level
if ($this->indentation < $step) {
throw new \LogicException('Unable to call outdent() as the indentation would become negative.');
throw new LogicException('Unable to call outdent() as the indentation would become negative.');
}

$this->indentation -= $step;
Expand All @@ -281,8 +276,6 @@ public function outdent($step = 1)

public function getVarName()
{
return sprintf('__internal_%s', hash('sha256', __METHOD__.$this->varNameSalt++));
return sprintf('__internal_%s', hash('sha256', uniqid(mt_rand(), true), false));
}
}

class_alias('Twig\Compiler', 'Twig_Compiler');

0 comments on commit 52b5c7a

Please sign in to comment.