assign_null_coalescing_to_coalesce_equal.rst 664 B

123456789101112131415161718192021222324252627282930
  1. =================================================
  2. Rule ``assign_null_coalescing_to_coalesce_equal``
  3. =================================================
  4. Use the null coalescing assignment operator ``??=`` where possible.
  5. Examples
  6. --------
  7. Example #1
  8. ~~~~~~~~~~
  9. .. code-block:: diff
  10. --- Original
  11. +++ New
  12. <?php
  13. -$foo = $foo ?? 1;
  14. +$foo ??= 1;
  15. Rule sets
  16. ---------
  17. The rule is part of the following rule sets:
  18. - `@PHP74Migration <./../../ruleSets/PHP74Migration.rst>`_
  19. - `@PHP80Migration <./../../ruleSets/PHP80Migration.rst>`_
  20. - `@PHP81Migration <./../../ruleSets/PHP81Migration.rst>`_
  21. - `@PHP82Migration <./../../ruleSets/PHP82Migration.rst>`_