Skip to content

Commit 8024ff9

Browse files
authored
Merge pull request #7712 from paulbalandan/cs-workflow
Adjust registering of custom fixers for PHP 8.0+ only
2 parents 5c227fe + 00c7086 commit 8024ff9

File tree

3 files changed

+42
-21
lines changed

3 files changed

+42
-21
lines changed

.php-cs-fixer.dist.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,23 @@
4646
$overrides = [];
4747

4848
$options = [
49-
'cacheFile' => 'build/.php-cs-fixer.cache',
50-
'finder' => $finder,
51-
'customFixers' => FixerGenerator::create('vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer'),
52-
'customRules' => [
53-
NoCodeSeparatorCommentFixer::name() => true,
54-
],
49+
'cacheFile' => 'build/.php-cs-fixer.cache',
50+
'finder' => $finder,
5551
];
5652

57-
return Factory::create(new CodeIgniter4(), $overrides, $options)->forLibrary(
53+
$config = Factory::create(new CodeIgniter4(), $overrides, $options)->forLibrary(
5854
'CodeIgniter 4 framework',
5955
'CodeIgniter Foundation',
6056
6157
);
58+
59+
// @TODO: remove this check when support for PHP 7.4 is dropped
60+
if (PHP_VERSION_ID >= 80000) {
61+
$config
62+
->registerCustomFixers(FixerGenerator::create('vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer'))
63+
->setRules(array_merge($config->getRules(), [
64+
NoCodeSeparatorCommentFixer::name() => true,
65+
]));
66+
}
67+
68+
return $config;

.php-cs-fixer.no-header.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,19 @@
3232
$overrides = [];
3333

3434
$options = [
35-
'cacheFile' => 'build/.php-cs-fixer.no-header.cache',
36-
'finder' => $finder,
37-
'customFixers' => FixerGenerator::create('vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer'),
38-
'customRules' => [
39-
NoCodeSeparatorCommentFixer::name() => true,
40-
],
35+
'cacheFile' => 'build/.php-cs-fixer.no-header.cache',
36+
'finder' => $finder,
4137
];
4238

43-
return Factory::create(new CodeIgniter4(), $overrides, $options)->forProjects();
39+
$config = Factory::create(new CodeIgniter4(), $overrides, $options)->forProjects();
40+
41+
// @TODO: remove this check when support for PHP 7.4 is dropped
42+
if (PHP_VERSION_ID >= 80000) {
43+
$config
44+
->registerCustomFixers(FixerGenerator::create('vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer'))
45+
->setRules(array_merge($config->getRules(), [
46+
NoCodeSeparatorCommentFixer::name() => true,
47+
]));
48+
}
49+
50+
return $config;

.php-cs-fixer.user-guide.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,19 @@
3636
];
3737

3838
$options = [
39-
'cacheFile' => 'build/.php-cs-fixer.user-guide.cache',
40-
'finder' => $finder,
41-
'customFixers' => FixerGenerator::create('vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer'),
42-
'customRules' => [
43-
NoCodeSeparatorCommentFixer::name() => true,
44-
],
39+
'cacheFile' => 'build/.php-cs-fixer.no-header.cache',
40+
'finder' => $finder,
4541
];
4642

47-
return Factory::create(new CodeIgniter4(), $overrides, $options)->forProjects();
43+
$config = Factory::create(new CodeIgniter4(), $overrides, $options)->forProjects();
44+
45+
// @TODO: remove this check when support for PHP 7.4 is dropped
46+
if (PHP_VERSION_ID >= 80000) {
47+
$config
48+
->registerCustomFixers(FixerGenerator::create('vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer'))
49+
->setRules(array_merge($config->getRules(), [
50+
NoCodeSeparatorCommentFixer::name() => true,
51+
]));
52+
}
53+
54+
return $config;

0 commit comments

Comments
 (0)