Skip to content

Commit

Permalink
fix: ClassKeywordFixer must run before `FullyQualifiedStrictTypesFi…
Browse files Browse the repository at this point in the history
…xer` (PHP-CS-Fixer#7767)

Co-authored-by: Greg Korba <greg@codito.dev>
  • Loading branch information
2 people authored and danog committed Feb 2, 2024
1 parent bffaf46 commit 9dc4adc
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Fixer/Import/FullyQualifiedStrictTypesFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public function foo(): \Other\FunctionReturnType
* {@inheritdoc}
*
* Must run before NoSuperfluousPhpdocTagsFixer, OrderedImportsFixer, OrderedInterfacesFixer, StatementIndentationFixer.
* Must run after PhpdocToReturnTypeFixer.
* Must run after ClassKeywordFixer, PhpdocToReturnTypeFixer.
*/
public function getPriority(): int
{
Expand Down
10 changes: 10 additions & 0 deletions src/Fixer/LanguageConstruct/ClassKeywordFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ public function getDefinition(): FixerDefinitionInterface
);
}

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

public function isCandidate(Tokens $tokens): bool
{
return true;
Expand Down
3 changes: 3 additions & 0 deletions tests/AutoReview/FixerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,9 @@ private static function getFixersPriorityGraph(): array
'braces',
'single_line_empty_body',
],
'class_keyword' => [
'fully_qualified_strict_types',
],
'class_keyword_remove' => [
'no_unused_imports',
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
Integration of fixers: class_keyword,fully_qualified_strict_types.
--RULESET--
{"class_keyword": true, "fully_qualified_strict_types": {"import_symbols": true}}
--EXPECT--
<?php

use PhpCsFixer\Fixer\FixerInterface;
echo FixerInterface::class;

--INPUT--
<?php

echo 'PhpCsFixer\Fixer\FixerInterface';

0 comments on commit 9dc4adc

Please sign in to comment.