Skip to content

Commit 698ae45

Browse files
committed
Minor tweaks
1 parent 3cc1163 commit 698ae45

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

components/expression_language/syntax.rst

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,18 +343,23 @@ Ternary Operators
343343
* ``foo ?: 'no'`` (equal to ``foo ? foo : 'no'``)
344344
* ``foo ? 'yes'`` (equal to ``foo ? 'yes' : ''``)
345345

346-
Null-coalescing Operator
346+
Null Coalescing Operator
347347
~~~~~~~~~~~~~~~~~~~~~~~~
348348

349-
This is the same as the PHP's null-coalescing operator ``??`` which is a syntactic sugar for the use of a ternary
350-
in conjunction with isset(). It returns the left hand-side if it exist and not ``null`` otherwise it returns the right hand-side.
351-
Note that coalescing can be chained.
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.
352353

353354
* ``foo ?? 'no'``
354355
* ``foo.baz ?? 'no'``
355356
* ``foo[3] ?? 'no'``
356357
* ``foo.baz ?? foo['baz'] ?? 'no'``
357358

359+
.. versionadded:: 6.2
360+
361+
The null-coalescing operator was introduced in Symfony 6.2.
362+
358363
Built-in Objects and Variables
359364
------------------------------
360365

@@ -365,3 +370,5 @@ expressions (e.g. the request, the current user, etc.):
365370
* :doc:`Variables available in security expressions </security/expressions>`;
366371
* :doc:`Variables available in service container expressions </service_container/expression_language>`;
367372
* :ref:`Variables available in routing expressions <routing-matching-expressions>`.
373+
374+
.. _`null-coalescing operator`: https://www.php.net/manual/en/language.operators.comparison.php#language.operators.comparison.coalesce

0 commit comments

Comments
 (0)