From 9922e5ba3f82344cee099ce4b0a6ae7a86a4051b Mon Sep 17 00:00:00 2001 From: MHO <17177411+mho22@users.noreply.github.com> Date: Sun, 14 Jan 2024 16:47:05 +0100 Subject: [PATCH] fix: `NoSpaceAroundDoubleColonFixer` must run before `MethodChainingIndentationFixer` (#7723) --- .../NoSpaceAroundDoubleColonFixer.php | 10 +++++++++ .../MethodChainingIndentationFixer.php | 10 +++++++++ tests/AutoReview/FixerFactoryTest.php | 3 +++ ...ble_colon,method_chaining_indentation.test | 22 +++++++++++++++++++ 4 files changed, 45 insertions(+) create mode 100644 tests/Fixtures/Integration/priority/no_space_around_double_colon,method_chaining_indentation.test diff --git a/src/Fixer/Operator/NoSpaceAroundDoubleColonFixer.php b/src/Fixer/Operator/NoSpaceAroundDoubleColonFixer.php index ddf0c2dfd0a..d897fff5954 100644 --- a/src/Fixer/Operator/NoSpaceAroundDoubleColonFixer.php +++ b/src/Fixer/Operator/NoSpaceAroundDoubleColonFixer.php @@ -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); diff --git a/src/Fixer/Whitespace/MethodChainingIndentationFixer.php b/src/Fixer/Whitespace/MethodChainingIndentationFixer.php index 2830246a50c..dc7fff6eab0 100644 --- a/src/Fixer/Whitespace/MethodChainingIndentationFixer.php +++ b/src/Fixer/Whitespace/MethodChainingIndentationFixer.php @@ -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()); diff --git a/tests/AutoReview/FixerFactoryTest.php b/tests/AutoReview/FixerFactoryTest.php index 0277a5b5486..f7ac929e750 100644 --- a/tests/AutoReview/FixerFactoryTest.php +++ b/tests/AutoReview/FixerFactoryTest.php @@ -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', diff --git a/tests/Fixtures/Integration/priority/no_space_around_double_colon,method_chaining_indentation.test b/tests/Fixtures/Integration/priority/no_space_around_double_colon,method_chaining_indentation.test new file mode 100644 index 00000000000..c7f35215c9a --- /dev/null +++ b/tests/Fixtures/Integration/priority/no_space_around_double_colon,method_chaining_indentation.test @@ -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-- +baz() + ->cux(); + +--INPUT-- +baz() +->cux();