|
13 | 13 |
|
14 | 14 | use PhpCsFixer\Fixer\ConfigurableFixerInterface; |
15 | 15 | use PhpCsFixer\Fixer\DeprecatedFixerInterface; |
| 16 | +use PhpCsFixer\Fixer\FixerInterface; |
16 | 17 | use PhpCsFixer\Fixer\WhitespacesAwareFixerInterface; |
17 | 18 | use PhpCsFixer\FixerDefinition\CodeSampleInterface; |
| 19 | +use PhpCsFixer\FixerFactory; |
| 20 | +use PhpCsFixer\RuleSet\RuleSet; |
18 | 21 | use PhpCsFixer\Tokenizer\Tokens; |
19 | 22 | use PhpCsFixer\Utils; |
20 | 23 | use PhpCsFixer\WhitespacesFixerConfig; |
@@ -168,7 +171,22 @@ private static function fixers(): string |
168 | 171 | $fixer->getDefinition()->getSummary(), |
169 | 172 | ); |
170 | 173 |
|
171 | | - $output .= $fixer instanceof DeprecatedFixerInterface ? \sprintf("\n DEPRECATED: use `%s` instead.", \implode('`, `', $fixer->getSuccessorsNames())) : ''; |
| 174 | + if ($fixer instanceof DeprecatedFixerInterface) { |
| 175 | + $fixers = (new FixerFactory()) |
| 176 | + ->registerBuiltInFixers() |
| 177 | + ->registerCustomFixers(new Fixers()) |
| 178 | + ->useRuleSet(new RuleSet(\array_combine($fixer->getSuccessorsNames(), [true]))) |
| 179 | + ->getFixers(); |
| 180 | + |
| 181 | + $successors = \array_map( |
| 182 | + static fn (FixerInterface $fixer): string => $fixer instanceof AbstractFixer |
| 183 | + ? (new \ReflectionObject($fixer))->getShortName() |
| 184 | + : $fixer->getName(), |
| 185 | + $fixers, |
| 186 | + ); |
| 187 | + |
| 188 | + $output .= \sprintf("\n DEPRECATED: use `%s` instead.", \implode('`, `', $successors)); |
| 189 | + } |
172 | 190 |
|
173 | 191 | if ($fixer instanceof DataProviderStaticFixer) { |
174 | 192 | $fixer->configure(['force' => true]); |
|
0 commit comments