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:
Lenaick
2026-02-26 10:36:32 +01:00
committed by GitHub
parent d4821b7edc
commit fc967c06ce
961 changed files with 12298 additions and 7130 deletions

View File

@@ -18,14 +18,14 @@ use Twig\Node\Expression\ConstantExpression;
use Twig\Node\Expression\FilterExpression;
use Twig\Node\Expression\FunctionExpression;
use Twig\Node\Node;
use Twig\NodeVisitor\AbstractNodeVisitor;
use Twig\NodeVisitor\NodeVisitorInterface;
/**
* TranslationNodeVisitor extracts translation messages.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
final class TranslationNodeVisitor extends AbstractNodeVisitor
final class TranslationNodeVisitor implements NodeVisitorInterface
{
public const UNDEFINED_DOMAIN = '_undefined';
@@ -49,7 +49,7 @@ final class TranslationNodeVisitor extends AbstractNodeVisitor
return $this->messages;
}
protected function doEnterNode(Node $node, Environment $env): Node
public function enterNode(Node $node, Environment $env): Node
{
if (!$this->enabled) {
return $node;
@@ -57,7 +57,7 @@ final class TranslationNodeVisitor extends AbstractNodeVisitor
if (
$node instanceof FilterExpression
&& 'trans' === $node->getNode('filter')->getAttribute('value')
&& 'trans' === ($node->hasAttribute('twig_callable') ? $node->getAttribute('twig_callable')->getName() : $node->getNode('filter')->getAttribute('value'))
&& $node->getNode('node') instanceof ConstantExpression
) {
// extract constant nodes with a trans filter
@@ -85,7 +85,7 @@ final class TranslationNodeVisitor extends AbstractNodeVisitor
];
} elseif (
$node instanceof FilterExpression
&& 'trans' === $node->getNode('filter')->getAttribute('value')
&& 'trans' === ($node->hasAttribute('twig_callable') ? $node->getAttribute('twig_callable')->getName() : $node->getNode('filter')->getAttribute('value'))
&& $node->getNode('node') instanceof ConcatBinary
&& $message = $this->getConcatValueFromNode($node->getNode('node'), null)
) {
@@ -98,7 +98,7 @@ final class TranslationNodeVisitor extends AbstractNodeVisitor
return $node;
}
protected function doLeaveNode(Node $node, Environment $env): ?Node
public function leaveNode(Node $node, Environment $env): ?Node
{
return $node;
}
@@ -149,6 +149,22 @@ final class TranslationNodeVisitor extends AbstractNodeVisitor
return $node->getAttribute('value');
}
if (
$node instanceof FunctionExpression
&& 'constant' === $node->getAttribute('name')
) {
$nodeArguments = $node->getNode('arguments');
if ($nodeArguments->getIterator()->current() instanceof ConstantExpression) {
$constantName = $nodeArguments->getIterator()->current()->getAttribute('value');
if (\defined($constantName)) {
$value = \constant($constantName);
if (\is_string($value)) {
return $value;
}
}
}
}
return self::UNDEFINED_DOMAIN;
}