bug #2411 Exception for use of "===" instead of "same as" (sgotre)

This PR was squashed before being merged into the 1.x branch (closes #2411).

Discussion
----------

Exception for use of "===" instead of "same as"

As mentioned in #2358
Hope this is the right location for this Exception

Commits
-------

194d51a4 Exception for use of "===" instead of "same as"
This commit is contained in:
Fabien Potencier
2018-03-02 06:02:21 -08:00
+2
View File
@@ -204,6 +204,8 @@ class Twig_ExpressionParser
$node = $this->parseArrayExpression();
} elseif ($token->test(Twig_Token::PUNCTUATION_TYPE, '{')) {
$node = $this->parseHashExpression();
} elseif ($token->test(Twig_Token::OPERATOR_TYPE, '=') && ($this->parser->getStream()->look(-1)->getValue() === '==' || $this->parser->getStream()->look(-1)->getValue() === '!=')) {
throw new Twig_Error_Syntax(sprintf('Unexpected operator of value "%s". Did you try to use "===" or "!==" for strict comparison? Use "is same as(value)" to compare stricly.', $token->getValue()), $token->getLine(), $this->parser->getStream()->getSourceContext());
} else {
throw new Twig_Error_Syntax(sprintf('Unexpected token "%s" of value "%s".', Twig_Token::typeToEnglish($token->getType()), $token->getValue()), $token->getLine(), $this->parser->getStream()->getSourceContext());
}