I just wrote some twig template which contained === and the parser failed:
Twig_Error_Syntax: Unexpected token "operator" of value "=" in "foo.html.twig" at line 19. in Twig_ExpressionParser->parsePrimaryExpression() (line 208 of vendor/twig/twig/lib/Twig/ExpressionParser.php).
I wonder whether twig should simply treat === as == or even provide some form of strict comparison.
=== does exist in Twig, but the name of the test is same as.
Right, I'm simply wondering whether === should be treated as "same as" automatically. I'm wondering whether its just me who is so stupid falling into that trap :)
This is really not like a feature request or so, I'm really just wondering
That's a good question and one for which we had a discussion in the past. The conclusion was that === is confusing for anyone not familiar with PHP. So, we decided to support it via same as instead.
One thing which could be done is to not support "===" but instead throw a helpful exception telling people about "same as"
That makes sense. Anyone willing to submit a PR for that? Could be done in the 1.x branch.
Absolutely
:+1: for closing PRs.
@dawehner It's not closed but merged ;)
Oh haha. Well even better :)
Most helpful comment
One thing which could be done is to not support "===" but instead throw a helpful exception telling people about "same as"