Skip to content

Commit

Permalink
bug - Fix priority issue between array_syntax and single_space_after_…
Browse files Browse the repository at this point in the history
…construct and between array_syntax and single_space_around_construct
  • Loading branch information
SpacePossum committed Sep 26, 2023
1 parent e34645e commit 7cfd5b2
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 4 deletions.
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
();

0 comments on commit 7cfd5b2

Please sign in to comment.