Fix the sandbox not reporting the line of a rejected guard tag

This commit is contained in:
Fabien Potencier
2026-09-26 10:22:21 +02:00
parent 2904612341
commit b1d6b51183
3 changed files with 3 additions and 1 deletions
+1
View File
@@ -1,6 +1,7 @@
# 3.30.1 (2026-XX-XX)
* Speed up reading object attributes backed by getters or class constants
* Fix the sandbox not reporting the line of a rejected `guard` tag
# 3.30.0 (2026-09-25)
+1 -1
View File
@@ -59,7 +59,7 @@ final class GuardTokenParser extends AbstractTokenParser
}
$stream->expect(Token::BLOCK_END_TYPE);
return new Nodes([$exists ? $body : $else]);
return new Nodes([$exists ? $body : $else], $token->getLine());
}
public function decideGuardFork(Token $token): bool
+1
View File
@@ -142,6 +142,7 @@ class SandboxTest extends TestCase
yield ['flush', '{% flush %}'];
yield ['for', '{% for i in 1..2 %}{% endfor %}'];
yield ['from', '{% from "macros" import foo %}'];
yield ['guard', '{% guard function max %}{% endguard %}'];
yield ['if', '{% if false %}{% endif %}'];
yield ['import', '{% import "macros" as macros %}'];
yield ['include', '{% include "macros" %}'];