psr_autoloading.rst 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. ========================
  2. Rule ``psr_autoloading``
  3. ========================
  4. Classes must be in a path that matches their namespace, be at least one
  5. namespace deep and the class name should match the file name.
  6. Warning
  7. -------
  8. Using this rule is risky
  9. ~~~~~~~~~~~~~~~~~~~~~~~~
  10. This fixer may change your class name, which will break the code that depends on
  11. the old name.
  12. Configuration
  13. -------------
  14. ``dir``
  15. ~~~~~~~
  16. If provided, the directory where the project code is placed.
  17. Allowed types: ``null`` and ``string``
  18. Default value: ``null``
  19. Examples
  20. --------
  21. Example #1
  22. ~~~~~~~~~~
  23. *Default* configuration.
  24. .. code-block:: diff
  25. --- Original
  26. +++ New
  27. <?php
  28. namespace PhpCsFixer\FIXER\Basic;
  29. -class InvalidName {}
  30. +class PsrAutoloadingFixer {}
  31. Example #2
  32. ~~~~~~~~~~
  33. With configuration: ``['dir' => './src']``.
  34. .. code-block:: diff
  35. --- Original
  36. +++ New
  37. <?php
  38. -namespace PhpCsFixer\FIXER\Basic;
  39. -class InvalidName {}
  40. +namespace PhpCsFixer\Fixer\Basic;
  41. +class PsrAutoloadingFixer {}
  42. Rule sets
  43. ---------
  44. The rule is part of the following rule sets:
  45. - `@PhpCsFixer:risky <./../../ruleSets/PhpCsFixerRisky.rst>`_
  46. - `@Symfony:risky <./../../ruleSets/SymfonyRisky.rst>`_