File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
components/expression_language Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -343,6 +343,23 @@ Ternary Operators
343343* ``foo ?: 'no' `` (equal to ``foo ? foo : 'no' ``)
344344* ``foo ? 'yes' `` (equal to ``foo ? 'yes' : '' ``)
345345
346+ Null Coalescing Operator
347+ ~~~~~~~~~~~~~~~~~~~~~~~~
348+
349+ This is the same as the PHP `null-coalescing operator `_, which combines
350+ the ternary operator and ``isset() ``. It returns the left hand-side if it exists
351+ and it's not ``null ``; otherwise it returns the right hand-side. Note that you
352+ can chain multiple coalescing operators.
353+
354+ * ``foo ?? 'no' ``
355+ * ``foo.baz ?? 'no' ``
356+ * ``foo[3] ?? 'no' ``
357+ * ``foo.baz ?? foo['baz'] ?? 'no' ``
358+
359+ .. versionadded :: 6.2
360+
361+ The null-coalescing operator was introduced in Symfony 6.2.
362+
346363Built-in Objects and Variables
347364------------------------------
348365
You can’t perform that action at this time.
0 commit comments