diff --git a/src/ExpressionParser.php b/src/ExpressionParser.php index 66acddf61..70b6eb05c 100644 --- a/src/ExpressionParser.php +++ b/src/ExpressionParser.php @@ -485,7 +485,7 @@ class ExpressionParser } } } else { - throw new SyntaxError('Expected name or number.', $lineno, $stream->getSourceContext()); + throw new SyntaxError(sprintf('Expected name or number, got value "%s" of type %s.', $token->getValue(), Token::typeToEnglish($token->getType())), $lineno, $stream->getSourceContext()); } if ($node instanceof NameExpression && null !== $this->parser->getImportedSymbol('template', $node->getAttribute('name'))) { diff --git a/src/Sandbox/SecurityPolicyInterface.php b/src/Sandbox/SecurityPolicyInterface.php index 8eff61414..36471c54c 100644 --- a/src/Sandbox/SecurityPolicyInterface.php +++ b/src/Sandbox/SecurityPolicyInterface.php @@ -19,16 +19,26 @@ namespace Twig\Sandbox; interface SecurityPolicyInterface { /** + * @param string[] $tags + * @param string[] $filters + * @param string[] $functions + * * @throws SecurityError */ public function checkSecurity($tags, $filters, $functions): void; /** + * @param object $obj + * @param string $method + * * @throws SecurityNotAllowedMethodError */ public function checkMethodAllowed($obj, $method): void; /** + * @param object $obj + * @param string $property + * * @throws SecurityNotAllowedPropertyError */ public function checkPropertyAllowed($obj, $property): void; diff --git a/tests/Fixtures/expressions/dot_as_concatenation.test b/tests/Fixtures/expressions/dot_as_concatenation.test new file mode 100644 index 000000000..7aa1403b6 --- /dev/null +++ b/tests/Fixtures/expressions/dot_as_concatenation.test @@ -0,0 +1,8 @@ +--TEST-- +Twig does not support using . for concatenation +--TEMPLATE-- +{{ 'a'.'b' }} +--DATA-- +return [] +--EXCEPTION-- +Twig\Error\SyntaxError: Expected name or number, got value "b" of type string in "index.twig" at line 2.