From b67971191547d440a6756c33065997d26cd17bd9 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Tue, 9 Jul 2024 12:58:32 +0800 Subject: [PATCH] Depend on main config --- .php-cs-fixer.no-header.php | 24 ++++++++++-------------- .php-cs-fixer.tests.php | 32 +++++++++----------------------- .php-cs-fixer.user-guide.php | 23 +++++++++-------------- 3 files changed, 28 insertions(+), 51 deletions(-) diff --git a/.php-cs-fixer.no-header.php b/.php-cs-fixer.no-header.php index cd10717aa5..f3bc97dc78 100644 --- a/.php-cs-fixer.no-header.php +++ b/.php-cs-fixer.no-header.php @@ -11,12 +11,12 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -use CodeIgniter\CodingStandard\CodeIgniter4; -use Nexus\CsConfig\Factory; -use Nexus\CsConfig\Fixer\Comment\NoCodeSeparatorCommentFixer; -use Nexus\CsConfig\FixerGenerator; +use PhpCsFixer\ConfigInterface; use PhpCsFixer\Finder; +/** @var ConfigInterface $config */ +$config = require __DIR__ . '/.php-cs-fixer.dist.php'; + $finder = Finder::create() ->files() ->in([ @@ -29,15 +29,11 @@ $finder = Finder::create() __DIR__ . '/admin/starter/builds', ]); -$overrides = []; - -$options = [ - 'cacheFile' => 'build/.php-cs-fixer.no-header.cache', - 'finder' => $finder, - 'customFixers' => FixerGenerator::create('vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer'), - 'customRules' => [ - NoCodeSeparatorCommentFixer::name() => true, - ], +$overrides = [ + 'header_comment' => false, ]; -return Factory::create(new CodeIgniter4(), $overrides, $options)->forProjects(); +return $config + ->setFinder($finder) + ->setCacheFile('build/.php-cs-fixer.no-header.cache') + ->setRules(array_merge($config->getRules(), $overrides)); diff --git a/.php-cs-fixer.tests.php b/.php-cs-fixer.tests.php index 7d5c1fad5e..28a7124909 100644 --- a/.php-cs-fixer.tests.php +++ b/.php-cs-fixer.tests.php @@ -11,43 +11,29 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -use CodeIgniter\CodingStandard\CodeIgniter4; -use Nexus\CsConfig\Factory; -use Nexus\CsConfig\Fixer\Comment\NoCodeSeparatorCommentFixer; -use Nexus\CsConfig\FixerGenerator; +use PhpCsFixer\ConfigInterface; use PhpCsFixer\Finder; +/** @var ConfigInterface $config */ +$config = require __DIR__ . '/.php-cs-fixer.dist.php'; + $finder = Finder::create() ->files() ->in([ __DIR__ . '/tests', ]) - ->exclude([ - ]) ->notPath([ '_support/View/Cells/multiplier.php', '_support/View/Cells/colors.php', '_support/View/Cells/addition.php', ]) - ->notName('#Foobar.php$#') - ->append([ - ]); + ->notName('#Foobar.php$#'); $overrides = [ 'void_return' => true, ]; -$options = [ - 'cacheFile' => 'build/.php-cs-fixer.tests.cache', - 'finder' => $finder, - 'customFixers' => FixerGenerator::create('vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer'), - 'customRules' => [ - NoCodeSeparatorCommentFixer::name() => true, - ], -]; - -return Factory::create(new CodeIgniter4(), $overrides, $options)->forLibrary( - 'CodeIgniter 4 framework', - 'CodeIgniter Foundation', - 'admin@codeigniter.com' -); +return $config + ->setFinder($finder) + ->setCacheFile('build/.php-cs-fixer.tests.cache') + ->setRules(array_merge($config->getRules(), $overrides)); diff --git a/.php-cs-fixer.user-guide.php b/.php-cs-fixer.user-guide.php index 6382201525..6b925ee8b0 100644 --- a/.php-cs-fixer.user-guide.php +++ b/.php-cs-fixer.user-guide.php @@ -11,12 +11,12 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -use CodeIgniter\CodingStandard\CodeIgniter4; -use Nexus\CsConfig\Factory; -use Nexus\CsConfig\Fixer\Comment\NoCodeSeparatorCommentFixer; -use Nexus\CsConfig\FixerGenerator; +use PhpCsFixer\ConfigInterface; use PhpCsFixer\Finder; +/** @var ConfigInterface $config */ +$config = require __DIR__ . '/.php-cs-fixer.dist.php'; + $finder = Finder::create() ->files() ->in([ @@ -32,6 +32,7 @@ $finder = Finder::create() $overrides = [ 'echo_tag_syntax' => false, + 'header_comment' => false, 'php_unit_internal_class' => false, 'no_unused_imports' => false, 'class_attributes_separation' => false, @@ -41,13 +42,7 @@ $overrides = [ ], ]; -$options = [ - 'cacheFile' => 'build/.php-cs-fixer.user-guide.cache', - 'finder' => $finder, - 'customFixers' => FixerGenerator::create('vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer'), - 'customRules' => [ - NoCodeSeparatorCommentFixer::name() => true, - ], -]; - -return Factory::create(new CodeIgniter4(), $overrides, $options)->forProjects(); +return $config + ->setFinder($finder) + ->setCacheFile('build/.php-cs-fixer.user-guide.cache') + ->setRules(array_merge($config->getRules(), $overrides));