attribute_empty_parentheses.rst 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. ====================================
  2. Rule ``attribute_empty_parentheses``
  3. ====================================
  4. PHP attributes declared without arguments must (not) be followed by empty
  5. parentheses.
  6. Configuration
  7. -------------
  8. ``use_parentheses``
  9. ~~~~~~~~~~~~~~~~~~~
  10. Whether attributes should be followed by parentheses or not.
  11. Allowed types: ``bool``
  12. Default value: ``false``
  13. Examples
  14. --------
  15. Example #1
  16. ~~~~~~~~~~
  17. *Default* configuration.
  18. .. code-block:: diff
  19. --- Original
  20. +++ New
  21. <?php
  22. -#[Foo()]
  23. +#[Foo]
  24. class Sample1 {}
  25. -#[Bar(), Baz()]
  26. +#[Bar, Baz]
  27. class Sample2 {}
  28. Example #2
  29. ~~~~~~~~~~
  30. With configuration: ``['use_parentheses' => true]``.
  31. .. code-block:: diff
  32. --- Original
  33. +++ New
  34. <?php
  35. -#[Foo]
  36. +#[Foo()]
  37. class Sample1 {}
  38. -#[Bar, Baz]
  39. +#[Bar(), Baz()]
  40. class Sample2 {}
  41. References
  42. ----------
  43. - Fixer class: `PhpCsFixer\\Fixer\\AttributeNotation\\AttributeEmptyParenthesesFixer <./../../../src/Fixer/AttributeNotation/AttributeEmptyParenthesesFixer.php>`_
  44. - Test class: `PhpCsFixer\\Tests\\Fixer\\AttributeNotation\\AttributeEmptyParenthesesFixerTest <./../../../tests/Fixer/AttributeNotation/AttributeEmptyParenthesesFixerTest.php>`_
  45. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.