Skip to content

Commit

Permalink
Merge branch '5.4' into 6.4
Browse files Browse the repository at this point in the history
* 5.4:
  fix Twig 3.12 compatibility
  [Translation] Review Serbian translations
  Fix typos
  [DependencyInjection] Fix error message typo in YamlFileLoader
  • Loading branch information
xabbuh committed Aug 29, 2024
2 parents 5800179 + 0057d05 commit 2cf03a4
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 5 deletions.
8 changes: 7 additions & 1 deletion Node/DumpNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Bridge\Twig\Node;

use Twig\Attribute\FirstClassTwigCallableReady;
use Twig\Attribute\YieldReady;
use Twig\Compiler;
use Twig\Node\Node;
Expand All @@ -30,7 +31,12 @@ public function __construct(string $varPrefix, ?Node $values, int $lineno, ?stri
$nodes['values'] = $values;
}

parent::__construct($nodes, [], $lineno, $tag);
if (class_exists(FirstClassTwigCallableReady::class)) {
parent::__construct($nodes, [], $lineno);
} else {
parent::__construct($nodes, [], $lineno, $tag);
}

$this->varPrefix = $varPrefix;
}

Expand Down
7 changes: 6 additions & 1 deletion Node/FormThemeNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Bridge\Twig\Node;

use Symfony\Component\Form\FormRenderer;
use Twig\Attribute\FirstClassTwigCallableReady;
use Twig\Attribute\YieldReady;
use Twig\Compiler;
use Twig\Node\Node;
Expand All @@ -24,7 +25,11 @@ final class FormThemeNode extends Node
{
public function __construct(Node $form, Node $resources, int $lineno, ?string $tag = null, bool $only = false)
{
parent::__construct(['form' => $form, 'resources' => $resources], ['only' => $only], $lineno, $tag);
if (class_exists(FirstClassTwigCallableReady::class)) {
parent::__construct(['form' => $form, 'resources' => $resources], ['only' => $only], $lineno);
} else {
parent::__construct(['form' => $form, 'resources' => $resources], ['only' => $only], $lineno, $tag);
}
}

public function compile(Compiler $compiler): void
Expand Down
7 changes: 6 additions & 1 deletion Node/StopwatchNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Bridge\Twig\Node;

use Twig\Attribute\FirstClassTwigCallableReady;
use Twig\Attribute\YieldReady;
use Twig\Compiler;
use Twig\Node\Expression\AssignNameExpression;
Expand All @@ -26,7 +27,11 @@ final class StopwatchNode extends Node
{
public function __construct(Node $name, Node $body, AssignNameExpression $var, int $lineno = 0, ?string $tag = null)
{
parent::__construct(['body' => $body, 'name' => $name, 'var' => $var], [], $lineno, $tag);
if (class_exists(FirstClassTwigCallableReady::class)) {
parent::__construct(['body' => $body, 'name' => $name, 'var' => $var], [], $lineno);
} else {
parent::__construct(['body' => $body, 'name' => $name, 'var' => $var], [], $lineno, $tag);
}
}

public function compile(Compiler $compiler): void
Expand Down
7 changes: 6 additions & 1 deletion Node/TransDefaultDomainNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Bridge\Twig\Node;

use Twig\Attribute\FirstClassTwigCallableReady;
use Twig\Attribute\YieldReady;
use Twig\Compiler;
use Twig\Node\Expression\AbstractExpression;
Expand All @@ -24,7 +25,11 @@ final class TransDefaultDomainNode extends Node
{
public function __construct(AbstractExpression $expr, int $lineno = 0, ?string $tag = null)
{
parent::__construct(['expr' => $expr], [], $lineno, $tag);
if (class_exists(FirstClassTwigCallableReady::class)) {
parent::__construct(['expr' => $expr], [], $lineno);
} else {
parent::__construct(['expr' => $expr], [], $lineno, $tag);
}
}

public function compile(Compiler $compiler): void
Expand Down
7 changes: 6 additions & 1 deletion Node/TransNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Bridge\Twig\Node;

use Twig\Attribute\FirstClassTwigCallableReady;
use Twig\Attribute\YieldReady;
use Twig\Compiler;
use Twig\Node\Expression\AbstractExpression;
Expand Down Expand Up @@ -42,7 +43,11 @@ public function __construct(Node $body, ?Node $domain = null, ?AbstractExpressio
$nodes['locale'] = $locale;
}

parent::__construct($nodes, [], $lineno, $tag);
if (class_exists(FirstClassTwigCallableReady::class)) {
parent::__construct($nodes, [], $lineno);
} else {
parent::__construct($nodes, [], $lineno, $tag);
}
}

public function compile(Compiler $compiler): void
Expand Down
5 changes: 5 additions & 0 deletions Tests/TokenParser/FormThemeTokenParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Twig\Node\FormThemeNode;
use Symfony\Bridge\Twig\TokenParser\FormThemeTokenParser;
use Twig\Attribute\FirstClassTwigCallableReady;
use Twig\Environment;
use Twig\Loader\LoaderInterface;
use Twig\Node\Expression\ArrayExpression;
Expand All @@ -35,6 +36,10 @@ public function testCompile($source, $expected)
$stream = $env->tokenize($source);
$parser = new Parser($env);

if (class_exists(FirstClassTwigCallableReady::class)) {
$expected->setNodeTag('form_theme');
}

$expected->setSourceContext($source);

$this->assertEquals($expected, $parser->parse($stream)->getNode('body')->getNode(0));
Expand Down

0 comments on commit 2cf03a4

Please sign in to comment.