8000 [TwigBridge] Remove legacy code by alexandre-daubois · Pull Request #59778 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[TwigBridge] Remove legacy code #59778

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[TwigBridge] Remove legacy code
  • Loading branch information
alexandre-daubois committed Feb 14, 2025
commit ef65035d3dab677244276845c478463f6584a831
4 changes: 1 addition & 3 deletions src/Symfony/Bridge/Twig/TokenParser/DumpTokenParser.php
8000
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ public function parse(Token $token): Node
{
$values = null;
if (!$this->parser->getStream()->test(Token::BLOCK_END_TYPE)) {
$values = method_exists($this->parser, 'parseExpression') ?
$this->parseMultitargetExpression() :
$this->parser->getExpressionParser()->parseMultitargetExpression();
$values = $this->parseMultitargetExpression();
}
$this->parser->getStream()->expect(Token::BLOCK_END_TYPE);

Expand Down
10 changes: 3 additions & 7 deletions src/Symfony/Bridge/Twig/TokenParser/FormThemeTokenParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,20 @@ public function parse(Token $token): Node
$lineno = $token->getLine();
$stream = $this->parser->getStream();

$parseExpression = method_exists($this->parser, 'parseExpression')
? $this->parser->parseExpression(...)
: $this->parser->getExpressionParser()->parseExpression(...);

$form = $parseExpression();
$form = $this->parser->parseExpression();
$only = false;

if ($this->parser->getStream()->test(Token::NAME_TYPE, 'with')) {
$this->parser->getStream()->next();
$resources = $parse 8000 Expression();
$resources = $this->parser->parseExpression();

if ($this->parser->getStream()->nextIf(Token::NAME_TYPE, 'only')) {
$only = true;
}
} else {
$resources = new ArrayExpression([], $stream->getCurrent()->getLine());
do {
$resources->addElement($parseExpression());
$resources->addElement($this->parser->parseExpression());
} while (!$stream->test(Token::BLOCK_END_TYPE));
}

Expand Down
4 changes: 1 addition & 3 deletions src/Symfony/Bridge/Twig/TokenParser/StopwatchTokenParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ public function parse(Token $token): Node
$stream = $this->parser->getStream();

// {% stopwatch 'bar' %}
$name = method_exists($this->parser, 'parseExpression') ?
$this->parser->parseExpression() :
$this->parser->getExpressionParser()->parseExpression();
$name = $this->parser->parseExpression();

$stream->expect(Token::BLOCK_END_TYPE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ final class TransDefaultDomainTokenParser extends AbstractTokenParser
{
public function parse(Token $token): Node
{
$expr = method_exists($this->parser, 'parseExpression') ?
$this->parser->parseExpression() :
$this->parser->getExpressionParser()->parseExpression();
$expr = $this->parser->parseExpression();

$this->parser->getStream()->expect(Token::BLOCK_END_TYPE);

Expand Down
11 changes: 4 additions & 7 deletions src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,33 +36,30 @@ public function parse(Token $token): Node
$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 = $parseExpression();
$count = $this->parser->parseExpression();
}

if ($stream->test('with')) {
// {% trans with vars %}
$stream->next();
$vars = $parseExpression();
$vars = $this->parser->parseExpression();
}

if ($stream->test('from')) {
// {% trans from "messages" %}
$stream->next();
$domain = $parseExpression();
$domain = $this->parser->parseExpression();
}

if ($stream->test('into')) {
// {% trans into "fr" %}
$stream->next();
$locale = $parseExpression();
$locale = $this->parser->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());
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Twig/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"php": ">=8.2",
"symfony/deprecation-contracts": "^2.5|^3",
"symfony/translation-contracts": "^2.5|^3",
"twig/twig": "^3.12"
"twig/twig": "^3.21"
},
"require-dev": {
"egulias/email-validator": "^2.1.10|^3|^4",
Expand Down
Loading
0