ternary_to_null_coalescing.rst 829 B

123456789101112131415161718192021222324252627282930313233
  1. ===================================
  2. Rule ``ternary_to_null_coalescing``
  3. ===================================
  4. Use ``null`` coalescing operator ``??`` where possible. Requires PHP >= 7.0.
  5. Examples
  6. --------
  7. Example #1
  8. ~~~~~~~~~~
  9. .. code-block:: diff
  10. --- Original
  11. +++ New
  12. <?php
  13. -$sample = isset($a) ? $a : $b;
  14. +$sample = $a ?? $b;
  15. Rule sets
  16. ---------
  17. The rule is part of the following rule sets:
  18. - `@PHP70Migration <./../../ruleSets/PHP70Migration.rst>`_
  19. - `@PHP71Migration <./../../ruleSets/PHP71Migration.rst>`_
  20. - `@PHP73Migration <./../../ruleSets/PHP73Migration.rst>`_
  21. - `@PHP74Migration <./../../ruleSets/PHP74Migration.rst>`_
  22. - `@PHP80Migration <./../../ruleSets/PHP80Migration.rst>`_
  23. - `@PHP81Migration <./../../ruleSets/PHP81Migration.rst>`_
  24. - `@PHP82Migration <./../../ruleSets/PHP82Migration.rst>`_