From e33f97cd8bcdedc3b0169a2b01b835724f3d797f Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Thu, 17 Mar 2022 22:53:08 +0100 Subject: [PATCH 1/3] Add phpdoc to SecurityPolicyInterface --- src/Sandbox/SecurityPolicyInterface.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Sandbox/SecurityPolicyInterface.php b/src/Sandbox/SecurityPolicyInterface.php index e9e82c965..0166f67a3 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); /** + * @param object $obj + * @param string $method + * * @throws SecurityNotAllowedMethodError */ public function checkMethodAllowed($obj, $method); /** + * @param object $obj + * @param string $property + * * @throws SecurityNotAllowedPropertyError */ public function checkPropertyAllowed($obj, $property); From 6c8da65b7432c5d5b6b7e4b3c48f097eeaed692f Mon Sep 17 00:00:00 2001 From: Kamyar Mirzavaziri Date: Fri, 11 Feb 2022 20:52:25 +0330 Subject: [PATCH 2/3] Added token type and value to error message Added the given token type and value to the error message in case that the token after '.' is neither a name nor a number. --- src/ExpressionParser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ExpressionParser.php b/src/ExpressionParser.php index 1d9c87687..b0bcf1080 100644 --- a/src/ExpressionParser.php +++ b/src/ExpressionParser.php @@ -488,7 +488,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'))) { From beea1a7c4ae995d5bb01446ab0bea8d8fa22bcbf Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 25 Mar 2022 09:18:53 +0100 Subject: [PATCH 3/3] Add a test --- tests/Fixtures/expressions/dot_as_concatenation.test | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 tests/Fixtures/expressions/dot_as_concatenation.test 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.