guanguans / php-cs-fixer-custom-fixers
Use php-cs-fixer to format bats,blade.php,Dockerfile,env,json,md,sh,sql,text,toml,txt,xml,yaml...files. - 使用 php-cs-fixer 去格式化 bats、blade.php、Dockerfile、env、json、md、sh、sql、text、toml、txt、xml、yaml...文件。
Fund package maintenance!
Sponsors
Installs: 20
Dependents: 2
Suggesters: 0
Security: 0
Stars: 2
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/guanguans/php-cs-fixer-custom-fixers
Requires
- php: >=7.4
- friendsofphp/php-cs-fixer: ^3.92
- illuminate/support: ^8.83 || ^9.0 || ^10.0 || ^11.0 || ^12.0
Requires (Dev)
- adamwojs/php-cs-fixer-phpdoc-force-fqcn: ^2.0
- bamarni/composer-bin-plugin: ^1.8
- brainmaestro/composer-git-hooks: ^2.8 || ^3.0
- composer/composer: ^2.9
- doctrine/sql-formatter: ^1.3
- ergebnis/composer-normalize: ^2.48
- ergebnis/license: ^2.7
- ergebnis/php-cs-fixer-config: ^6.58
- ergebnis/rector-rules: ^1.8
- fakerphp/faker: ^1.24
- mockery/mockery: ^1.6
- nette/utils: ^3.2 || ^4.0
- pestphp/pest: ^1.23 || ^2.0 || ^3.0 || ^4.0
- php-mock/php-mock-phpunit: ^2.14
- phpbench/phpbench: ^1.2
- phpmyadmin/sql-parser: ^5.11 || ^6.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.1
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-mockery: ^2.0
- phpstan/phpstan-strict-rules: ^2.0
- phpstan/phpstan-webmozart-assert: ^2.0
- povils/phpmnd: ^3.6
- rector/jack: ^0.4
- rector/rector: ^2.2
- rector/swiss-knife: ^2.3
- rector/type-perfect: ^2.1
- shipmonk/composer-dependency-analyser: ^1.8
- shipmonk/dead-code-detector: ^0.14
- shipmonk/name-collision-detector: ^2.1
- shipmonk/phpstan-baseline-per-identifier: ^2.3
- spatie/pest-plugin-snapshots: ^1.1 || ^2.0
- spaze/phpstan-disallowed-calls: ^4.7
- staabm/phpstan-todo-by: ^0.3
- symfony/thanks: ^1.3
- symfony/var-dumper: ^5.4 || ^6.0 || ^7.0 || ^8.0
- symplify/phpstan-rules: ^14.9
- tomasvotruba/class-leak: ^2.1
- tomasvotruba/cognitive-complexity: ^1.0
- tomasvotruba/type-coverage: ^2.1
- yamadashy/phpstan-friendly-formatter: ^1.2
Suggests
- doctrine/sql-formatter: Required to use the fixer [SqlOfDoctrineSqlFormatterFixer].
- laravel/pint: Required to use the fixer [PintFixer].
- phpmyadmin/sql-parser: Required to use the fixer [SqlOfPhpmyadminSqlParserFixer].
Conflicts
- pestphp/pest: ^4.0
This package is auto-updated.
Last update: 2025-12-17 15:52:12 UTC
README
Warning
This package is not stable yet, use it with caution.
Use php-cs-fixer to format bats,blade.php,Dockerfile,env,json,md,sh,sql,text,toml,txt,xml,yaml...files. - 使用 php-cs-fixer 去格式化 bats、blade.php、Dockerfile、env、json、md、sh、sql、text、toml、txt、xml、yaml...文件。
Requirement
- PHP >= 7.4
Installation
composer require guanguans/php-cs-fixer-custom-fixers --dev --ansi -v
Usage
In your php-cs-fixer configuration(sample) register fixers and use them
<?php return (new PhpCsFixer\Config()) + ->registerCustomFixers($fixers = Guanguans\PhpCsFixerCustomFixers\Fixers::make()) ->setRules([ '@PhpCsFixer:risky' => true, + Guanguans\PhpCsFixerCustomFixers\Fixer\CommandLineTool\BladeFormatterFixer::name() => true, + Guanguans\PhpCsFixerCustomFixers\Fixer\CommandLineTool\YamlfmtFixer::name() => true, + // Other fixers... ]) ->setFinder( PhpCsFixer\Finder::create() ->in(__DIR__) + // ->name(Guanguans\PhpCsFixerCustomFixers\Fixer\CommandLineTool\BladeFormatterFixer::make()->extensionPatterns()) + // ->name(Guanguans\PhpCsFixerCustomFixers\Fixer\CommandLineTool\YamlfmtFixer::make()->extensionPatterns()) + // Other ... + ->name($fixers->extensionPatterns()) );
Install command line tools(if you haven't installed them yet)
npm install -g blade-formatter
brew install yamlfmt
# Other command line tools...
Run php-cs-fixer
vendor/bin/php-cs-fixer check --config=.php-cs-fixer-custom.php --show-progress=dots --diff --ansi -vv # Check only vendor/bin/php-cs-fixer fix --config=.php-cs-fixer-custom.php --show-progress=dots --diff --dry-run --ansi -vv # Check only vendor/bin/php-cs-fixer fix --config=.php-cs-fixer-custom.php --show-progress=dots --diff --ansi -vv # Fix vendor/bin/php-cs-fixer fix --config=.php-cs-fixer-custom.php --show-progress=dots --diff --ansi -vvv --sequential # Show debug information
Fixers
AutocorrectFixer
Format txt files using autocorrect.
Risky: it depends on the configuration of autocorrect.
Configuration options:
command(string[]): the command to run and its arguments listed as separate entries; defaults to['autocorrect']cwd(string,null): the working directory or null to use the working dir of the current PHP process; defaults tonullenv(array): the environment variables or null to use the same environment as the current PHP process; defaults to[]extensions(string[]): the supported file extensions are used for formatting; defaults to['txt', 'text', 'md', 'markdown']input(string,null): the input as stream resource, scalar or \Traversable, or null for no input; defaults tonulloptions(array): the command options to run listed as separate entries; defaults to[]timeout(float,int,null): the timeout in seconds or null to disable; defaults to10
Sample1: configuration(default)
-Hello世界! +Hello 世界!
Sample2: configuration(default)
-Hello世界! +Hello 世界!
BladeFormatterFixer
Format blade.php files using blade-formatter.
Risky: it depends on the configuration of blade-formatter.
Configuration options:
command(string[]): the command to run and its arguments listed as separate entries; defaults to['blade-formatter']cwd(string,null): the working directory or null to use the working dir of the current PHP process; defaults tonullenv(array): the environment variables or null to use the same environment as the current PHP process; defaults to[]extensions(string[]): the supported file extensions are used for formatting; defaults to['blade.php']input(string,null): the input as stream resource, scalar or \Traversable, or null for no input; defaults tonulloptions(array): the command options to run listed as separate entries; defaults to[]timeout(float,int,null): the timeout in seconds or null to disable; defaults to10
Sample1: configuration(default)
-@if($paginator->hasPages()) +@if ($paginator->hasPages()) <nav> <ul class="pagination"> - {{-- Previous Page Link --}} - @if ($paginator->onFirstPage()) - - <li class="disabled" aria-disabled="true"><span>@lang('pagination.previous')</span></li> - @else - - <li><a href="{{ $paginator->previousPageUrl() }}" rel="prev">@lang('pagination.previous')</a></li> - @endif + {{-- Previous Page Link --}} + @if ($paginator->onFirstPage()) + <li class="disabled" aria-disabled="true"><span>@lang('pagination.previous')</span></li> + @else + <li><a href="{{ $paginator->previousPageUrl() }}" rel="prev">@lang('pagination.previous')</a></li> + @endif </ul> </nav> -@endif \ No newline at end of file +@endif
Sample2: configuration(['options' => ['--indent-size' => 2, '--extra-liners' => true]])
-@if($paginator->hasPages()) - <nav> - <ul class="pagination"> - {{-- Previous Page Link --}} - @if ($paginator->onFirstPage()) - - <li class="disabled" aria-disabled="true"><span>@lang('pagination.previous')</span></li> - @else - - <li><a href="{{ $paginator->previousPageUrl() }}" rel="prev">@lang('pagination.previous')</a></li> - @endif - </ul> - </nav> -@endif \ No newline at end of file +@if ($paginator->hasPages()) + <nav> + <ul class="pagination"> + {{-- Previous Page Link --}} + @if ($paginator->onFirstPage()) + <li class="disabled" aria-disabled="true"><span>@lang('pagination.previous')</span></li> + @else + <li><a href="{{ $paginator->previousPageUrl() }}" rel="prev">@lang('pagination.previous')</a></li> + @endif + </ul> + </nav> +@endif
DockerfmtFixer
Format Dockerfile files using dockerfmt.
Risky: it depends on the configuration of dockerfmt.
Configuration options:
command(string[]): the command to run and its arguments listed as separate entries; defaults to['dockerfmt']cwd(string,null): the working directory or null to use the working dir of the current PHP process; defaults tonullenv(array): the environment variables or null to use the same environment as the current PHP process; defaults to[]extensions(string[]): the supported file extensions are used for formatting; defaults to['Dockerfile']input(string,null): the input as stream resource, scalar or \Traversable, or null for no input; defaults tonulloptions(array): the command options to run listed as separate entries; defaults to[]timeout(float,int,null): the timeout in seconds or null to disable; defaults to10
Sample1: configuration(default)
-RUN foo \ +RUN foo \ # comment 1 -&& \ -# comment 2 -bar && \ -# comment 3 -baz \ No newline at end of file + # comment 2 + && bar \ + # comment 3 + && baz
DotenvLinterFixer
Format env files using dotenv-linter.
Risky: it depends on the configuration of dotenv-linter.
Configuration options:
command(string[]): the command to run and its arguments listed as separate entries; defaults to['dotenv-linter', 'fix']cwd(string,null): the working directory or null to use the working dir of the current PHP process; defaults tonullenv(array): the environment variables or null to use the same environment as the current PHP process; defaults to[]extensions(string[]): the supported file extensions are used for formatting; defaults to['env', 'env.example']input(string,null): the input as stream resource, scalar or \Traversable, or null for no input; defaults tonulloptions(array): the command options to run listed as separate entries; defaults to[]timeout(float,int,null): the timeout in seconds or null to disable; defaults to10
Sample1: configuration(default)
-FOO= BAR -BAR = FOO \ No newline at end of file +BAR=FOO +FOO=BAR
Sample2: configuration(default)
-FOO=${BAR -BAR="$BAR}" \ No newline at end of file +BAR="${BAR}" +FOO=${BAR}
Sample3: configuration(default)
-FOO=BAR BAZ \ No newline at end of file +FOO="BAR BAZ"
LintMdFixer
Format md files using lint-md.
Risky: it depends on the configuration of lint-md.
Configuration options:
command(string[]): the command to run and its arguments listed as separate entries; defaults to['lint-md']cwd(string,null): the working directory or null to use the working dir of the current PHP process; defaults tonullenv(array): the environment variables or null to use the same environment as the current PHP process; defaults to[]extensions(string[]): the supported file extensions are used for formatting; defaults to['md', 'markdown']input(string,null): the input as stream resource, scalar or \Traversable, or null for no input; defaults tonulloptions(array): the command options to run listed as separate entries; defaults to[]timeout(float,int,null): the timeout in seconds or null to disable; defaults to10
Sample1: configuration(default)
## 全角数字 -> 这件蛋糕只卖 1000 元。 \ No newline at end of file +> 这件蛋糕只卖 1000 元。 \ No newline at end of file
Sample2: configuration(default)
## 块引用空格 -> 摇旗呐喊的热情 +> 摇旗呐喊的热情 ->携光阴渐远去 \ No newline at end of file +> 携光阴渐远去 \ No newline at end of file
MarkdownlintCli2Fixer
Format md files using markdownlint-cli2.
Risky: it depends on the configuration of markdownlint-cli2.
Configuration options:
command(string[]): the command to run and its arguments listed as separate entries; defaults to['markdownlint-cli2']cwd(string,null): the working directory or null to use the working dir of the current PHP process; defaults tonullenv(array): the environment variables or null to use the same environment as the current PHP process; defaults to[]extensions(string[]): the supported file extensions are used for formatting; defaults to['md', 'markdown']input(string,null): the input as stream resource, scalar or \Traversable, or null for no input; defaults tonulloptions(array): the command options to run listed as separate entries; defaults to[]timeout(float,int,null): the timeout in seconds or null to disable; defaults to10
Sample1: configuration(default)
# Examples + ## This is ordered list -1. First item +1. First item 2. Second item ## This is unordered list -* https://link.com -* [ this is link ](https://link.com ) -* ** bold text ** \ No newline at end of file +* <https://link.com> +* [this is link](https://link.com ) +* **bold text**
MarkdownlintFixer
Format md files using markdownlint.
Risky: it depends on the configuration of markdownlint.
Configuration options:
command(string[]): the command to run and its arguments listed as separate entries; defaults to['markdownlint']cwd(string,null): the working directory or null to use the working dir of the current PHP process; defaults tonullenv(array): the environment variables or null to use the same environment as the current PHP process; defaults to[]extensions(string[]): the supported file extensions are used for formatting; defaults to['md', 'markdown']input(string,null): the input as stream resource, scalar or \Traversable, or null for no input; defaults tonulloptions(array): the command options to run listed as separate entries; defaults to[]timeout(float,int,null): the timeout in seconds or null to disable; defaults to10
Sample1: configuration(default)
# Examples + ## This is ordered list -1. First item +1. First item 2. Second item ## This is unordered list * https://link.com -* [ this is link ](https://link.com ) -* ** bold text ** \ No newline at end of file +* [this is link](https://link.com ) +* **bold text**
PintFixer
Format php files using pint.
Risky: it depends on the configuration of pint.
Configuration options:
command(string[]): the command to run and its arguments listed as separate entries; defaults to['php', 'vendor/bin/pint']cwd(string,null): the working directory or null to use the working dir of the current PHP process; defaults tonullenv(array): the environment variables or null to use the same environment as the current PHP process; defaults to[]extensions(string[]): the supported file extensions are used for formatting; defaults to['php']input(string,null): the input as stream resource, scalar or \Traversable, or null for no input; defaults tonulloptions(array): the command options to run listed as separate entries; defaults to[]timeout(float,int,null): the timeout in seconds or null to disable; defaults to10
ShfmtFixer
Format sh files using shfmt.
Risky: it depends on the configuration of shfmt.
Configuration options:
command(string[]): the command to run and its arguments listed as separate entries; defaults to['shfmt']cwd(string,null): the working directory or null to use the working dir of the current PHP process; defaults tonullenv(array): the environment variables or null to use the same environment as the current PHP process; defaults to[]extensions(string[]): the supported file extensions are used for formatting; defaults to['sh', 'bats']input(string,null): the input as stream resource, scalar or \Traversable, or null for no input; defaults tonulloptions(array): the command options to run listed as separate entries; defaults to[]timeout(float,int,null): the timeout in seconds or null to disable; defaults to10
Sample1: configuration(default)
#!/bin/bash -if foo ; then - bar +if foo; then + bar fi for i in 1 2 3; do - bar -done \ No newline at end of file + bar +done
Sample2: configuration(['options' => ['--minify' => true]])
#!/bin/bash - -if foo ; then - bar +if foo;then +bar fi - -for i in 1 2 3; do - bar -done \ No newline at end of file +for i in 1 2 3;do +bar +done
SqlfluffFixer
Format sql files using sqlfluff.
Risky: it depends on the configuration of sqlfluff.
Configuration options:
command(string[]): the command to run and its arguments listed as separate entries; defaults to['sqlfluff', 'format']cwd(string,null): the working directory or null to use the working dir of the current PHP process; defaults tonullenv(array): the environment variables or null to use the same environment as the current PHP process; defaults to[]extensions(string[]): the supported file extensions are used for formatting; defaults to['sql']input(string,null): the input as stream resource, scalar or \Traversable, or null for no input; defaults tonulloptions(array): the command options to run listed as separate entries; defaults to[]timeout(float,int,null): the timeout in seconds or null to disable; defaults to10
Sample1: configuration(default)
-SELECT customer_id, customer_name, COUNT(order_id) as total +SELECT + customer_id, + customer_name, + COUNT(order_id) AS total FROM customers INNER JOIN orders ON customers.customer_id = orders.customer_id GROUP BY customer_id, customer_name HAVING COUNT(order_id) > 5 -ORDER BY COUNT(order_id) DESC; \ No newline at end of file +ORDER BY COUNT(order_id) DESC;
SqruffFixer
Format sql files using sqruff.
Risky: it depends on the configuration of sqruff.
Configuration options:
command(string[]): the command to run and its arguments listed as separate entries; defaults to['sqruff', 'fix']cwd(string,null): the working directory or null to use the working dir of the current PHP process; defaults tonullenv(array): the environment variables or null to use the same environment as the current PHP process; defaults to[]extensions(string[]): the supported file extensions are used for formatting; defaults to['sql']input(string,null): the input as stream resource, scalar or \Traversable, or null for no input; defaults tonulloptions(array): the command options to run listed as separate entries; defaults to[]timeout(float,int,null): the timeout in seconds or null to disable; defaults to10
Sample1: configuration(default)
-SELECT customer_id, customer_name, COUNT(order_id) as total +SELECT customer_id, customer_name, COUNT(order_id) AS total FROM customers INNER JOIN orders ON customers.customer_id = orders.customer_id GROUP BY customer_id, customer_name HAVING COUNT(order_id) > 5 -ORDER BY COUNT(order_id) DESC; \ No newline at end of file +ORDER BY COUNT(order_id) DESC;
TextlintFixer
Format txt files using textlint.
Risky: it depends on the configuration of textlint.
Configuration options:
command(string[]): the command to run and its arguments listed as separate entries; defaults to['textlint']cwd(string,null): the working directory or null to use the working dir of the current PHP process; defaults tonullenv(array): the environment variables or null to use the same environment as the current PHP process; defaults to[]extensions(string[]): the supported file extensions are used for formatting; defaults to['txt', 'text', 'md', 'markdown']input(string,null): the input as stream resource, scalar or \Traversable, or null for no input; defaults tonulloptions(array): the command options to run listed as separate entries; defaults to[]timeout(float,int,null): the timeout in seconds or null to disable; defaults to10
Sample1: configuration(['options' => ['--rule' => 'terminology']])
-jquery is javascript library. \ No newline at end of file +jQuery is JavaScript library. \ No newline at end of file
TombiFixer
Format toml files using tombi.
Risky: it depends on the configuration of tombi.
Configuration options:
command(string[]): the command to run and its arguments listed as separate entries; defaults to['tombi', 'format']cwd(string,null): the working directory or null to use the working dir of the current PHP process; defaults tonullenv(array): the environment variables or null to use the same environment as the current PHP process; defaults to[]extensions(string[]): the supported file extensions are used for formatting; defaults to['toml']input(string,null): the input as stream resource, scalar or \Traversable, or null for no input; defaults tonulloptions(array): the command options to run listed as separate entries; defaults to[]timeout(float,int,null): the timeout in seconds or null to disable; defaults to10
Sample1: configuration(default)
key1 = "value1" - -key2 = "value2" \ No newline at end of file +key2 = "value2"
Sample2: configuration(default)
-items = [ - "a", - "b", - "c" -] \ No newline at end of file +items = ["a", "b", "c"]
Sample3: configuration(default)
-items = ["aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk"] \ No newline at end of file +items = [ + "aaa", + "bbb", + "ccc", + "ddd", + "eee", + "fff", + "ggg", + "hhh", + "iii", + "jjj", + "kkk" +]
XmllintFixer
Format xml files using xmllint.
Risky: it depends on the configuration of xmllint.
Configuration options:
command(string[]): the command to run and its arguments listed as separate entries; defaults to['xmllint']cwd(string,null): the working directory or null to use the working dir of the current PHP process; defaults tonullenv(array): the environment variables or null to use the same environment as the current PHP process; defaults to[]extensions(string[]): the supported file extensions are used for formatting; defaults to['xml', 'xml.dist']input(string,null): the input as stream resource, scalar or \Traversable, or null for no input; defaults tonulloptions(array): the command options to run listed as separate entries; defaults to[]timeout(float,int,null): the timeout in seconds or null to disable; defaults to10wrap_attributes_min_attrs(int): minimum number of xml tag attributes for force wrap attribute options; defaults to5
Sample1: configuration(default)
-<phpunit bootstrap="vendor/autoload.php" colors="true" failOnDeprecation="true" failOnRisky="true" failOnWarning="true"> +<?xml version="1.0" encoding="UTF-8"?> +<phpunit + bootstrap="vendor/autoload.php" + colors="true" + failOnDeprecation="true" + failOnRisky="true" + failOnWarning="true" +> <php> - <ini name="memory_limit" value="-1" /> - <env name="DUMP_LIGHT_ARRAY" value=""></env> + <ini name="memory_limit" value="-1"/> + <env name="DUMP_LIGHT_ARRAY" value=""/> </php> <source> - <include> - <directory>src/</directory> - </include> + <include> + <directory>src/</directory> + </include> </source> -</phpunit> \ No newline at end of file +</phpunit>
YamlfmtFixer
Format yaml files using yamlfmt.
Risky: it depends on the configuration of yamlfmt.
Configuration options:
command(string[]): the command to run and its arguments listed as separate entries; defaults to['yamlfmt']cwd(string,null): the working directory or null to use the working dir of the current PHP process; defaults tonullenv(array): the environment variables or null to use the same environment as the current PHP process; defaults to[]extensions(string[]): the supported file extensions are used for formatting; defaults to['yaml', 'yml']input(string,null): the input as stream resource, scalar or \Traversable, or null for no input; defaults tonulloptions(array): the command options to run listed as separate entries; defaults to[]timeout(float,int,null): the timeout in seconds or null to disable; defaults to10
Sample1: configuration(default)
issues: - types: [ opened ] \ No newline at end of file + types: [opened]
Sample2: configuration(default)
to_be_merged: &tbm key1: value1 merged_map: - <<: *tbm \ No newline at end of file + !!merge <<: *tbm
Sample3: configuration(default)
-commands: > +commands: >- [ -f "/usr/local/bin/foo" ] && echo "skip install" || - go install github.com/foo/foo@latest \ No newline at end of file + go install github.com/foo/foo@latest
ZhlintFixer
Format zh_CN.md files using zhlint.
Risky: it depends on the configuration of zhlint.
Configuration options:
command(string[]): the command to run and its arguments listed as separate entries; defaults to['zhlint']cwd(string,null): the working directory or null to use the working dir of the current PHP process; defaults tonullenv(array): the environment variables or null to use the same environment as the current PHP process; defaults to[]extensions(string[]): the supported file extensions are used for formatting; defaults to['zh_CN.md']input(string,null): the input as stream resource, scalar or \Traversable, or null for no input; defaults tonulloptions(array): the command options to run listed as separate entries; defaults to[]timeout(float,int,null): the timeout in seconds or null to disable; defaults to10
Sample1: configuration(default)
-3 minute(s) left 中文 +3 minute(s)left 中文 -case-abbr:Pure JavaScript (a.k.a. Vanilla) 中文 +case-abbr:Pure JavaScript(a.k.a. Vanilla)中文 -case-backslash:a \# b 中文\# __中文__ \# 中文 __\#__ __中文__\#中文__\#__ +case-backslash:a \# b 中文\# __中文__ \# 中文 __\#__ __中文__\#中文 __\#__ -case-traditional:a「b『c』d」e 中文 +case-traditional:a “b ‘c’ d” e 中文 -mark-raw:a `b` c `d`e`f` g`h`i 中文 +mark-raw:a `b` c `d` e `f` g `h` i 中文 -mark-type:a__[b](x)__c__[ d ](y)__e 中文 +mark-type:a__[b](x)__c__ [d](y) __e 中文 -space-brackets:(x)a(b)c (d )e( f) g ( h ) i(j)k (l) m __( a )__ b( __c__ )d(e) 中文 +space-brackets:(x)a(b)c(d)e(f)g(h)i(j)k(l)m__(a)__b(__c__)d(e)中文 -space-punctuation:中文 。 中文(中文)中文。中文 . 中文(中文)中文. +space-punctuation:中文。中文(中文)中文。中文。中文(中文)中文。 -space-quotations: a " hello world " b 中文 +space-quotations:a “hello world” b 中文 -unify-punctuation:中文,中文 (中文) 中文'中文'中文"中文"中文 (中文)(中文)中文 (中文)。 \ No newline at end of file +unify-punctuation:中文,中文(中文)中文 ‘中文’ 中文 “中文” 中文(中文)(中文)中文(中文)。 \ No newline at end of file
JsonFixer
Format json files using json_encode().
Risky: it depends on the configuration of json_encode().
Configuration options:
decode_flags(int): the flags to use when decoding JSON; defaults to0encode_flags(int): the flags to use when encoding JSON; defaults to4194752extensions(string[]): the supported file extensions are used for formatting; defaults to['json']indent_string(string): the string to use for indentation; defaults to' '
Sample1: configuration(default)
{
- "phrase": "\u4f60\u597d\uff01"
+ "phrase": "你好!"
}
Sample2: configuration(['indent_string' => ' '])
{
- "name": "guanguans/php-cs-fixer-custom-fixers",
- "keywords": [
- "dev",
- "fixer",
- "standards"
- ],
- "authors": [
- {
- "name": "guanguans",
- "email": "ityaozm@gmail.com",
- "homepage": "https://github.com/guanguans"
- }
- ]
+ "name": "guanguans/php-cs-fixer-custom-fixers",
+ "keywords": [
+ "dev",
+ "fixer",
+ "standards"
+ ],
+ "authors": [
+ {
+ "name": "guanguans",
+ "email": "ityaozm@gmail.com",
+ "homepage": "https://github.com/guanguans"
+ }
+ ]
}
SqlOfDoctrineSqlFormatterFixer
Format sql files using doctrine/sql-formatter.
Risky: it depends on the configuration of doctrine/sql-formatter.
Configuration options:
extensions(string[]): the supported file extensions are used for formatting; defaults to['sql']indent_string(string): the SQL string with HTML styles and formatting wrapped in a <pre> tag; defaults to' '
Sample1: configuration(default)
-SELECT customer_id, customer_name, COUNT(order_id) as total -FROM customers INNER JOIN orders ON customers.customer_id = orders.customer_id -GROUP BY customer_id, customer_name -HAVING COUNT(order_id) > 5 -ORDER BY COUNT(order_id) DESC; \ No newline at end of file +SELECT + customer_id, + customer_name, + COUNT(order_id) AS total +FROM + customers + INNER JOIN orders ON customers.customer_id = orders.customer_id +GROUP BY + customer_id, + customer_name +HAVING + COUNT(order_id) > 5 +ORDER BY + COUNT(order_id) DESC;
Sample2: configuration(['indent_string' => ' '])
-SELECT customer_id, customer_name, COUNT(order_id) as total -FROM customers INNER JOIN orders ON customers.customer_id = orders.customer_id -GROUP BY customer_id, customer_name -HAVING COUNT(order_id) > 5 -ORDER BY COUNT(order_id) DESC; \ No newline at end of file +SELECT + customer_id, + customer_name, + COUNT(order_id) AS total +FROM + customers + INNER JOIN orders ON customers.customer_id = orders.customer_id +GROUP BY + customer_id, + customer_name +HAVING + COUNT(order_id) > 5 +ORDER BY + COUNT(order_id) DESC;
SqlOfPhpmyadminSqlParserFixer
Format sql files using phpmyadmin/sql-parser.
Risky: it depends on the configuration of phpmyadmin/sql-parser.
Configuration options:
clause_newline(bool): whether each clause should be on a new line; defaults totrueextensions(string[]): the supported file extensions are used for formatting; defaults to['sql']indent_parts(bool): whether each part of each clause should be indented; defaults totrueindentation(string,null): the string used for indentation; defaults tonullline_ending(string,null): the line ending used; defaults tonullparts_newline(bool): whether each part should be on a new line; defaults totrueremove_comments(bool): whether comments should be removed or not; defaults tofalse
Sample1: configuration(default)
-SELECT customer_id, customer_name, COUNT(order_id) as total -FROM customers INNER JOIN orders ON customers.customer_id = orders.customer_id -GROUP BY customer_id, customer_name -HAVING COUNT(order_id) > 5 -ORDER BY COUNT(order_id) DESC; \ No newline at end of file +SELECT + customer_id, + customer_name, + COUNT(order_id) AS total +FROM + customers +INNER JOIN orders ON customers.customer_id = orders.customer_id +GROUP BY + customer_id, + customer_name +HAVING + COUNT(order_id) > 5 +ORDER BY + COUNT(order_id) +DESC + ;
Sample2: configuration(['clause_newline' => false])
-SELECT customer_id, customer_name, COUNT(order_id) as total -FROM customers INNER JOIN orders ON customers.customer_id = orders.customer_id -GROUP BY customer_id, customer_name -HAVING COUNT(order_id) > 5 -ORDER BY COUNT(order_id) DESC; \ No newline at end of file +SELECT customer_id, customer_name, COUNT(order_id) AS total FROM customers INNER JOIN orders ON customers.customer_id = orders.customer_id GROUP BY customer_id, customer_name HAVING COUNT(order_id) > 5 ORDER BY COUNT(order_id) +DESC;
Sample3: configuration(['indentation' => ' '])
-SELECT customer_id, customer_name, COUNT(order_id) as total -FROM customers INNER JOIN orders ON customers.customer_id = orders.customer_id -GROUP BY customer_id, customer_name -HAVING COUNT(order_id) > 5 -ORDER BY COUNT(order_id) DESC; \ No newline at end of file +SELECT + customer_id, + customer_name, + COUNT(order_id) AS total +FROM + customers +INNER JOIN orders ON customers.customer_id = orders.customer_id +GROUP BY + customer_id, + customer_name +HAVING + COUNT(order_id) > 5 +ORDER BY + COUNT(order_id) +DESC + ;
Composer scripts
composer checks:required
composer php-cs-fixer-custom-fixers:update-fixers-document
composer php-cs-fixer:fix
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.