Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: PSR12 - configure unary_operator_spaces #7388

Merged
merged 2 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3423,7 +3423,7 @@ List of Available Rules

Unary operators should be placed adjacent to their operands.

Part of rule sets `@PhpCsFixer <./ruleSets/PhpCsFixer.rst>`_ `@Symfony <./ruleSets/Symfony.rst>`_
Part of rule sets `@PER <./ruleSets/PER.rst>`_ `@PER-CS <./ruleSets/PER-CS.rst>`_ `@PER-CS1.0 <./ruleSets/PER-CS1.0.rst>`_ `@PER-CS2.0 <./ruleSets/PER-CS2.0.rst>`_ `@PSR12 <./ruleSets/PSR12.rst>`_ `@PhpCsFixer <./ruleSets/PhpCsFixer.rst>`_ `@Symfony <./ruleSets/Symfony.rst>`_

`Source PhpCsFixer\\Fixer\\Operator\\UnaryOperatorSpacesFixer <./../src/Fixer/Operator/UnaryOperatorSpacesFixer.php>`_
- `use_arrow_functions <./rules/function_notation/use_arrow_functions.rst>`_
Expand Down
1 change: 1 addition & 0 deletions doc/ruleSets/PSR12.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ Rules

- `single_trait_insert_per_statement <./../rules/class_notation/single_trait_insert_per_statement.rst>`_
- `ternary_operator_spaces <./../rules/operator/ternary_operator_spaces.rst>`_
- `unary_operator_spaces <./../rules/operator/unary_operator_spaces.rst>`_
- `visibility_required <./../rules/class_notation/visibility_required.rst>`_
1 change: 0 additions & 1 deletion doc/ruleSets/Symfony.rst
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,5 @@ Rules
- `trim_array_spaces <./../rules/array_notation/trim_array_spaces.rst>`_
- `type_declaration_spaces <./../rules/whitespace/type_declaration_spaces.rst>`_
- `types_spaces <./../rules/whitespace/types_spaces.rst>`_
- `unary_operator_spaces <./../rules/operator/unary_operator_spaces.rst>`_
- `whitespace_after_comma_in_array <./../rules/array_notation/whitespace_after_comma_in_array.rst>`_
- `yoda_style <./../rules/control_structure/yoda_style.rst>`_
5 changes: 5 additions & 0 deletions doc/rules/operator/unary_operator_spaces.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ Rule sets

The rule is part of the following rule sets:

- `@PER <./../../ruleSets/PER.rst>`_
- `@PER-CS <./../../ruleSets/PER-CS.rst>`_
- `@PER-CS1.0 <./../../ruleSets/PER-CS1.0.rst>`_
- `@PER-CS2.0 <./../../ruleSets/PER-CS2.0.rst>`_
- `@PSR12 <./../../ruleSets/PSR12.rst>`_
- `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
- `@Symfony <./../../ruleSets/Symfony.rst>`_

2 changes: 2 additions & 0 deletions src/Fixer/Operator/UnaryOperatorSpacesFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
use PhpCsFixer\Tokenizer\TokensAnalyzer;

/**
* Fixer for rules defined in PSR12 ¶6.1.
*
* @author Gregor Harlan <gharlan@web.de>
*/
final class UnaryOperatorSpacesFixer extends AbstractFixer
Expand Down
1 change: 1 addition & 0 deletions src/RuleSet/Sets/PSR12Set.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public function getRules(): array
'single_import_per_statement' => ['group_to_single_imports' => false],
'single_trait_insert_per_statement' => true,
'ternary_operator_spaces' => true,
'unary_operator_spaces' => true,
'visibility_required' => true,
];
}
Expand Down
1 change: 0 additions & 1 deletion src/RuleSet/Sets/SymfonySet.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ public function getRules(): array
'trim_array_spaces' => true,
'type_declaration_spaces' => true,
'types_spaces' => true,
'unary_operator_spaces' => true,
'whitespace_after_comma_in_array' => true,
'yoda_style' => true,
];
Expand Down
2 changes: 2 additions & 0 deletions tests/Fixtures/Integration/set/@PSR12_php70.test-in.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

function foo() : void
{
$a =& $b;
$c = & $d;
}

$class = new class() {};
2 changes: 2 additions & 0 deletions tests/Fixtures/Integration/set/@PSR12_php70.test-out.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

function foo(): void
{
$a = &$b;
$c = &$d;
}

$class = new class () {};