no_unneeded_curly_braces.rst 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. =================================
  2. Rule ``no_unneeded_curly_braces``
  3. =================================
  4. Removes unneeded curly braces that are superfluous and aren't part of a control
  5. structure's body.
  6. Configuration
  7. -------------
  8. ``namespaces``
  9. ~~~~~~~~~~~~~~
  10. Remove unneeded curly braces from bracketed namespaces.
  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. +<?php
  23. echo 1;
  24. -}
  25. +
  26. switch ($b) {
  27. - case 1: {
  28. + case 1:
  29. break;
  30. - }
  31. +
  32. }
  33. Example #2
  34. ~~~~~~~~~~
  35. With configuration: ``['namespaces' => true]``.
  36. .. code-block:: diff
  37. --- Original
  38. +++ New
  39. <?php
  40. -namespace Foo {
  41. +namespace Foo;
  42. function Bar(){}
  43. -}
  44. +
  45. Rule sets
  46. ---------
  47. The rule is part of the following rule sets:
  48. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_ with config:
  49. ``['namespaces' => true]``
  50. - `@Symfony <./../../ruleSets/Symfony.rst>`_ with config:
  51. ``['namespaces' => true]``