mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-19 15:22:17 +02:00
N°8834 - Add compatibility with PHP 8.4 (#819)
* N°8834 - Add compatibility with PHP 8.4 * Rollback of scssphp/scssphp version upgrade due to compilation error
This commit is contained in:
@@ -12,7 +12,9 @@
|
||||
namespace Symfony\Bridge\Twig\TokenParser;
|
||||
|
||||
use Symfony\Bridge\Twig\Node\DumpNode;
|
||||
use Twig\Node\Expression\Variable\LocalVariable;
|
||||
use Twig\Node\Node;
|
||||
use Twig\Node\Nodes;
|
||||
use Twig\Token;
|
||||
use Twig\TokenParser\AbstractTokenParser;
|
||||
|
||||
@@ -33,11 +35,26 @@ final class DumpTokenParser extends AbstractTokenParser
|
||||
{
|
||||
$values = null;
|
||||
if (!$this->parser->getStream()->test(Token::BLOCK_END_TYPE)) {
|
||||
$values = $this->parser->getExpressionParser()->parseMultitargetExpression();
|
||||
$values = method_exists($this->parser, 'parseExpression') ?
|
||||
$this->parseMultitargetExpression() :
|
||||
$this->parser->getExpressionParser()->parseMultitargetExpression();
|
||||
}
|
||||
$this->parser->getStream()->expect(Token::BLOCK_END_TYPE);
|
||||
|
||||
return new DumpNode($this->parser->getVarName(), $values, $token->getLine(), $this->getTag());
|
||||
return new DumpNode(class_exists(LocalVariable::class) ? new LocalVariable(null, $token->getLine()) : $this->parser->getVarName(), $values, $token->getLine(), $this->getTag());
|
||||
}
|
||||
|
||||
private function parseMultitargetExpression(): Node
|
||||
{
|
||||
$targets = [];
|
||||
while (true) {
|
||||
$targets[] = $this->parser->parseExpression();
|
||||
if (!$this->parser->getStream()->nextIf(Token::PUNCTUATION_TYPE, ',')) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return new Nodes($targets);
|
||||
}
|
||||
|
||||
public function getTag(): string
|
||||
|
||||
@@ -29,12 +29,16 @@ final class FormThemeTokenParser extends AbstractTokenParser
|
||||
$lineno = $token->getLine();
|
||||
$stream = $this->parser->getStream();
|
||||
|
||||
$form = $this->parser->getExpressionParser()->parseExpression();
|
||||
$parseExpression = method_exists($this->parser, 'parseExpression')
|
||||
? $this->parser->parseExpression(...)
|
||||
: $this->parser->getExpressionParser()->parseExpression(...);
|
||||
|
||||
$form = $parseExpression();
|
||||
$only = false;
|
||||
|
||||
if ($this->parser->getStream()->test(Token::NAME_TYPE, 'with')) {
|
||||
$this->parser->getStream()->next();
|
||||
$resources = $this->parser->getExpressionParser()->parseExpression();
|
||||
$resources = $parseExpression();
|
||||
|
||||
if ($this->parser->getStream()->nextIf(Token::NAME_TYPE, 'only')) {
|
||||
$only = true;
|
||||
@@ -42,7 +46,7 @@ final class FormThemeTokenParser extends AbstractTokenParser
|
||||
} else {
|
||||
$resources = new ArrayExpression([], $stream->getCurrent()->getLine());
|
||||
do {
|
||||
$resources->addElement($this->parser->getExpressionParser()->parseExpression());
|
||||
$resources->addElement($parseExpression());
|
||||
} while (!$stream->test(Token::BLOCK_END_TYPE));
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Symfony\Bridge\Twig\TokenParser;
|
||||
|
||||
use Symfony\Bridge\Twig\Node\StopwatchNode;
|
||||
use Twig\Node\Expression\AssignNameExpression;
|
||||
use Twig\Node\Expression\Variable\LocalVariable;
|
||||
use Twig\Node\Node;
|
||||
use Twig\Token;
|
||||
use Twig\TokenParser\AbstractTokenParser;
|
||||
@@ -37,7 +38,9 @@ final class StopwatchTokenParser extends AbstractTokenParser
|
||||
$stream = $this->parser->getStream();
|
||||
|
||||
// {% stopwatch 'bar' %}
|
||||
$name = $this->parser->getExpressionParser()->parseExpression();
|
||||
$name = method_exists($this->parser, 'parseExpression') ?
|
||||
$this->parser->parseExpression() :
|
||||
$this->parser->getExpressionParser()->parseExpression();
|
||||
|
||||
$stream->expect(Token::BLOCK_END_TYPE);
|
||||
|
||||
@@ -46,7 +49,7 @@ final class StopwatchTokenParser extends AbstractTokenParser
|
||||
$stream->expect(Token::BLOCK_END_TYPE);
|
||||
|
||||
if ($this->stopwatchIsAvailable) {
|
||||
return new StopwatchNode($name, $body, new AssignNameExpression($this->parser->getVarName(), $token->getLine()), $lineno, $this->getTag());
|
||||
return new StopwatchNode($name, $body, class_exists(LocalVariable::class) ? new LocalVariable(null, $token->getLine()) : new AssignNameExpression($this->parser->getVarName(), $token->getLine()), $lineno, $this->getTag());
|
||||
}
|
||||
|
||||
return $body;
|
||||
|
||||
@@ -25,7 +25,9 @@ final class TransDefaultDomainTokenParser extends AbstractTokenParser
|
||||
{
|
||||
public function parse(Token $token): Node
|
||||
{
|
||||
$expr = $this->parser->getExpressionParser()->parseExpression();
|
||||
$expr = method_exists($this->parser, 'parseExpression') ?
|
||||
$this->parser->parseExpression() :
|
||||
$this->parser->getExpressionParser()->parseExpression();
|
||||
|
||||
$this->parser->getStream()->expect(Token::BLOCK_END_TYPE);
|
||||
|
||||
|
||||
@@ -36,29 +36,33 @@ final class TransTokenParser extends AbstractTokenParser
|
||||
$vars = new ArrayExpression([], $lineno);
|
||||
$domain = null;
|
||||
$locale = null;
|
||||
$parseExpression = method_exists($this->parser, 'parseExpression')
|
||||
? $this->parser->parseExpression(...)
|
||||
: $this->parser->getExpressionParser()->parseExpression(...);
|
||||
|
||||
if (!$stream->test(Token::BLOCK_END_TYPE)) {
|
||||
if ($stream->test('count')) {
|
||||
// {% trans count 5 %}
|
||||
$stream->next();
|
||||
$count = $this->parser->getExpressionParser()->parseExpression();
|
||||
$count = $parseExpression();
|
||||
}
|
||||
|
||||
if ($stream->test('with')) {
|
||||
// {% trans with vars %}
|
||||
$stream->next();
|
||||
$vars = $this->parser->getExpressionParser()->parseExpression();
|
||||
$vars = $parseExpression();
|
||||
}
|
||||
|
||||
if ($stream->test('from')) {
|
||||
// {% trans from "messages" %}
|
||||
$stream->next();
|
||||
$domain = $this->parser->getExpressionParser()->parseExpression();
|
||||
$domain = $parseExpression();
|
||||
}
|
||||
|
||||
if ($stream->test('into')) {
|
||||
// {% trans into "fr" %}
|
||||
$stream->next();
|
||||
$locale = $this->parser->getExpressionParser()->parseExpression();
|
||||
$locale = $parseExpression();
|
||||
} elseif (!$stream->test(Token::BLOCK_END_TYPE)) {
|
||||
throw new SyntaxError('Unexpected token. Twig was looking for the "with", "from", or "into" keyword.', $stream->getCurrent()->getLine(), $stream->getSourceContext());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user