=============================== Rule ``binary_operator_spaces`` =============================== Binary operators should be surrounded by space as configured. Configuration ------------- ``default`` ~~~~~~~~~~~ Default fix strategy. Allowed values: ``'align'``, ``'align_by_scope'``, ``'align_single_space'``, ``'align_single_space_by_scope'``, ``'align_single_space_minimal'``, ``'align_single_space_minimal_by_scope'``, ``'at_least_single_space'``, ``'no_space'``, ``'single_space'`` and ``null`` Default value: ``'single_space'`` ``operators`` ~~~~~~~~~~~~~ Dictionary of ``binary operator`` => ``fix strategy`` values that differ from the default strategy. Supported are: ``=``, ``*``, ``/``, ``%``, ``<``, ``>``, ``|``, ``^``, ``+``, ``-``, ``&``, ``&=``, ``&&``, ``||``, ``.=``, ``/=``, ``=>``, ``==``, ``>=``, ``===``, ``!=``, ``<>``, ``!==``, ``<=``, ``and``, ``or``, ``xor``, ``-=``, ``%=``, ``*=``, ``|=``, ``+=``, ``<<``, ``<<=``, ``>>``, ``>>=``, ``^=``, ``**``, ``**=``, ``<=>``, ``??`` and ``??=``. Allowed types: ``array`` Default value: ``[]`` Examples -------- Example #1 ~~~~~~~~~~ *Default* configuration. .. code-block:: diff --- Original +++ New ['=' => 'align', 'xor' => null]]``. .. code-block:: diff --- Original +++ New ['+=' => 'align_single_space']]``. .. code-block:: diff --- Original +++ New ['===' => 'align_single_space_minimal']]``. .. code-block:: diff --- Original +++ New ['|' => 'no_space']]``. .. code-block:: diff --- Original +++ New ['=>' => 'single_space']]``. .. code-block:: diff --- Original +++ New 1, - "baaaaaaaaaaar" => 11, + "foo" => 1, + "baaaaaaaaaaar" => 11, ]; Example #7 ~~~~~~~~~~ With configuration: ``['operators' => ['=>' => 'align']]``. .. code-block:: diff --- Original +++ New 12, + "foo" => 12, "baaaaaaaaaaar" => 13, "baz" => 1, ]; Example #8 ~~~~~~~~~~ With configuration: ``['operators' => ['=>' => 'align_by_scope']]``. .. code-block:: diff --- Original +++ New 12, + "foo" => 12, "baaaaaaaaaaar" => 13, - "baz" => 1, + "baz" => 1, ]; Example #9 ~~~~~~~~~~ With configuration: ``['operators' => ['=>' => 'align_single_space']]``. .. code-block:: diff --- Original +++ New 12, + "foo" => 12, "baaaaaaaaaaar" => 13, "baz" => 1, ]; Example #10 ~~~~~~~~~~~ With configuration: ``['operators' => ['=>' => 'align_single_space_by_scope']]``. .. code-block:: diff --- Original +++ New 12, + "foo" => 12, "baaaaaaaaaaar" => 13, - "baz" => 1, + "baz" => 1, ]; Example #11 ~~~~~~~~~~~ With configuration: ``['operators' => ['=>' => 'align_single_space_minimal']]``. .. code-block:: diff --- Original +++ New 12, - "baaaaaaaaaaar" => 13, + "foo" => 12, + "baaaaaaaaaaar" => 13, "baz" => 1, ]; Example #12 ~~~~~~~~~~~ With configuration: ``['operators' => ['=>' => 'align_single_space_minimal_by_scope']]``. .. code-block:: diff --- Original +++ New 12, - "baaaaaaaaaaar" => 13, + "foo" => 12, + "baaaaaaaaaaar" => 13, - "baz" => 1, + "baz" => 1, ]; Rule sets --------- The rule is part of the following rule sets: - `@PER <./../../ruleSets/PER.rst>`_ with config: ``['default' => 'at_least_single_space']`` - `@PER-CS1.0 <./../../ruleSets/PER-CS1.0.rst>`_ with config: ``['default' => 'at_least_single_space']`` - `@PER-CS2.0 <./../../ruleSets/PER-CS2.0.rst>`_ with config: ``['default' => 'at_least_single_space']`` - `@PSR12 <./../../ruleSets/PSR12.rst>`_ with config: ``['default' => 'at_least_single_space']`` - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_ - `@Symfony <./../../ruleSets/Symfony.rst>`_