single_line_empty_body.rst 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. ===============================
  2. Rule ``single_line_empty_body``
  3. ===============================
  4. Empty body of class, interface, trait, enum or function must be abbreviated as
  5. ``{}`` and placed on the same line as the previous symbol, separated by a single
  6. space.
  7. Examples
  8. --------
  9. Example #1
  10. ~~~~~~~~~~
  11. .. code-block:: diff
  12. --- Original
  13. +++ New
  14. <?php function foo(
  15. int $x
  16. -)
  17. -{
  18. -}
  19. +) {}
  20. Rule sets
  21. ---------
  22. The rule is part of the following rule sets:
  23. - `@PER <./../../ruleSets/PER.rst>`_
  24. - `@PER-CS <./../../ruleSets/PER-CS.rst>`_
  25. - `@PER-CS2.0 <./../../ruleSets/PER-CS2.0.rst>`_
  26. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  27. References
  28. ----------
  29. - Fixer class: `PhpCsFixer\\Fixer\\Basic\\SingleLineEmptyBodyFixer <./../../../src/Fixer/Basic/SingleLineEmptyBodyFixer.php>`_
  30. - Test class: `PhpCsFixer\\Tests\\Fixer\\Basic\\SingleLineEmptyBodyFixerTest <./../../../tests/Fixer/Basic/SingleLineEmptyBodyFixerTest.php>`_
  31. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.