mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-05 15:07:11 +00:00
minor #3008 Tweak an error message (fabpot)
This PR was merged into the 1.x branch.
Discussion
----------
Tweak an error message
Commits
-------
19164de7 tweaked error messages
This commit is contained in:
+3
-2
@@ -97,9 +97,10 @@ class TokenStream
|
||||
$token = $this->tokens[$this->current];
|
||||
if (!$token->test($type, $value)) {
|
||||
$line = $token->getLine();
|
||||
throw new SyntaxError(sprintf('%sUnexpected token "%s" of value "%s" ("%s" expected%s).',
|
||||
throw new SyntaxError(sprintf('%sUnexpected token "%s"%s ("%s" expected%s).',
|
||||
$message ? $message.'. ' : '',
|
||||
Token::typeToEnglish($token->getType()), $token->getValue(),
|
||||
Token::typeToEnglish($token->getType()),
|
||||
$token->getValue() ? sprintf(' of value "%s"', $token->getValue()) : '',
|
||||
Token::typeToEnglish($type), $value ? sprintf(' with value "%s"', $value) : ''),
|
||||
$line,
|
||||
$this->source
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
--TEST--
|
||||
"from" tag with syntax error
|
||||
--TEMPLATE--
|
||||
{% from 'forms.twig' %}
|
||||
--DATA--
|
||||
return []
|
||||
--EXCEPTION--
|
||||
Twig\Error\SyntaxError: Unexpected token "end of statement block" ("name" expected with value "import") in "index.twig" at line 2.
|
||||
@@ -2,7 +2,6 @@
|
||||
"from" tag with reserved name
|
||||
--TEMPLATE--
|
||||
{% from 'forms.twig' import templateName %}
|
||||
--TEMPLATE(forms.twig)--
|
||||
--DATA--
|
||||
return []
|
||||
--EXCEPTION--
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
--TEST--
|
||||
"import" tag with reserved name
|
||||
--TEMPLATE--
|
||||
{% import 'forms.twig' %}
|
||||
|
||||
{{ macros.parent() }}
|
||||
--DATA--
|
||||
return []
|
||||
--EXCEPTION--
|
||||
Twig\Error\SyntaxError: Unexpected token "end of statement block" ("name" expected with value "as") in "index.twig" at line 2.
|
||||
-1
@@ -4,7 +4,6 @@
|
||||
{% import 'forms.twig' as macros %}
|
||||
|
||||
{{ macros.parent() }}
|
||||
--TEMPLATE(forms.twig)--
|
||||
--DATA--
|
||||
return []
|
||||
--EXCEPTION--
|
||||
Reference in New Issue
Block a user