Skip to content

Commit 6709431

Browse files
authored
Add PHP CS Fixer v3 support (#499)
1 parent 13d6534 commit 6709431

18 files changed

+41
-31
lines changed

.github/workflows/ci.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ jobs:
3636
os: [ macos-latest, ubuntu-latest, windows-latest ]
3737
php-version: [ '7.4', '8.0' ]
3838
include:
39+
- os: ubuntu-18.04
40+
php-version: '8.0'
41+
php-cs-fixer-version: '^2'
42+
- os: ubuntu-18.04
43+
php-version: '7.4'
44+
php-cs-fixer-version: '^2'
3945
- os: ubuntu-latest
4046
php-version: '7.3'
4147
- os: ubuntu-latest
@@ -89,6 +95,10 @@ jobs:
8995
key: ${{ runner.os }}-composer-cache-${{ hashFiles('**/composer.json') }}
9096
restore-keys: ${{ runner.os }}-composer-cache-
9197

98+
- name: Configure PHP CS Fixer version
99+
if: matrix.php-cs-fixer-version
100+
run: composer require friendsofphp/php-cs-fixer:${{ matrix.php-cs-fixer-version }} --no-update
101+
92102
- name: Install dependencies
93103
run: composer update --no-progress ${{ matrix.composer_flags }}
94104

File renamed without changes.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"require": {
1313
"php": "^7.2 || ^8.0",
1414
"ext-tokenizer": "*",
15-
"friendsofphp/php-cs-fixer": "^2.17",
15+
"friendsofphp/php-cs-fixer": "^2.17 || ^3.0.0",
1616
"symfony/finder": "^3.0 || ^4.0 || ^5.0"
1717
},
1818
"require-dev": {

dev-tools/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"ergebnis/composer-normalize": "^2.13.3",
44
"infection/infection": "^0.22.0",
55
"kubawerlos/composer-smaller-lock": "^0.1.1",
6-
"kubawerlos/php-cs-fixer-config": "dev-master",
6+
"kubawerlos/php-cs-fixer-config": "dev-main",
77
"kubawerlos/types-checker": "^2.1.0",
88
"maglnet/composer-require-checker": "^3.2.0",
99
"mi-schi/phpmd-extension": "^4.3.0",

dev-tools/composer.lock

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

dev-tools/phpcs.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<file>./src</file>
1010
<file>../src</file>
1111
<file>../tests</file>
12-
<file>../.php_cs</file>
12+
<file>../.php-cs-fixer.php</file>
1313
<exclude-pattern>./src/Readme/php-cs-fixer.config.*.php</exclude-pattern>
1414

1515
<rule ref='PSR12'>

dev-tools/phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ parameters:
44
excludes_analyse:
55
- ./src/Readme
66
ignoreErrors:
7-
- message: '#^Call to an undefined method PhpCsFixer\\Fixer\\DefinedFixerInterface::#'
7+
- message: '#^Call to an undefined method PhpCsFixer\\Fixer\\FixerInterface::[a-zA-Z]+\(\)\.$#'
88
path: ../tests
99
- message: '#^Call to function method_exists\(\) with ''Tests\\\\.*'' and ''.*'' will always evaluate to true\.$#'
1010
path: ../tests

dev-tools/psalm.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
<file name='./src/Fixer/OrderedClassElementsInternalFixer.php' />
4040
<file name='../src/Analyzer/Analysis/ArrayElementAnalysis.php' />
4141
<file name='../src/Fixer/DeprecatingFixerInterface.php' />
42+
<file name='../src/Fixer/NoLeadingSlashInGlobalNamespaceFixer.php' />
4243
</errorLevel>
4344
</PossiblyUnusedMethod>
4445
<UnnecessaryVarAnnotation errorLevel='suppress' />

dev-tools/src/Readme/ReadmeCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
use PhpCsFixer\Console\Command\HelpCommand;
1717
use PhpCsFixer\Fixer\ConfigurableFixerInterface;
18-
use PhpCsFixer\Fixer\ConfigurationDefinitionFixerInterface;
1918
use PhpCsFixer\Fixer\DeprecatedFixerInterface;
2019
use PhpCsFixer\FixerDefinition\CodeSample;
2120
use PhpCsFixer\StdinFileInfo;
@@ -195,7 +194,7 @@ private function fixers(): string
195194
);
196195
}
197196

198-
if ($fixer instanceof ConfigurationDefinitionFixerInterface) {
197+
if ($fixer instanceof ConfigurableFixerInterface) {
199198
$output .= "\nConfiguration options:";
200199

201200
foreach ($fixer->getConfigurationDefinition()->getOptions() as $option) {

src/Fixer/AbstractFixer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313

1414
namespace PhpCsFixerCustomFixers\Fixer;
1515

16-
use PhpCsFixer\Fixer\DefinedFixerInterface;
16+
use PhpCsFixer\Fixer\FixerInterface;
1717
use PhpCsFixer\Preg;
1818

19-
abstract class AbstractFixer implements DefinedFixerInterface
19+
abstract class AbstractFixer implements FixerInterface
2020
{
2121
final public static function name(): string
2222
{

0 commit comments

Comments
 (0)