assign_null_coalescing_to_coalesce_equal.rst 912 B

123456789101112131415161718192021222324252627282930313233
  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
  19. Using the `@PHP74Migration <./../../ruleSets/PHP74Migration.rst>`_ rule set will enable the ``assign_null_coalescing_to_coalesce_equal`` rule.
  20. @PHP80Migration
  21. Using the `@PHP80Migration <./../../ruleSets/PHP80Migration.rst>`_ rule set will enable the ``assign_null_coalescing_to_coalesce_equal`` rule.
  22. @PHP81Migration
  23. Using the `@PHP81Migration <./../../ruleSets/PHP81Migration.rst>`_ rule set will enable the ``assign_null_coalescing_to_coalesce_equal`` rule.