spaces_inside_parentheses.rst 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. ==================================
  2. Rule ``spaces_inside_parentheses``
  3. ==================================
  4. Parentheses must be declared using the configured whitespace.
  5. Description
  6. -----------
  7. By default there are not any additional spaces inside parentheses, however with
  8. ``space=single`` configuration option whitespace inside parentheses will be
  9. unified to single space.
  10. Configuration
  11. -------------
  12. ``space``
  13. ~~~~~~~~~
  14. Whether to have ``single`` or ``none`` space inside parentheses.
  15. Allowed values: ``'none'`` and ``'single'``
  16. Default value: ``'none'``
  17. Examples
  18. --------
  19. Example #1
  20. ~~~~~~~~~~
  21. *Default* configuration.
  22. .. code-block:: diff
  23. --- Original
  24. +++ New
  25. <?php
  26. -if ( $a ) {
  27. - foo( );
  28. +if ($a) {
  29. + foo();
  30. }
  31. Example #2
  32. ~~~~~~~~~~
  33. With configuration: ``['space' => 'none']``.
  34. .. code-block:: diff
  35. --- Original
  36. +++ New
  37. <?php
  38. -function foo( $bar, $baz )
  39. +function foo($bar, $baz)
  40. {
  41. }
  42. Example #3
  43. ~~~~~~~~~~
  44. With configuration: ``['space' => 'single']``.
  45. .. code-block:: diff
  46. --- Original
  47. +++ New
  48. <?php
  49. -if ($a) {
  50. - foo( );
  51. +if ( $a ) {
  52. + foo();
  53. }
  54. Example #4
  55. ~~~~~~~~~~
  56. With configuration: ``['space' => 'single']``.
  57. .. code-block:: diff
  58. --- Original
  59. +++ New
  60. <?php
  61. -function foo($bar, $baz)
  62. +function foo( $bar, $baz )
  63. {
  64. }
  65. Rule sets
  66. ---------
  67. The rule is part of the following rule sets:
  68. - `@PER <./../../ruleSets/PER.rst>`_
  69. - `@PER-CS <./../../ruleSets/PER-CS.rst>`_
  70. - `@PER-CS1.0 <./../../ruleSets/PER-CS1.0.rst>`_
  71. - `@PER-CS2.0 <./../../ruleSets/PER-CS2.0.rst>`_
  72. - `@PSR2 <./../../ruleSets/PSR2.rst>`_
  73. - `@PSR12 <./../../ruleSets/PSR12.rst>`_
  74. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  75. - `@Symfony <./../../ruleSets/Symfony.rst>`_
  76. References
  77. ----------
  78. - Fixer class: `PhpCsFixer\\Fixer\\Whitespace\\SpacesInsideParenthesesFixer <./../../../src/Fixer/Whitespace/SpacesInsideParenthesesFixer.php>`_
  79. - Test class: `PhpCsFixer\\Tests\\Fixer\\Whitespace\\SpacesInsideParenthesesFixerTest <./../../../tests/Fixer/Whitespace/SpacesInsideParenthesesFixerTest.php>`_
  80. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.