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: NoSpaceAroundDoubleColonFixer must run before MethodChainingIndentationFixer #7723

Merged
merged 5 commits into from
Jan 14, 2024
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
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();