no_unset_cast.rst 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. ======================
  2. Rule ``no_unset_cast``
  3. ======================
  4. Variables must be set ``null`` instead of using ``(unset)`` casting.
  5. Examples
  6. --------
  7. Example #1
  8. ~~~~~~~~~~
  9. .. code-block:: diff
  10. --- Original
  11. +++ New
  12. <?php
  13. -$a = (unset) $b;
  14. +$a = null;
  15. Rule sets
  16. ---------
  17. The rule is part of the following rule sets:
  18. - `@PHP80Migration <./../../ruleSets/PHP80Migration.rst>`_
  19. - `@PHP81Migration <./../../ruleSets/PHP81Migration.rst>`_
  20. - `@PHP82Migration <./../../ruleSets/PHP82Migration.rst>`_
  21. - `@PHP83Migration <./../../ruleSets/PHP83Migration.rst>`_
  22. - `@PHP84Migration <./../../ruleSets/PHP84Migration.rst>`_
  23. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  24. - `@Symfony <./../../ruleSets/Symfony.rst>`_
  25. References
  26. ----------
  27. - Fixer class: `PhpCsFixer\\Fixer\\CastNotation\\NoUnsetCastFixer <./../../../src/Fixer/CastNotation/NoUnsetCastFixer.php>`_
  28. - Test class: `PhpCsFixer\\Tests\\Fixer\\CastNotation\\NoUnsetCastFixerTest <./../../../tests/Fixer/CastNotation/NoUnsetCastFixerTest.php>`_
  29. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.