Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ExpressionLanguage] Document precedence #19803

Open
homersimpsons opened this issue Apr 18, 2024 · 2 comments · May be fixed by #19860
Open

[ExpressionLanguage] Document precedence #19803

homersimpsons opened this issue Apr 18, 2024 · 2 comments · May be fixed by #19860

Comments

@homersimpsons
Copy link
Contributor

Current status

The page https://symfony.com/doc/current/reference/formats/expression_language.html#supported-operators does not document operators precedence.

Objective

Add documentation about operators precedence.

Why?

Today I wanted to check the precedence of some operator in order to update a code, I had an expression that could translate to the following ambiguity:

var_dump(! null === false); // => ((!null) === false) => false
var_dump(! (null === false)); // => true

We can find the precedence in https://github.com/symfony/expression-language/blob/b8ec919a6d3d47fc4e7845c256d164413207bf73/Parser.php#L24

I think that this information should be accessible in the doc directly, but I understand that it won't benefit a lot of users so I'm wondering how it should be presented. Maybe just a collapsible array at the end, or when the precedence is mentioned in:

You must use parentheses because the unary operator not has precedence over the binary operator matches.

@94noni
Copy link
Contributor

94noni commented Apr 19, 2024

A note block could be added and document this internal behavior i think yes 👍🏻

homersimpsons added a commit to homersimpsons/symfony-docs that referenced this issue May 3, 2024
@homersimpsons homersimpsons linked a pull request May 3, 2024 that will close this issue
homersimpsons added a commit to homersimpsons/symfony-docs that referenced this issue May 3, 2024
@OskarStark
Copy link
Contributor

I really like this note and we should merge it. However, what about a debug command? We have the same for listener priorities

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants