Skip to content

Commit

Permalink
fix: FunctionToConstantFixer should run before `NativeConstantInvoc…
Browse files Browse the repository at this point in the history
…ationFixer` (PHP-CS-Fixer#7344)
  • Loading branch information
HypeMC authored Sep 29, 2023
1 parent 2f4d1a3 commit 4a8cf69
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/Fixer/ConstantNotation/NativeConstantInvocationFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,11 @@ public function getDefinition(): FixerDefinitionInterface
* {@inheritdoc}
*
* Must run before GlobalNamespaceImportFixer.
* Must run after FunctionToConstantFixer.
*/
public function getPriority(): int
{
return 10;
return 1;
}

public function isCandidate(Tokens $tokens): bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function getDefinition(): FixerDefinitionInterface
*/
public function getPriority(): int
{
return 2;
return 3;
}

public function isCandidate(Tokens $tokens): bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function getDefinition(): FixerDefinitionInterface
*/
public function getPriority(): int
{
return 3;
return 4;
}

public function isCandidate(Tokens $tokens): bool
Expand Down
4 changes: 2 additions & 2 deletions src/Fixer/LanguageConstruct/FunctionToConstantFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ public function getDefinition(): FixerDefinitionInterface
/**
* {@inheritdoc}
*
* Must run before NativeFunctionCasingFixer, NoExtraBlankLinesFixer, NoSinglelineWhitespaceBeforeSemicolonsFixer, NoTrailingWhitespaceFixer, NoWhitespaceInBlankLineFixer, SelfStaticAccessorFixer.
* Must run before NativeConstantInvocationFixer, NativeFunctionCasingFixer, NoExtraBlankLinesFixer, NoSinglelineWhitespaceBeforeSemicolonsFixer, NoTrailingWhitespaceFixer, NoWhitespaceInBlankLineFixer, SelfStaticAccessorFixer.
* Must run after NoSpacesAfterFunctionNameFixer, NoSpacesInsideParenthesisFixer, SpacesInsideParenthesesFixer.
*/
public function getPriority(): int
{
return 1;
return 2;
}

public function isCandidate(Tokens $tokens): bool
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/Whitespace/NoSpacesInsideParenthesisFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function foo( \$bar, \$baz )
*/
public function getPriority(): int
{
return 2;
return 3;
}

public function getSuccessorsNames(): array
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/Whitespace/SpacesInsideParenthesesFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function foo(\$bar, \$baz)
*/
public function getPriority(): int
{
return 2;
return 3;
}

public function isCandidate(Tokens $tokens): bool
Expand Down
1 change: 1 addition & 0 deletions tests/AutoReview/FixerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ private static function getFixersPriorityGraph(): array
'method_argument_space',
],
'function_to_constant' => [
'native_constant_invocation',
'native_function_casing',
'no_extra_blank_lines',
'no_singleline_whitespace_before_semicolons',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
Integration of fixers: function_to_constant,native_constant_invocation.
--RULESET--
{"function_to_constant": true, "native_constant_invocation": true}
--EXPECT--
<?php

echo \M_PI;

--INPUT--
<?php

echo pi();

0 comments on commit 4a8cf69

Please sign in to comment.