Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[ExpressionLanguage] Add support for null coalescing syntax#46142
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
[ExpressionLanguage] Add support for null coalescing syntax#46142
Uh oh!
There was an error while loading.Please reload this page.
Conversation
nicolas-grekas left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks for working on this!
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/ExpressionLanguage/Node/NullCoalesceNode.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/ExpressionLanguage/Node/NullCoalesceNode.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
nicolas-grekas left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
(please apply fabbot's path)
825d77f tofaf40dfComparenicolas-grekas commentedMay 27, 2022
kvailas commentedJul 13, 2022
Hello@nicolas-grekas , many many many thanks for working on this one! |
fabpot commentedJul 20, 2022
@kvailas Seehttps://symfony.com/doc/current/contributing/community/releases.html for more information about our release process. |
kvailas commentedJul 20, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@fabpot actually i am using the expression language library as part of anon-symfony based project. Just loading the library in order to use the expression language from its respective repo. Thanks for your input, appreciated. |
stof commentedJul 20, 2022
@kvailas this does not changewhen the releases of the components happen (btw, Symfony-based projects also download components from the subtree-split repos) |
fabpot commentedJul 20, 2022
Can you rebase on current 6.2? |
fabpot commentedJul 25, 2022
Thank you@mytuny. |
faf40df to8e3c505Comparefabpot commentedJul 25, 2022
FYI, follow-up PR here:#47058 |
| } | ||
| }; | ||
| yield ['foo.bar ?? "default"',null]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
yield foo ?? 'default' <- will be red
This is another waited feature for the syntax of the expression-language component. Thenull-coalescing operator
??becomes a need for variant programming needs these days.Following my previous PR introducing the null-safe operator (#45795). I'm hereby introducing yet another essential operator to make the syntax even more complete.
The null-coalescing operator is a syntactic sugar for a common use of ternary in conjunction with
isset()(in PHP) or equivalent in other languages. This is such a common use-case to the point that almost all majors programming syntax nowadays support a sort of a short-hand for that operation namely coalescing operator. Now it's time for the syntax of Expression-Language to do so!Expressions like:
foo.bar ?? 'default'foo[3] ?? 'default'foo.bar ?? foo['bar'] ?? 'default'will default to the expression in the right-hand-side of the
??operator whenever the expression in the left-hand-side of it does not exist or it'snull. Note that this coalescing behavior can be chained and the validation logic takes decreasing priority from left to right.