no_unused_imports.rst 853 B

12345678910111213141516171819202122232425262728293031323334353637
  1. ==========================
  2. Rule ``no_unused_imports``
  3. ==========================
  4. Unused ``use`` statements must be removed.
  5. Examples
  6. --------
  7. Example #1
  8. ~~~~~~~~~~
  9. .. code-block:: diff
  10. --- Original
  11. +++ New
  12. <?php
  13. use \DateTime;
  14. -use \Exception;
  15. new DateTime();
  16. Rule sets
  17. ---------
  18. The rule is part of the following rule sets:
  19. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  20. - `@Symfony <./../../ruleSets/Symfony.rst>`_
  21. References
  22. ----------
  23. - Fixer class: `PhpCsFixer\\Fixer\\Import\\NoUnusedImportsFixer <./../../../src/Fixer/Import/NoUnusedImportsFixer.php>`_
  24. - Test class: `PhpCsFixer\\Tests\\Fixer\\Import\\NoUnusedImportsFixerTest <./../../../tests/Fixer/Import/NoUnusedImportsFixerTest.php>`_
  25. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.