no_spaces_around_offset.rst 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. ================================
  2. Rule ``no_spaces_around_offset``
  3. ================================
  4. There MUST NOT be spaces around offset braces.
  5. Configuration
  6. -------------
  7. ``positions``
  8. ~~~~~~~~~~~~~
  9. Whether spacing should be fixed inside and/or outside the offset braces.
  10. Allowed values: a subset of ``['inside', 'outside']``
  11. Default value: ``['inside', 'outside']``
  12. Examples
  13. --------
  14. Example #1
  15. ~~~~~~~~~~
  16. *Default* configuration.
  17. .. code-block:: diff
  18. --- Original
  19. +++ New
  20. <?php
  21. -$sample = $b [ 'a' ] [ 'b' ];
  22. +$sample = $b['a']['b'];
  23. Example #2
  24. ~~~~~~~~~~
  25. With configuration: ``['positions' => ['inside']]``.
  26. .. code-block:: diff
  27. --- Original
  28. +++ New
  29. <?php
  30. -$sample = $b [ 'a' ] [ 'b' ];
  31. +$sample = $b ['a'] ['b'];
  32. Example #3
  33. ~~~~~~~~~~
  34. With configuration: ``['positions' => ['outside']]``.
  35. .. code-block:: diff
  36. --- Original
  37. +++ New
  38. <?php
  39. -$sample = $b [ 'a' ] [ 'b' ];
  40. +$sample = $b[ 'a' ][ 'b' ];
  41. Rule sets
  42. ---------
  43. The rule is part of the following rule sets:
  44. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  45. - `@Symfony <./../../ruleSets/Symfony.rst>`_
  46. References
  47. ----------
  48. - Fixer class: `PhpCsFixer\\Fixer\\Whitespace\\NoSpacesAroundOffsetFixer <./../../../src/Fixer/Whitespace/NoSpacesAroundOffsetFixer.php>`_
  49. - Test class: `PhpCsFixer\\Tests\\Fixer\\Whitespace\\NoSpacesAroundOffsetFixerTest <./../../../tests/Fixer/Whitespace/NoSpacesAroundOffsetFixerTest.php>`_
  50. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.