guanguans / php-cs-fixer-custom-fixers
Use php-cs-fixer to format bats,blade.php,Dockerfile,env,json,md,mdx,sh,sql,tex,text,toml,txt,xml,yaml...files. - 使用 php-cs-fixer 去格式化 bats、blade.php、Dockerfile、env、json、md、mdx、sh、sql、tex、text、toml、txt、xml、yaml...文件。
Fund package maintenance!
Sponsors
Installs: 448
Dependents: 4
Suggesters: 0
Security: 0
Stars: 4
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
- dg/bypass-finals: ^1.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.9
- fakerphp/faker: ^1.24
- guanguans/rector-rules: ^1.0
- mockery/mockery: ^1.6
- nette/utils: ^3.2 || ^4.0
- pestphp/pest: ^1.23 || ^2.0 || ^3.0 || ^4.0
- php-cs-fixer/phpunit-constraint-isidenticalstring: ^1.6
- 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.5
- rector/rector: ^2.3
- 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].
README
Note
Use php-cs-fixer to format bats,blade.php,Dockerfile,env,json,md,mdx,sh,sql,tex,text,toml,txt,xml,yaml...files. - 使用 php-cs-fixer 去格式化 bats、blade.php、Dockerfile、env、json、md、mdx、sh、sql、tex、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()) );
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 # Fix with 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', 'mdx', 'tex']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[]single_blank_line_at_eof('\n','\r\n',null): the line ending to use at the end of the file; defaults tonullskip_paths(string[]): list of paths to skip; defaults to[]timeout(float,int,null): the timeout in seconds or null to disable; defaults to10
Sample1: configuration(default)
-Hello世界! +Hello 世界!
Sample2: configuration(['options' => ['--type' => 'txt']])
-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[]single_blank_line_at_eof('\n','\r\n',null): the line ending to use at the end of the file; defaults tonullskip_paths(string[]): list of paths to skip; 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
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> +@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[]single_blank_line_at_eof('\n','\r\n',null): the line ending to use at the end of the file; defaults tonullskip_paths(string[]): list of paths to skip; 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 + # comment 2 + && bar \ + # comment 3 + && baz
Sample2: configuration(['options' => ['--indent' => 2]])
-RUN foo \ - # comment 1 -&& \ -# comment 2 -bar && \ -# comment 3 -baz +RUN foo \ + # comment 1 + # 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[]single_blank_line_at_eof('\n','\r\n',null): the line ending to use at the end of the file; defaults tonullskip_paths(string[]): list of paths to skip; defaults to[]timeout(float,int,null): the timeout in seconds or null to disable; defaults to10
Sample1: configuration(default)
-FOO= BAR -BAR = FOO +BAR=FOO +FOO=BAR
Sample2: configuration(['options' => ['--plain' => true]])
-FOO=${BAR -BAR="$BAR}" +BAR="${BAR}" +FOO=${BAR}
Sample3: configuration(['options' => ['--plain' => true]])
-FOO=BAR BAZ +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[]single_blank_line_at_eof('\n','\r\n',null): the line ending to use at the end of the file; defaults tonullskip_paths(string[]): list of paths to skip; defaults to[]timeout(float,int,null): the timeout in seconds or null to disable; defaults to10
Sample1: configuration(default)
## 全角数字 -> 这件蛋糕只卖 1000 元。 +> 这件蛋糕只卖 1000 元。
Sample2: configuration(['options' => ['--suppress-warnings' => true]])
## 块引用空格 -> 摇旗呐喊的热情 +> 摇旗呐喊的热情 ->携光阴渐远去 +> 携光阴渐远去
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[]single_blank_line_at_eof('\n','\r\n',null): the line ending to use at the end of the file; defaults tonullskip_paths(string[]): list of paths to skip; 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 ** +* <https://link.com> +* [this is link](https://link.com ) +* **bold text**
Sample2: configuration(['options' => ['--no-globs' => true]])
# 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 ** +* <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[]single_blank_line_at_eof('\n','\r\n',null): the line ending to use at the end of the file; defaults tonullskip_paths(string[]): list of paths to skip; 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 ** +* [this is link](https://link.com ) +* **bold text**
Sample2: configuration(['options' => ['--dot' => true]])
# 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 ** +* [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[]single_blank_line_at_eof('\n','\r\n',null): the line ending to use at the end of the file; defaults tonullskip_paths(string[]): list of paths to skip; 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[]single_blank_line_at_eof('\n','\r\n',null): the line ending to use at the end of the file; defaults tonullskip_paths(string[]): list of paths to skip; 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 + 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 +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[]single_blank_line_at_eof('\n','\r\n',null): the line ending to use at the end of the file; defaults tonullskip_paths(string[]): list of paths to skip; 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;
Sample2: configuration(['options' => ['--nocolor' => true]])
-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;
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[]single_blank_line_at_eof('\n','\r\n',null): the line ending to use at the end of the file; defaults tonullskip_paths(string[]): list of paths to skip; 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;
Sample2: configuration(['options' => ['--parsing-errors' => true]])
-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;
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[]single_blank_line_at_eof('\n','\r\n',null): the line ending to use at the end of the file; defaults tonullskip_paths(string[]): list of paths to skip; 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. +jQuery is JavaScript library.
Sample2: configuration(['options' => ['--rule' => 'terminology', '--no-color' => true]])
-jquery is javascript library. +jQuery is JavaScript library.
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[]single_blank_line_at_eof('\n','\r\n',null): the line ending to use at the end of the file; defaults tonullskip_paths(string[]): list of paths to skip; defaults to[]timeout(float,int,null): the timeout in seconds or null to disable; defaults to10
Sample1: configuration(default)
key1 = "value1"
-
key2 = "value2"
Sample2: configuration(['options' => ['--diff' => true]])
-items = [ - "a", - "b", - "c" -] +items = ["a", "b", "c"]
Sample3: configuration(['options' => ['--diff' => true]])
-items = ["aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk"] +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[]single_blank_line_at_eof('\n','\r\n',null): the line ending to use at the end of the file; defaults tonullskip_paths(string[]): list of paths to skip; 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>
Sample2: configuration(['options' => ['--noblanks' => true]])
-<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>
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[]single_blank_line_at_eof('\n','\r\n',null): the line ending to use at the end of the file; defaults tonullskip_paths(string[]): list of paths to skip; defaults to[]timeout(float,int,null): the timeout in seconds or null to disable; defaults to10
Sample1: configuration(default)
issues: - types: [ opened ] + types: [opened]
Sample2: configuration(['options' => ['-verbose' => true]])
to_be_merged: &tbm key1: value1 merged_map: - <<: *tbm + !!merge <<: *tbm
Sample3: configuration(['options' => ['-verbose' => true]])
-commands: > +commands: >- [ -f "/usr/local/bin/foo" ] && echo "skip install" || 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[]single_blank_line_at_eof('\n','\r\n',null): the line ending to use at the end of the file; defaults tonullskip_paths(string[]): list of paths to skip; 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:中文,中文 (中文) 中文'中文'中文"中文"中文 (中文)(中文)中文 (中文)。 +unify-punctuation:中文,中文(中文)中文 ‘中文’ 中文 “中文” 中文(中文)(中文)中文(中文)。
Sample2: configuration(['options' => ['--config' => null]])
-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:中文,中文 (中文) 中文'中文'中文"中文"中文 (中文)(中文)中文 (中文)。 +unify-punctuation:中文,中文(中文)中文 ‘中文’ 中文 “中文” 中文(中文)(中文)中文(中文)。
JsonFixer
Format json files.
Risky: it depends on the configuration.
Configuration options:
decode_flags(int): the flags to use when decoding JSON; defaults to0encode_flags(int): the flags to use when encoding JSON; defaults to7342016extensions(string[]): the supported file extensions are used for formatting; defaults to['json']indent_string(' ',' ','\t'): the string to use for indentation; defaults to' 'single_blank_line_at_eof('\n','\r\n',null): the line ending to use at the end of the file; defaults to'\n'skip_paths(string[]): list of paths to skip; 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(' ',' ','\t'): the SQL string with HTML styles and formatting wrapped in a <pre> tag; defaults to' 'single_blank_line_at_eof('\n','\r\n',null): the line ending to use at the end of the file; defaults to'\n'skip_paths(string[]): list of paths to skip; 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; +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; +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(' ',' ','\t',null): the string used for indentation; defaults tonullline_ending('\n','\r\n',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 tofalsesingle_blank_line_at_eof('\n','\r\n',null): the line ending to use at the end of the file; defaults to'\n'skip_paths(string[]): list of paths to skip; 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; +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; +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; +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:install-command-line-tools --dry-run
composer php-cs-fixer-custom-fixers:install-command-line-tools -vvv
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.