PHPackages                             guanguans/php-cs-fixer-custom-fixers - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. guanguans/php-cs-fixer-custom-fixers

ActiveLibrary[Testing &amp; Quality](/categories/testing)

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...文件。

1.2.1(1mo ago)42.8k10MITPHPPHP &gt;=7.4CI passing

Since Dec 13Pushed 1mo agoCompare

[ Source](https://github.com/guanguans/php-cs-fixer-custom-fixers)[ Packagist](https://packagist.org/packages/guanguans/php-cs-fixer-custom-fixers)[ Docs](https://github.com/guanguans/php-cs-fixer-custom-fixers)[ Fund](https://guanguans.github.io/sponsors)[ RSS](/packages/guanguans-php-cs-fixer-custom-fixers/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (101)Versions (15)Used By (10)

php-cs-fixer-custom-fixers
==========================

[](#php-cs-fixer-custom-fixers)

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...文件。 A set of custom fixers for friendsofphp/php-cs-fixer. - 一套针对 `friendsofphp/php-cs-fixer` 的自定义修复器。

[![tests](https://github.com/guanguans/php-cs-fixer-custom-fixers/actions/workflows/tests.yml/badge.svg)](https://github.com/guanguans/php-cs-fixer-custom-fixers/actions/workflows/tests.yml)[![php-cs-fixer](https://github.com/guanguans/php-cs-fixer-custom-fixers/actions/workflows/php-cs-fixer.yml/badge.svg)](https://github.com/guanguans/php-cs-fixer-custom-fixers/actions/workflows/php-cs-fixer.yml)[![codecov](https://camo.githubusercontent.com/363f6c101adc334f6eb0eb6350308cd64bb3a096f21c037703e1a7da956d24dc/68747470733a2f2f636f6465636f762e696f2f67682f6775616e6775616e732f7068702d63732d66697865722d637573746f6d2d6669786572732f67726170682f62616467652e7376673f746f6b656e3d3052746753476f6d344b)](https://codecov.io/gh/guanguans/php-cs-fixer-custom-fixers)[![Latest Stable Version](https://camo.githubusercontent.com/a996baa13bfc9e43f258c8bda1fcd4fcb8dbc9717982452d3b3b29d7f49a6542/68747470733a2f2f706f7365722e707567782e6f72672f6775616e6775616e732f7068702d63732d66697865722d637573746f6d2d6669786572732f76)](https://packagist.org/packages/guanguans/php-cs-fixer-custom-fixers)[![GitHub release (with filter)](https://camo.githubusercontent.com/a0f02a9619032a63db44cd485d14d06c9e5140d1646097edf803e9995c12400f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6775616e6775616e732f7068702d63732d66697865722d637573746f6d2d666978657273)](https://github.com/guanguans/php-cs-fixer-custom-fixers/releases)[![Total Downloads](https://camo.githubusercontent.com/c0e0a847d9458d354b4e5fb7b9bfee09d6dc19d92fa1bc10c5de36e9626ea40a/68747470733a2f2f706f7365722e707567782e6f72672f6775616e6775616e732f7068702d63732d66697865722d637573746f6d2d6669786572732f646f776e6c6f616473)](https://packagist.org/packages/guanguans/php-cs-fixer-custom-fixers)[![License](https://camo.githubusercontent.com/5a779f45d0bc07ba6f78781c5b8593df62cb57716a0b11277c7418102dde3d90/68747470733a2f2f706f7365722e707567782e6f72672f6775616e6775616e732f7068702d63732d66697865722d637573746f6d2d6669786572732f6c6963656e7365)](https://packagist.org/packages/guanguans/php-cs-fixer-custom-fixers)

Requirement
-----------

[](#requirement)

- PHP &gt;= 7.4

Installation
------------

[](#installation)

```
composer require guanguans/php-cs-fixer-custom-fixers --dev --ansi -v
```

Usage
-----

[](#usage)

### In your php-cs-fixer configuration([sample](.php-cs-fixer-custom.php)) register fixers and use them

[](#in-your-php-cs-fixer-configurationsample-register-fixers-and-use-them)

```

+

-
-
+
+

-
-          src/
-
+
+      src/
+

```

Sample2: configuration(`['options' => ['--noblanks' => true]]`)

```
-
+
+

-
-
+
+

-
-          src/
-
+
+      src/
+

```

**YamlfmtFixer**Format `yaml` files using [`yamlfmt`](https://github.com/google/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 to `null`
- `env` (`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 to `null`
- `options` (`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 to `null`
- `skip_paths` (`string[]`): list of paths to skip; defaults to `[]`
- `timeout` (`float`, `int`, `null`): the timeout in seconds or null to disable; defaults to `10`

Sample1: configuration(`default`)

```
 issues:
-    types: [ opened ]
+  types: [opened]
```

Sample2: configuration(`['options' => ['-verbose' => true]]`)

```
 to_be_merged: &tbm
   key1: value1
 merged_map:
-  -
   [ -f "/usr/local/bin/foo" ] &&
   echo "skip install" ||
   go install github.com/foo/foo@latest
```

**ZhlintFixer**Format `zh_CN.md` files using [`zhlint`](https://github.com/zhlint-project/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 to `null`
- `env` (`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 to `null`
- `options` (`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 to `null`
- `skip_paths` (`string[]`): list of paths to skip; defaults to `[]`
- `timeout` (`float`, `int`, `null`): the timeout in seconds or null to disable; defaults to `10`

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 to `0`
- `encode_flags` (`int`): the flags to use when encoding JSON; defaults to `7342016`
- `extensions` (`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`](https://github.com/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 &lt;pre&gt; 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`](https://github.com/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 to `true`
- `extensions` (`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 to `true`
- `indentation` (`'  '`, `'    '`, `'\t'`, `null`): the string used for indentation; defaults to `null`
- `line_ending` (`'\n'`, `'\r\n'`, `null`): the line ending used; defaults to `null`
- `parts_newline` (`bool`): whether each part should be on a new line; defaults to `true`
- `remove_comments` (`bool`): whether comments should be removed or not; defaults to `false`
- `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(`['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-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
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [guanguans](https://github.com/guanguans)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance91

Actively maintained with recent releases

Popularity27

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~8 days

Total

14

Last Release

46d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a49e4a0625bdf47c4e2924dcf07a053538d0c3a1e9287e8d6bfe68ed4017aa6f?d=identicon)[guanguans](/maintainers/guanguans)

---

Top Contributors

[![guanguans](https://avatars.githubusercontent.com/u/22309277?v=4)](https://github.com/guanguans "guanguans (77 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")

---

Tags

autocorrectblade-formatterdockerfmtdotenv-linterformatlintlint-mdmarkdownlintphp-cs-fixerpintshfmtsqlfluffsqrufftextlinttombityposxmllintyamlfmtzhlintformatterstandardstestingdevstatic analysisfixerformatlinterlinttyposphp-cs-fixerPintautocorrectblade-formatterdockerfmtdotenv-linterlint-mdmarkdownlintmarkdownlint-cli2shfmtsqlfluffsqrufftextlinttombixmllintyamlfmtzhlintdoctrine-sql-formatterphpmyadmin-sql-parser

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Type Coverage Yes

### Embed Badge

![Health badge](/badges/guanguans-php-cs-fixer-custom-fixers/health.svg)

```
[![Health](https://phpackages.com/badges/guanguans-php-cs-fixer-custom-fixers/health.svg)](https://phpackages.com/packages/guanguans-php-cs-fixer-custom-fixers)
```

###  Alternatives

[laravel/pint

An opinionated code formatter for PHP.

3.1k147.7M13.2k](/packages/laravel-pint)[stechstudio/laravel-php-cs-fixer

Easily format your Laravel Code with this Configuration file and accompanying artisan command.

146718.6k2](/packages/stechstudio-laravel-php-cs-fixer)[guanguans/laravel-soar

SQL optimizer and rewriter for laravel. - laravel 的 SQL 优化器和重写器。

2227.8k](/packages/guanguans-laravel-soar)[erickskrauch/php-cs-fixer-custom-fixers

A set of custom fixers for PHP-CS-Fixer

302.1M18](/packages/erickskrauch-php-cs-fixer-custom-fixers)[jubeki/laravel-code-style

Combine Custom Fixers with the ruleset of Laravel Pint to fix your code style in Laravel Applications/Packages.

56521.7k8](/packages/jubeki-laravel-code-style)[dragon-code/codestyler

A tool to automatically fix Coding Style Standards issues by The Dragon Code.

291.8M16](/packages/dragon-code-codestyler)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
