Merge branch '2.x' into 3.x

* 2.x:
  Add a test
  Added token type and value to error message
  Add phpdoc to SecurityPolicyInterface
This commit is contained in:
Fabien Potencier
2022-03-25 09:18:59 +01:00
3 changed files with 19 additions and 1 deletions
+1 -1
View File
@@ -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'))) {
+10
View File
@@ -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;
@@ -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.