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] Add more configurability to the parsing/linting methods #53806

Merged
merged 1 commit into from
Feb 6, 2024

Conversation

fabpot
Copy link
Member

@fabpot fabpot commented Feb 6, 2024

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:

$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:

$parser->lint($expr, null);

After:

$parser->lint($expr, flags: Parser::IGNORE_UNKNOWN_VARIABLES);

@fabpot fabpot force-pushed the expression-language-parser-flexibility branch from a4a7791 to fc571b5 Compare February 6, 2024 11:42
@fabpot fabpot force-pushed the expression-language-parser-flexibility branch from fc571b5 to 343551b Compare February 6, 2024 12:16
@fabpot fabpot force-pushed the expression-language-parser-flexibility branch from 4ec7fdb to c6182c0 Compare February 6, 2024 15:36
@fabpot fabpot merged commit 550130c into symfony:7.1 Feb 6, 2024
6 of 9 checks passed
@fabpot fabpot deleted the expression-language-parser-flexibility branch February 6, 2024 15:41
nicolas-grekas added a commit that referenced this pull request Feb 9, 2024
This PR was merged into the 7.1 branch.

Discussion
----------

[SecurityBundle] Fix failing tests

| Q             | A
| ------------- | ---
| Branch?       | 7.1
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix CI
| License       | MIT

After #53806

Commits
-------

31cf4f8 [SecurityBundle] Fix failing tests
symfony-splitter pushed a commit to symfony/security-bundle that referenced this pull request Feb 9, 2024
This PR was merged into the 7.1 branch.

Discussion
----------

[SecurityBundle] Fix failing tests

| Q             | A
| ------------- | ---
| Branch?       | 7.1
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix CI
| License       | MIT

After symfony/symfony#53806

Commits
-------

31cf4f84a8 [SecurityBundle] Fix failing tests
@fabpot fabpot mentioned this pull request May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants