|
| 1 | +<?php |
| 2 | + |
| 3 | +/** @noinspection PhpPossiblePolymorphicInvocationInspection */ |
| 4 | +/** @noinspection PhpUnusedAliasInspection */ |
| 5 | + |
| 6 | +declare(strict_types=1); |
| 7 | + |
| 8 | +/** |
| 9 | + * Copyright (c) 2019-2025 guanguans<[email protected]> |
| 10 | + * |
| 11 | + * For the full copyright and license information, please view |
| 12 | + * the LICENSE file that was distributed with this source code. |
| 13 | + * |
| 14 | + * @see https://github.com/guanguans/soar-php |
| 15 | + */ |
| 16 | + |
| 17 | +use Guanguans\PhpCsFixerCustomFixers\Fixer\CommandLineTool\AbstractCommandLineToolFixer; |
| 18 | +use Guanguans\PhpCsFixerCustomFixers\Fixer\CommandLineTool\AutocorrectFixer; |
| 19 | +use Guanguans\PhpCsFixerCustomFixers\Fixer\CommandLineTool\BladeFormatterFixer; |
| 20 | +use Guanguans\PhpCsFixerCustomFixers\Fixer\CommandLineTool\DockerfmtFixer; |
| 21 | +use Guanguans\PhpCsFixerCustomFixers\Fixer\CommandLineTool\DotenvLinterFixer; |
| 22 | +use Guanguans\PhpCsFixerCustomFixers\Fixer\CommandLineTool\LintMdFixer; |
| 23 | +use Guanguans\PhpCsFixerCustomFixers\Fixer\CommandLineTool\MarkdownlintCli2Fixer; |
| 24 | +use Guanguans\PhpCsFixerCustomFixers\Fixer\CommandLineTool\MarkdownlintFixer; |
| 25 | +use Guanguans\PhpCsFixerCustomFixers\Fixer\CommandLineTool\PintFixer; |
| 26 | +use Guanguans\PhpCsFixerCustomFixers\Fixer\CommandLineTool\ShfmtFixer; |
| 27 | +use Guanguans\PhpCsFixerCustomFixers\Fixer\CommandLineTool\SqlfluffFixer; |
| 28 | +use Guanguans\PhpCsFixerCustomFixers\Fixer\CommandLineTool\SqruffFixer; |
| 29 | +use Guanguans\PhpCsFixerCustomFixers\Fixer\CommandLineTool\TextlintFixer; |
| 30 | +use Guanguans\PhpCsFixerCustomFixers\Fixer\CommandLineTool\TombiFixer; |
| 31 | +use Guanguans\PhpCsFixerCustomFixers\Fixer\CommandLineTool\XmllintFixer; |
| 32 | +use Guanguans\PhpCsFixerCustomFixers\Fixer\CommandLineTool\YamlfmtFixer; |
| 33 | +use Guanguans\PhpCsFixerCustomFixers\Fixer\CommandLineTool\ZhlintFixer; |
| 34 | +use Guanguans\PhpCsFixerCustomFixers\Fixer\InlineHtml\JsonFixer; |
| 35 | +use Guanguans\PhpCsFixerCustomFixers\Fixer\InlineHtml\SqlOfDoctrineSqlFormatterFixer; |
| 36 | +use Guanguans\PhpCsFixerCustomFixers\Fixer\InlineHtml\SqlOfPhpmyadminSqlParserFixer; |
| 37 | +use Guanguans\PhpCsFixerCustomFixers\Fixers; |
| 38 | +use PhpCsFixer\Config; |
| 39 | +use PhpCsFixer\Finder; |
| 40 | +use PhpCsFixer\Runner\Parallel\ParallelConfigFactory; |
| 41 | + |
| 42 | +// putenv('PHP_CS_FIXER_ENFORCE_CACHE=1'); |
| 43 | +// putenv('PHP_CS_FIXER_IGNORE_ENV=1'); |
| 44 | +putenv('PHP_CS_FIXER_FUTURE_MODE=1'); |
| 45 | +putenv('PHP_CS_FIXER_NON_MONOLITHIC=1'); |
| 46 | +putenv('PHP_CS_FIXER_PARALLEL=1'); |
| 47 | + |
| 48 | +return (new Config) |
| 49 | + ->registerCustomFixers($fixers = Fixers::make()) |
| 50 | + ->setRules([ |
| 51 | + 'encoding' => true, |
| 52 | + 'no_trailing_whitespace' => true, |
| 53 | + 'no_whitespace_in_blank_line' => true, |
| 54 | + 'non_printable_character' => true, |
| 55 | + 'single_blank_line_at_eof' => true, |
| 56 | + |
| 57 | + AutocorrectFixer::name() => true, |
| 58 | + LintMdFixer::name() => true, |
| 59 | + // MarkdownlintCli2Fixer::name() => true, |
| 60 | + MarkdownlintFixer::name() => true, |
| 61 | + // TextlintFixer::name() => true, |
| 62 | + ZhlintFixer::name() => true, |
| 63 | + |
| 64 | + // PintFixer::name() => true, |
| 65 | + // BladeFormatterFixer::name() => [ // Custom BladeFormatterFixer configuration |
| 66 | + // AbstractCommandLineToolFixer::COMMAND => ['path/to/node', 'path/to/blade-formatter'], |
| 67 | + // AbstractCommandLineToolFixer::OPTIONS => [ |
| 68 | + // '--config' => 'path/to/.bladeformatterrc', |
| 69 | + // '--extra-liners' => true, |
| 70 | + // '--indent-size' => 2, |
| 71 | + // // ... |
| 72 | + // ], |
| 73 | + // ], |
| 74 | + BladeFormatterFixer::name() => true, // Default BladeFormatterFixer configuration |
| 75 | + |
| 76 | + SqlOfDoctrineSqlFormatterFixer::name() => true, |
| 77 | + // SqlOfPhpmyadminSqlParserFixer::name() => true, |
| 78 | + // SqruffFixer::name() => true, |
| 79 | + // SqlfluffFixer::name() => true, |
| 80 | + // SqlfluffFixer::name() => [ |
| 81 | + // AbstractCommandLineToolFixer::OPTIONS => [ |
| 82 | + // '--dialect' => 'mysql', |
| 83 | + // ], |
| 84 | + // AbstractCommandLineToolFixer::EXTENSIONS => ['sql'], |
| 85 | + // ], |
| 86 | + |
| 87 | + DockerfmtFixer::name() => true, |
| 88 | + DotenvLinterFixer::name() => true, |
| 89 | + JsonFixer::name() => true, |
| 90 | + ShfmtFixer::name() => true, |
| 91 | + TombiFixer::name() => true, |
| 92 | + XmllintFixer::name() => true, |
| 93 | + YamlfmtFixer::name() => true, |
| 94 | + ]) |
| 95 | + ->setFinder( |
| 96 | + Finder::create() |
| 97 | + ->in(__DIR__) |
| 98 | + ->exclude([ |
| 99 | + '__snapshots__/', |
| 100 | + 'Fixtures/', |
| 101 | + 'vendor-bin/', |
| 102 | + ]) |
| 103 | + ->notPath([ |
| 104 | + '.chglog/CHANGELOG.tpl.md', |
| 105 | + 'CHANGELOG.md', |
| 106 | + // 'composer.json', |
| 107 | + 'README-zh_CN.md', |
| 108 | + 'README.md', |
| 109 | + ]) |
| 110 | + ->name($fixers->extensionPatterns()) |
| 111 | + ->notName([ |
| 112 | + '/\-overview\.md$/', |
| 113 | + '/\.lock$/', |
| 114 | + '/\-lock\.json$/', |
| 115 | + // '/\.php$/', |
| 116 | + '/(?<!\.blade)\.php$/', |
| 117 | + '/zhlint\-.*\.zh_CN\.md$/', |
| 118 | + ]) |
| 119 | + ->ignoreDotFiles(false) |
| 120 | + ->ignoreUnreadableDirs(false) |
| 121 | + ->ignoreVCS(true) |
| 122 | + ->ignoreVCSIgnored(true) |
| 123 | + ) |
| 124 | + ->setCacheFile(\sprintf('%s/.build/php-cs-fixer/%s.cache', __DIR__, pathinfo(__FILE__, \PATHINFO_FILENAME))) |
| 125 | + // ->setParallelConfig(ParallelConfigFactory::sequential()) |
| 126 | + ->setParallelConfig(ParallelConfigFactory::detect()) |
| 127 | + ->setRiskyAllowed(true) |
| 128 | + ->setUnsupportedPhpVersionAllowed(true) |
| 129 | + ->setUsingCache(true); |
0 commit comments