Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[ExpressionLanguage] Feature Null-coalescing operator#16743

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

Conversation

@mytuny
Copy link
Contributor

[ExpressionLanguage] [NEW FEATURE]

This PR introduces the support for null-coalescing operator??.

The proposed change, includes a paragraph under the sub-page /expression_language/syntax to describe the new feature usage. The sub-paragraph has a title ofNull-coalescing operator under the paragraphSupported Operators.

The actual work related to this Doc PR available as Symfony PR .

@carsonbotcarsonbot added this to the6.1 milestoneApr 22, 2022
@wouterjwouterj modified the milestones:6.1,nextMay 1, 2022
@wouterjwouterj added the Waiting Code MergeDocs for features pending to be merged labelMay 1, 2022
fabpot added a commit to symfony/symfony that referenced this pull requestJul 25, 2022
…yntax (mytuny)This PR was merged into the 6.2 branch.Discussion----------[ExpressionLanguage] Add support for null coalescing syntax| Q             | A| ------------- | ---| Branch?       | 6.1| Bug fix?      | no| New feature?  | yes| Deprecations? | no| Tickets       |Fix#45411,#21691| License       | MIT| Doc PR        |symfony/symfony-docs#16743This is another waited feature for the syntax of the expression-language component. The [null-coalescing](https://wiki.php.net/rfc/isset_ternary) 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's ``null``. Note that this coalescing behavior can be chained and the validation logic takes decreasing priority from left to right.Commits-------8e3c505 [ExpressionLanguage] Add support for null coalescing syntax
@javiereguiluzjaviereguiluz added Status: Reviewed and removed Status: Needs Review Waiting Code MergeDocs for features pending to be merged labelsJul 29, 2022
@javiereguiluzjaviereguiluz modified the milestones:next,6.2Jul 29, 2022
@javiereguiluzjaviereguiluz merged commit3cc1163 intosymfony:6.1Jul 29, 2022
@javiereguiluz
Copy link
Member

Sofien, thanks a lot for contributing this nice feature and its docs ... and congrats on your first Symfony Docs contribution 🎉

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

6.2

Development

Successfully merging this pull request may close these issues.

4 participants

@mytuny@javiereguiluz@wouterj@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp