-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy path.php-cs-fixer.php
74 lines (63 loc) · 2.63 KB
/
.php-cs-fixer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php declare(strict_types=1);
/*
* This file is part of PHP CS Fixer: custom fixers.
*
* (c) 2018 Kuba Werłos
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
require_once __DIR__ . '/.dev-tools/vendor/autoload.php';
require_once __DIR__ . '/vendor/autoload.php';
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
use PhpCsFixer\Fixer\DeprecatedFixerInterface;
use PhpCsFixerConfig\Rules\LibraryRules;
use PhpCsFixerCustomFixers\Fixer\NoSuperfluousConcatenationFixer;
use PhpCsFixerCustomFixers\Fixer\PhpdocOnlyAllowedAnnotationsFixer;
use PhpCsFixerCustomFixers\Fixer\PromotedConstructorPropertyFixer;
use PhpCsFixerCustomFixers\Fixers;
// sanity check
$expectedPath = realpath(__DIR__ . '/src/Fixers.php');
$actualPath = (new ReflectionClass(Fixers::class))->getFileName();
if ($expectedPath !== $actualPath) {
printf(
'Class %s must be loaded from "%s", but loaded from "%s"!' . PHP_EOL,
Fixers::class,
$expectedPath,
$actualPath,
);
exit(1);
}
$rules = (new LibraryRules('PHP CS Fixer: custom fixers', 'Kuba Werłos', 2018))->getRules();
$rules[NoSuperfluousConcatenationFixer::name()] = ['allow_preventing_trailing_spaces' => true];
// add new fixers that are not in PhpCsFixerConfig yet
foreach (new Fixers() as $fixer) {
if ($fixer instanceof DeprecatedFixerInterface) {
continue;
}
if (!array_key_exists($fixer->getName(), $rules)) {
$rules[$fixer->getName()] = true;
}
}
unset($rules['assign_null_coalescing_to_coalesce_equal']); // TODO: remove when dropping support to PHP <8.0
unset($rules['get_class_to_class_keyword']); // TODO: remove when dropping support to PHP <8.0
unset($rules['modernize_strpos']); // TODO: remove when dropping support to PHP <8.0
unset($rules['php_unit_attributes']); // TODO: remove when dropping support to PHP <8.0
unset($rules[PromotedConstructorPropertyFixer::name()]); // TODO: remove when dropping support to PHP <8.0
$rules['trailing_comma_in_multiline'] = ['after_heredoc' => true, 'elements' => ['arguments', 'arrays']]; // TODO: remove when dropping support to PHP <8.0
$rules[PhpdocOnlyAllowedAnnotationsFixer::name()]['elements'][] = 'phpstan-type';
foreach (new PhpCsFixerCustomFixersDev\Fixers() as $fixer) {
$rules[$fixer->getName()] = true;
}
return (new Config())
->registerCustomFixers(new Fixers())
->registerCustomFixers(new PhpCsFixerCustomFixersDev\Fixers())
->setRiskyAllowed(true)
->setUsingCache(false)
->setFinder(
Finder::create()
->ignoreDotFiles(false)
->in(__DIR__),
)
->setRules($rules);