is_null.rst 983 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. ================
  2. Rule ``is_null``
  3. ================
  4. Replaces ``is_null($var)`` expression with ``null === $var``.
  5. .. warning:: Using this rule is risky.
  6. Risky when the function ``is_null`` is overridden.
  7. Configuration
  8. -------------
  9. ``use_yoda_style``
  10. ~~~~~~~~~~~~~~~~~~
  11. .. warning:: This option is deprecated and will be removed on next major version. Use ``yoda_style`` fixer instead.
  12. Whether Yoda style conditions should be used.
  13. Allowed types: ``bool``
  14. Default value: ``true``
  15. Examples
  16. --------
  17. Example #1
  18. ~~~~~~~~~~
  19. *Default* configuration.
  20. .. code-block:: diff
  21. --- Original
  22. +++ New
  23. @@ -1,2 +1,2 @@
  24. <?php
  25. -$a = is_null($b);
  26. +$a = null === $b;
  27. Rule sets
  28. ---------
  29. The rule is part of the following rule sets:
  30. @Symfony:risky
  31. Using the ``@Symfony:risky`` rule set will enable the ``is_null`` rule with the default config.
  32. @PhpCsFixer:risky
  33. Using the ``@PhpCsFixer:risky`` rule set will enable the ``is_null`` rule with the default config.