Skip to content

Commit 9dfe0ba

Browse files
Stop using deprecated method
1 parent 45a4634 commit 9dfe0ba

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/Environment/Parser/ComponentTokenParser.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function parse(Token $token): Node
1717
{
1818
$stream = $this->parser->getStream();
1919

20-
$this->parser->getExpressionParser()->parseExpression();
20+
$this->parseExpression();
2121
$this->parseArguments();
2222

2323
$fakeParentToken = new Token(Token::STRING_TYPE, '__parent__', $token->getLine());
@@ -47,11 +47,22 @@ private function parseArguments(): void
4747
$stream = $this->parser->getStream();
4848

4949
if (null !== $stream->nextIf(Token::NAME_TYPE, 'with')) {
50-
$this->parser->getExpressionParser()->parseExpression();
50+
$this->parseExpression();
5151
}
5252

5353
$stream->nextIf(Token::NAME_TYPE, 'only');
5454

5555
$stream->expect(Token::BLOCK_END_TYPE);
5656
}
57+
58+
private function parseExpression(): void
59+
{
60+
// @phpstan-ignore-next-line
61+
if (method_exists($this->parser, 'parseExpression')) {
62+
// Since Twig 3.21
63+
$this->parser->parseExpression();
64+
} else {
65+
$this->parser->getExpressionParser()->parseExpression();
66+
}
67+
}
5768
}

0 commit comments

Comments
 (0)