Skip to content

Commit

Permalink
fix: NoSpaceAroundDoubleColonFixer must run before `MethodChainingI…
Browse files Browse the repository at this point in the history
…ndentationFixer` (#7723)
  • Loading branch information
mho22 committed Jan 14, 2024
1 parent 6d57705 commit 9922e5b
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Fixer/Operator/NoSpaceAroundDoubleColonFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ public function getDefinition(): FixerDefinitionInterface
);
}

/**
* {@inheritdoc}
*
* Must run before MethodChainingIndentationFixer.
*/
public function getPriority(): int
{
return 1;
}

public function isCandidate(Tokens $tokens): bool
{
return $tokens->isTokenKindFound(T_DOUBLE_COLON);
Expand Down
10 changes: 10 additions & 0 deletions src/Fixer/Whitespace/MethodChainingIndentationFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ public function getDefinition(): FixerDefinitionInterface
);
}

/**
* {@inheritdoc}
*
* Must run after NoSpaceAroundDoubleColonFixer.
*/
public function getPriority(): int
{
return 0;
}

public function isCandidate(Tokens $tokens): bool
{
return $tokens->isAnyTokenKindsFound(Token::getObjectOperatorKinds());
Expand Down
3 changes: 3 additions & 0 deletions tests/AutoReview/FixerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,9 @@ private static function getFixersPriorityGraph(): array
'no_short_bool_cast' => [
'cast_spaces',
],
'no_space_around_double_colon' => [
'method_chaining_indentation',
],
'no_spaces_after_function_name' => [
'function_to_constant',
'get_class_to_class_keyword',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--TEST--
Integration of fixers: no_space_around_double_colon,method_chaining_indentation.
--RULESET--
{"no_space_around_double_colon": true, "method_chaining_indentation": true}
--EXPECT--
<?php

use Foo;

Foo::bar()
->baz()
->cux();

--INPUT--
<?php

use Foo;

Foo
::bar()
->baz()
->cux();

0 comments on commit 9922e5b

Please sign in to comment.