ordered_traits.rst 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. =======================
  2. Rule ``ordered_traits``
  3. =======================
  4. Trait ``use`` statements must be sorted alphabetically.
  5. Warning
  6. -------
  7. Using this rule is risky
  8. ~~~~~~~~~~~~~~~~~~~~~~~~
  9. Risky when depending on order of the imports.
  10. Configuration
  11. -------------
  12. ``case_sensitive``
  13. ~~~~~~~~~~~~~~~~~~
  14. Whether the sorting should be case sensitive.
  15. Allowed types: ``bool``
  16. Default value: ``false``
  17. Examples
  18. --------
  19. Example #1
  20. ~~~~~~~~~~
  21. *Default* configuration.
  22. .. code-block:: diff
  23. --- Original
  24. +++ New
  25. <?php class Foo {
  26. -use Z; use A; }
  27. +use A; use Z; }
  28. Example #2
  29. ~~~~~~~~~~
  30. With configuration: ``['case_sensitive' => true]``.
  31. .. code-block:: diff
  32. --- Original
  33. +++ New
  34. <?php class Foo {
  35. -use Aaa; use AA; }
  36. +use AA; use Aaa; }
  37. Rule sets
  38. ---------
  39. The rule is part of the following rule sets:
  40. - `@PhpCsFixer:risky <./../../ruleSets/PhpCsFixerRisky.rst>`_
  41. - `@Symfony:risky <./../../ruleSets/SymfonyRisky.rst>`_
  42. References
  43. ----------
  44. - Fixer class: `PhpCsFixer\\Fixer\\ClassNotation\\OrderedTraitsFixer <./../../../src/Fixer/ClassNotation/OrderedTraitsFixer.php>`_
  45. - Test class: `PhpCsFixer\\Tests\\Fixer\\ClassNotation\\OrderedTraitsFixerTest <./../../../tests/Fixer/ClassNotation/OrderedTraitsFixerTest.php>`_
  46. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.