-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[ExpressionLanguage] Add Parser->parseWithoutContext
#50144
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] Add Parser->parseWithoutContext
#50144
Conversation
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
Parser->parseWithoutContext
Parser->parseWithoutContext
Hey! Thanks for your PR. You are targeting branch "6.3" but it seems your PR description refers to branch "6.3 for features / 5.4 or 6.2 for bug fixes". Cheers! Carsonbot |
cf5cb7f
to
a2ca917
Compare
Parser->parseWithoutContext
Parser->parseWithoutContext
|
Parser->parseWithoutContext
Parser->parseWithoutContext
a2ca917
to
b58cff5
Compare
I just rebased this Pull Request to latest upstream changes, it is ready for review. |
@stof Can you review this please ? Note: Sorry for the ping, but it seems you reviewed another PR about ExpressionLanguage and it looks like fabbot is not assigning anyone (is it supposed to?). |
@fabpot Is there any chance you could assign someone to my PR ? Or tell me what I am missing ? Note: Sorry for the ping but I still have no human feedback while my PR is ready for review. |
b58cff5
to
15ce692
Compare
Psalm reports the method as I could not find any |
It looks like your use case sits between lint() and parse(). A lint() that returns, or a parse that doesn't validate the variables 🤷♂️ I'm not sure adding a third method is the good move 🤔 Maybe we could "change" lint() return type (since it's void) and starts returning the node? |
See #53806 for an alternative implementation. |
Closing in favor of #53806 |
…arsing/linting methods (fabpot) This PR was merged into the 7.1 branch. Discussion ---------- [ExpressionLanguage] Add more configurability to the parsing/linting methods | Q | A | ------------- | --- | Branch? | 7.1 | Bug fix? | no | New feature? | yes | Deprecations? | yes | Issues | Fixes #50144 | License | MIT When linting/parsing an expression, two kinds of errors can be thrown: a syntax error (for which the parser cannot recover) or an unknown variable/function error (which does not block the parser). When linting an expression, currently you can ignore unknown variables by passing `null` instead of the valid variable names to `lint()` or `parse()`, but you cannot ignore unknown functions. For some use cases, it might be needed to just validate the syntax. This PR allows developers to ignore functions and/or variables the "proper way" with flags as a new argument to these methods: ```php $parser->lint($expr, flags: Parser::IGNORE_UNKNOWN_FUNCTIONS | Parser::IGNORE_UNKNOWN_VARIABLES); $parser->parse($expr, flags: Parser::IGNORE_UNKNOWN_FUNCTIONS | Parser::IGNORE_UNKNOWN_VARIABLES); ``` Passing `null` to the `$names` argument is deprecated: **Before**: ```php $parser->lint($expr, null); ``` **After**: ```php $parser->lint($expr, flags: Parser::IGNORE_UNKNOWN_VARIABLES); ``` Commits ------- c6182c0 [ExpressionLanguage] Add more configurability to the parsing/linting methods
Parser->parseWithoutContext
symfony-docs#18298)Code snippet
Let say we want to check that all our
#[Security]
attributes have anis_granted
call with a subject given.Note that the following example is for illustration purpose and does not really handle all possible outcomes (for instance
is_granted(.., ..) || is_granted(.., ..)
.Other use cases may involve: