no_unneeded_curly_braces.rst 1.5 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. Warning
  7. -------
  8. This rule is deprecated and will be removed in the next major version
  9. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  10. You should use ``no_unneeded_braces`` instead.
  11. Configuration
  12. -------------
  13. ``namespaces``
  14. ~~~~~~~~~~~~~~
  15. Remove unneeded curly braces from bracketed namespaces.
  16. Allowed types: ``bool``
  17. Default value: ``false``
  18. Examples
  19. --------
  20. Example #1
  21. ~~~~~~~~~~
  22. *Default* configuration.
  23. .. code-block:: diff
  24. --- Original
  25. +++ New
  26. -<?php {
  27. +<?php
  28. echo 1;
  29. -}
  30. +
  31. switch ($b) {
  32. - case 1: {
  33. + case 1:
  34. break;
  35. - }
  36. +
  37. }
  38. Example #2
  39. ~~~~~~~~~~
  40. With configuration: ``['namespaces' => true]``.
  41. .. code-block:: diff
  42. --- Original
  43. +++ New
  44. <?php
  45. -namespace Foo {
  46. +namespace Foo;
  47. function Bar(){}
  48. -}
  49. +
  50. References
  51. ----------
  52. - Fixer class: `PhpCsFixer\\Fixer\\ControlStructure\\NoUnneededCurlyBracesFixer <./../../../src/Fixer/ControlStructure/NoUnneededCurlyBracesFixer.php>`_
  53. - Test class: `PhpCsFixer\\Tests\\Fixer\\ControlStructure\\NoUnneededCurlyBracesFixerTest <./../../../tests/Fixer/ControlStructure/NoUnneededCurlyBracesFixerTest.php>`_
  54. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.