Skip to content

Commit e55510c

Browse files
authored
Update dev tools (#984)
1 parent 3602440 commit e55510c

File tree

7 files changed

+97
-66
lines changed

7 files changed

+97
-66
lines changed

.dev-tools/build-infection-config.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
include __DIR__ . '/../vendor/autoload.php';
1313
include __DIR__ . '/vendor/autoload.php';
1414

15-
$configBuilder = new PhpCsFixerCustomFixersDev\InfectionConfigBuilder();
15+
use PhpCsFixerCustomFixersDev\InfectionConfigBuilder;
16+
17+
$configBuilder = new InfectionConfigBuilder();
1618
$config = $configBuilder->build();
1719

1820
file_put_contents(__DIR__ . '/infection.json', json_encode($config, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) . "\n");

.dev-tools/composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
"ergebnis/composer-normalize": "^2.43",
66
"infection/infection": "^0.27.11",
77
"kubawerlos/composer-smaller-lock": "^1.0.1",
8-
"kubawerlos/php-cs-fixer-config": "^3.26",
8+
"kubawerlos/php-cs-fixer-config": "^4.0",
99
"maglnet/composer-require-checker": "^4.11",
1010
"mi-schi/phpmd-extension": "^4.3",
1111
"phpmd/phpmd": "^2.15",
1212
"phpstan/extension-installer": "^1.4.1",
13-
"phpstan/phpstan": "^1.11.7",
14-
"phpstan/phpstan-phpunit": "^1.4.0",
15-
"phpstan/phpstan-strict-rules": "^1.6.0",
16-
"squizlabs/php_codesniffer": "^3.10.1",
17-
"vimeo/psalm": "^5.25.0"
13+
"phpstan/phpstan": "^1.11.9",
14+
"phpstan/phpstan-phpunit": "^1.4",
15+
"phpstan/phpstan-strict-rules": "^1.6",
16+
"squizlabs/php_codesniffer": "^3.10.2",
17+
"vimeo/psalm": "^5.25"
1818
},
1919
"autoload": {
2020
"psr-4": {

.dev-tools/composer.lock

Lines changed: 48 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.dev-tools/generate_readme.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@
1111

1212
require_once __DIR__ . '/../vendor/autoload.php';
1313

14-
$application = new Symfony\Component\Console\Application();
15-
$command = new PhpCsFixerCustomFixersDev\Readme\ReadmeCommand();
14+
use PhpCsFixerCustomFixersDev\Readme\ReadmeCommand;
15+
use Symfony\Component\Console\Application;
16+
17+
$application = new Application();
18+
$command = new ReadmeCommand();
1619

1720
$application->add($command);
1821

.php-cs-fixer.php

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,35 @@
1212
require_once __DIR__ . '/.dev-tools/vendor/autoload.php';
1313
require_once __DIR__ . '/vendor/autoload.php';
1414

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+
1524
// sanity check
1625
$expectedPath = realpath(__DIR__ . '/src/Fixers.php');
17-
$actualPath = (new ReflectionClass(PhpCsFixerCustomFixers\Fixers::class))->getFileName();
26+
$actualPath = (new ReflectionClass(Fixers::class))->getFileName();
1827
if ($expectedPath !== $actualPath) {
1928
printf(
2029
'Class %s must be loaded from "%s", but loaded from "%s"!' . PHP_EOL,
21-
PhpCsFixerCustomFixers\Fixers::class,
30+
Fixers::class,
2231
$expectedPath,
2332
$actualPath,
2433
);
2534
exit(1);
2635
}
2736

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();
2938

30-
$rules[PhpCsFixerCustomFixers\Fixer\NoSuperfluousConcatenationFixer::name()] = ['allow_preventing_trailing_spaces' => true];
39+
$rules[NoSuperfluousConcatenationFixer::name()] = ['allow_preventing_trailing_spaces' => true];
3140

3241
// 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) {
3544
continue;
3645
}
3746
if (!array_key_exists($fixer->getName(), $rules)) {
@@ -42,22 +51,23 @@
4251
unset($rules['assign_null_coalescing_to_coalesce_equal']); // TODO: remove when dropping support to PHP <8.0
4352
unset($rules['get_class_to_class_keyword']); // TODO: remove when dropping support to PHP <8.0
4453
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
4656
$rules['trailing_comma_in_multiline'] = ['after_heredoc' => true, 'elements' => ['arguments', 'arrays']]; // TODO: remove when dropping support to PHP <8.0
4757

48-
$rules[PhpCsFixerCustomFixers\Fixer\PhpdocOnlyAllowedAnnotationsFixer::name()]['elements'][] = 'phpstan-type';
58+
$rules[PhpdocOnlyAllowedAnnotationsFixer::name()]['elements'][] = 'phpstan-type';
4959

5060
foreach (new PhpCsFixerCustomFixersDev\Fixers() as $fixer) {
5161
$rules[$fixer->getName()] = true;
5262
}
5363

54-
return (new PhpCsFixer\Config())
55-
->registerCustomFixers(new PhpCsFixerCustomFixers\Fixers())
64+
return (new Config())
65+
->registerCustomFixers(new Fixers())
5666
->registerCustomFixers(new PhpCsFixerCustomFixersDev\Fixers())
5767
->setRiskyAllowed(true)
5868
->setUsingCache(false)
5969
->setFinder(
60-
PhpCsFixer\Finder::create()
70+
Finder::create()
6171
->ignoreDotFiles(false)
6272
->in(__DIR__),
6373
)

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
"php": "^7.4 || ^8.0",
1414
"ext-filter": "*",
1515
"ext-tokenizer": "*",
16-
"friendsofphp/php-cs-fixer": "^3.59"
16+
"friendsofphp/php-cs-fixer": "^3.61.1"
1717
},
1818
"require-dev": {
19-
"phpunit/phpunit": "^9.6.4 || ^10.0.14"
19+
"phpunit/phpunit": "^9.6.4 || ^10.5.29"
2020
},
2121
"autoload": {
2222
"psr-4": {

tests/autoload.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
<?php declare(strict_types=1);
22

3+
/*
4+
* This file is part of PHP CS Fixer: custom fixers.
5+
*
6+
* (c) 2018 Kuba Werłos
7+
*
8+
* For the full copyright and license information, please view
9+
* the LICENSE file that was distributed with this source code.
10+
*/
11+
12+
use PhpCsFixer\Fixer\FixerInterface;
13+
314
/*
415
* This file is part of PHP CS Fixer: custom fixers.
516
*
@@ -11,7 +22,7 @@
1122

1223
require_once __DIR__ . '/../vendor/autoload.php';
1324

14-
if (!interface_exists(PhpCsFixer\Fixer\FixerInterface::class)) {
25+
if (!interface_exists(FixerInterface::class)) {
1526
$phars = [
1627
__DIR__ . '/../vendor/php-cs-fixer/shim/php-cs-fixer.phar',
1728
__DIR__ . '/../vendor/php-cs-fixer/shim/php-cs-fixer',

0 commit comments

Comments
 (0)