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

fix: priority issue between array_syntax and space after rules #7324

Merged
merged 1 commit into from
Sep 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
4 changes: 2 additions & 2 deletions src/Fixer/ArrayNotation/ArraySyntaxFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ public function getDefinition(): FixerDefinitionInterface
/**
* {@inheritdoc}
*
* Must run before BinaryOperatorSpacesFixer, TernaryOperatorSpacesFixer.
* Must run before BinaryOperatorSpacesFixer, SingleSpaceAfterConstructFixer, SingleSpaceAroundConstructFixer, TernaryOperatorSpacesFixer.
*/
public function getPriority(): int
{
return 1;
return 37;
}

public function isCandidate(Tokens $tokens): bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public function getDefinition(): FixerDefinitionInterface
* {@inheritdoc}
*
* Must run before BracesFixer, FunctionDeclarationFixer.
* Must run after ModernizeStrposFixer.
* Must run after ArraySyntaxFixer, ModernizeStrposFixer.
*/
public function getPriority(): int
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ function foo() { yield from baz(); }
* {@inheritdoc}
*
* Must run before BracesFixer, FunctionDeclarationFixer, NullableTypeDeclarationFixer.
* Must run after ModernizeStrposFixer.
* Must run after ArraySyntaxFixer, ModernizeStrposFixer.
*/
public function getPriority(): int
{
Expand Down
2 changes: 2 additions & 0 deletions tests/AutoReview/FixerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ private static function getFixersPriorityGraph(): array
],
'array_syntax' => [
'binary_operator_spaces',
'single_space_after_construct',
'single_space_around_construct',
'ternary_operator_spaces',
],
'assign_null_coalescing_to_coalesce_equal' => [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
Integration of fixers: array_syntax,single_space_after_construct.
--RULESET--
{"array_syntax": {"syntax":"short"}, "single_space_after_construct": {"constructs":["return"]}}
--EXPECT--
<?php
return // stop the war
[];

--INPUT--
<?php
return array // stop the war
();
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
Integration of fixers: array_syntax,single_space_around_construct.
--RULESET--
{"array_syntax": {"syntax":"short"}, "single_space_around_construct": {"constructs_followed_by_a_single_space":["return"]}}
--EXPECT--
<?php
return // stop the war
[];

--INPUT--
<?php
return array // stop the war
();