bug #4572 Use correct lineno for ForElseNode (ruudk)

This PR was merged into the 3.x branch.

Discussion
----------

Use correct lineno for ForElseNode

It should take the line number of the `{% else %}` block.

Commits
-------

a84e602b4f Use correct lineno for ForElseNode
This commit is contained in:
Fabien Potencier
2025-02-07 15:19:42 +01:00
+2 -1
View File
@@ -42,8 +42,9 @@ final class ForTokenParser extends AbstractTokenParser
$stream->expect(Token::BLOCK_END_TYPE);
$body = $this->parser->subparse([$this, 'decideForFork']);
if ('else' == $stream->next()->getValue()) {
$elseLineno = $stream->getCurrent()->getLine();
$stream->expect(Token::BLOCK_END_TYPE);
$else = new ForElseNode($this->parser->subparse([$this, 'decideForEnd'], true), $stream->getCurrent()->getLine());
$else = new ForElseNode($this->parser->subparse([$this, 'decideForEnd'], true), $elseLineno);
} else {
$else = null;
}