|
12 | 12 | require_once __DIR__ . '/.dev-tools/vendor/autoload.php'; |
13 | 13 | require_once __DIR__ . '/vendor/autoload.php'; |
14 | 14 |
|
| 15 | +use PhpCsFixer\Config; |
| 16 | +use PhpCsFixer\Finder; |
| 17 | +use PhpCsFixer\Fixer\DeprecatedFixerInterface; |
| 18 | +use PhpCsFixerConfig\Rules\LibraryRules; |
| 19 | +use PhpCsFixerCustomFixers\Fixer\NoSuperfluousConcatenationFixer; |
| 20 | +use PhpCsFixerCustomFixers\Fixer\PhpdocOnlyAllowedAnnotationsFixer; |
| 21 | +use PhpCsFixerCustomFixers\Fixer\PromotedConstructorPropertyFixer; |
| 22 | +use PhpCsFixerCustomFixers\Fixers; |
| 23 | + |
15 | 24 | // sanity check |
16 | 25 | $expectedPath = realpath(__DIR__ . '/src/Fixers.php'); |
17 | | -$actualPath = (new ReflectionClass(PhpCsFixerCustomFixers\Fixers::class))->getFileName(); |
| 26 | +$actualPath = (new ReflectionClass(Fixers::class))->getFileName(); |
18 | 27 | if ($expectedPath !== $actualPath) { |
19 | 28 | printf( |
20 | 29 | 'Class %s must be loaded from "%s", but loaded from "%s"!' . PHP_EOL, |
21 | | - PhpCsFixerCustomFixers\Fixers::class, |
| 30 | + Fixers::class, |
22 | 31 | $expectedPath, |
23 | 32 | $actualPath, |
24 | 33 | ); |
25 | 34 | exit(1); |
26 | 35 | } |
27 | 36 |
|
28 | | -$rules = (new PhpCsFixerConfig\Rules\LibraryRules('PHP CS Fixer: custom fixers', 'Kuba Werłos', 2018))->getRules(); |
| 37 | +$rules = (new LibraryRules('PHP CS Fixer: custom fixers', 'Kuba Werłos', 2018))->getRules(); |
29 | 38 |
|
30 | | -$rules[PhpCsFixerCustomFixers\Fixer\NoSuperfluousConcatenationFixer::name()] = ['allow_preventing_trailing_spaces' => true]; |
| 39 | +$rules[NoSuperfluousConcatenationFixer::name()] = ['allow_preventing_trailing_spaces' => true]; |
31 | 40 |
|
32 | 41 | // add new fixers that are not in PhpCsFixerConfig yet |
33 | | -foreach (new PhpCsFixerCustomFixers\Fixers() as $fixer) { |
34 | | - if ($fixer instanceof PhpCsFixer\Fixer\DeprecatedFixerInterface) { |
| 42 | +foreach (new Fixers() as $fixer) { |
| 43 | + if ($fixer instanceof DeprecatedFixerInterface) { |
35 | 44 | continue; |
36 | 45 | } |
37 | 46 | if (!array_key_exists($fixer->getName(), $rules)) { |
|
42 | 51 | unset($rules['assign_null_coalescing_to_coalesce_equal']); // TODO: remove when dropping support to PHP <8.0 |
43 | 52 | unset($rules['get_class_to_class_keyword']); // TODO: remove when dropping support to PHP <8.0 |
44 | 53 | unset($rules['modernize_strpos']); // TODO: remove when dropping support to PHP <8.0 |
45 | | -unset($rules[PhpCsFixerCustomFixers\Fixer\PromotedConstructorPropertyFixer::name()]); // TODO: remove when dropping support to PHP <8.0 |
| 54 | +unset($rules['php_unit_attributes']); // TODO: remove when dropping support to PHP <8.0 |
| 55 | +unset($rules[PromotedConstructorPropertyFixer::name()]); // TODO: remove when dropping support to PHP <8.0 |
46 | 56 | $rules['trailing_comma_in_multiline'] = ['after_heredoc' => true, 'elements' => ['arguments', 'arrays']]; // TODO: remove when dropping support to PHP <8.0 |
47 | 57 |
|
48 | | -$rules[PhpCsFixerCustomFixers\Fixer\PhpdocOnlyAllowedAnnotationsFixer::name()]['elements'][] = 'phpstan-type'; |
| 58 | +$rules[PhpdocOnlyAllowedAnnotationsFixer::name()]['elements'][] = 'phpstan-type'; |
49 | 59 |
|
50 | 60 | foreach (new PhpCsFixerCustomFixersDev\Fixers() as $fixer) { |
51 | 61 | $rules[$fixer->getName()] = true; |
52 | 62 | } |
53 | 63 |
|
54 | | -return (new PhpCsFixer\Config()) |
55 | | - ->registerCustomFixers(new PhpCsFixerCustomFixers\Fixers()) |
| 64 | +return (new Config()) |
| 65 | + ->registerCustomFixers(new Fixers()) |
56 | 66 | ->registerCustomFixers(new PhpCsFixerCustomFixersDev\Fixers()) |
57 | 67 | ->setRiskyAllowed(true) |
58 | 68 | ->setUsingCache(false) |
59 | 69 | ->setFinder( |
60 | | - PhpCsFixer\Finder::create() |
| 70 | + Finder::create() |
61 | 71 | ->ignoreDotFiles(false) |
62 | 72 | ->in(__DIR__), |
63 | 73 | ) |
|
0 commit comments