2021-07-19 21:21:30 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2021-07-19 21:32:33 +08:00
|
|
|
/**
|
|
|
|
* This file is part of CodeIgniter 4 framework.
|
|
|
|
*
|
|
|
|
* (c) CodeIgniter Foundation <admin@codeigniter.com>
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view
|
|
|
|
* the LICENSE file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
2021-09-02 12:32:07 +08:00
|
|
|
use CodeIgniter\CodingStandard\CodeIgniter4;
|
2021-07-19 21:21:30 +08:00
|
|
|
use Nexus\CsConfig\Factory;
|
2021-09-03 20:57:36 +08:00
|
|
|
use Nexus\CsConfig\Fixer\Comment\NoCodeSeparatorCommentFixer;
|
2021-09-02 12:32:07 +08:00
|
|
|
use Nexus\CsConfig\Fixer\Comment\SpaceAfterCommentStartFixer;
|
|
|
|
use Nexus\CsConfig\FixerGenerator;
|
2021-07-19 21:21:30 +08:00
|
|
|
use PhpCsFixer\Finder;
|
|
|
|
|
|
|
|
$finder = Finder::create()
|
|
|
|
->files()
|
|
|
|
->in([
|
|
|
|
__DIR__ . '/admin',
|
|
|
|
__DIR__ . '/app',
|
|
|
|
__DIR__ . '/public',
|
2021-09-02 12:32:07 +08:00
|
|
|
])
|
|
|
|
->notName('#Logger\.php$#');
|
2021-07-19 21:21:30 +08:00
|
|
|
|
2021-10-06 15:13:34 +08:00
|
|
|
$overrides = [
|
2021-10-05 20:00:17 +08:00
|
|
|
// @TODO Remove once these are live in coding-standard
|
|
|
|
'assign_null_coalescing_to_coalesce_equal' => false, // requires 7.4+
|
2021-10-11 17:03:05 +08:00
|
|
|
'class_attributes_separation' => [
|
|
|
|
'elements' => [
|
|
|
|
'const' => 'none',
|
|
|
|
'property' => 'none',
|
|
|
|
'method' => 'one',
|
|
|
|
'trait_import' => 'none',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'control_structure_continuation_position' => ['position' => 'same_line'],
|
|
|
|
'empty_loop_condition' => ['style' => 'while'],
|
|
|
|
'integer_literal_case' => true,
|
|
|
|
'modernize_strpos' => false, // requires 8.0+
|
|
|
|
'no_alternative_syntax' => ['fix_non_monolithic_code' => false],
|
|
|
|
'no_space_around_double_colon' => true,
|
|
|
|
'octal_notation' => false, // requires 8.1+
|
|
|
|
'string_length_to_empty' => true,
|
2021-10-06 15:13:34 +08:00
|
|
|
];
|
2021-07-19 21:21:30 +08:00
|
|
|
|
|
|
|
$options = [
|
2021-08-13 16:48:41 +08:00
|
|
|
'cacheFile' => 'build/.no-header.php-cs-fixer.cache',
|
|
|
|
'finder' => $finder,
|
2021-09-02 12:32:07 +08:00
|
|
|
'customFixers' => FixerGenerator::create('vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer'),
|
|
|
|
'customRules' => [
|
2021-09-03 20:57:36 +08:00
|
|
|
NoCodeSeparatorCommentFixer::name() => true,
|
2021-09-02 12:32:07 +08:00
|
|
|
SpaceAfterCommentStartFixer::name() => true,
|
2021-08-13 16:48:41 +08:00
|
|
|
],
|
2021-07-19 21:21:30 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
return Factory::create(new CodeIgniter4(), $overrides, $options)->forProjects();
|