Merge branch '2.x' into 3.x

* 2.x:
  tweaked the error message when using extends in a block/macro
This commit is contained in:
Fabien Potencier
2019-05-16 16:17:01 +02:00
5 changed files with 25 additions and 11 deletions
+4 -2
View File
@@ -27,8 +27,10 @@ final class ExtendsTokenParser extends AbstractTokenParser
{
$stream = $this->parser->getStream();
if (!$this->parser->isMainScope()) {
throw new SyntaxError('Cannot extend from a block.', $token->getLine(), $stream->getSourceContext());
if ($this->parser->peekBlockStack()) {
throw new SyntaxError('Cannot use "extend" in a block.', $token->getLine(), $stream->getSourceContext());
} elseif (!$this->parser->isMainScope()) {
throw new SyntaxError('Cannot use "extend" in a macro.', $token->getLine(), $stream->getSourceContext());
}
if (null !== $this->parser->getParent()) {