https://github.com/capsulescodes/php-cs-fixer-custom-fixers
A set of custom fixers for PHP CS Fixer
https://github.com/capsulescodes/php-cs-fixer-custom-fixers
code-standards code-style php php-cs-fixer static-analysis
Last synced: about 1 month ago
JSON representation
A set of custom fixers for PHP CS Fixer
- Host: GitHub
- URL: https://github.com/capsulescodes/php-cs-fixer-custom-fixers
- Owner: capsulescodes
- License: mit
- Created: 2023-12-26T22:22:49.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-06-01T22:40:46.000Z (8 months ago)
- Last Synced: 2025-06-02T08:36:27.891Z (8 months ago)
- Topics: code-standards, code-style, php, php-cs-fixer, static-analysis
- Language: PHP
- Homepage:
- Size: 58.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
## About
A set of custom fixers for [ PHP CS Fixer ](https://github.com/FriendsOfPHP/PHP-CS-Fixer).
> [!NOTE]
> This is in active development. New fixers will be introduced gradually.
## Fixers
### MethodChainingIndentationFixer
Indents each chained methods.
```diff
- Foo::bar()->baz()->qux()->quux()->corge();
+ Foo::bar()
+ ->baz()
+ ->qux()
+ ->quux()
+ ->corge();
```
> [!TIP]
> `single-line` : Set chains on single line `{true|false}`\
> `multi-line` : Set chains on next line if `{number}` chains
### MultipleLinesAfterImportsFixer
Adds a given number of lines after imports.
```diff
- use Baz;
- class Qux {}
+ use Baz;
+
+
+ class Qux {}
```
> [!TIP]
> `lines` : Set `{number}` blank lines after the use statements block
### SpacesInsideSquareBracesFixer :
Adds spaces inside squared braces.
```diff
- $foo = ["bar", "baz", "qux"];
+ $foo = [ "bar", "baz", "qux" ];
```
> [!TIP]
> `space` : Set space inside parentheses `{single|none}`.
## Installation
1. Install dependency
```bash
composer require --dev capsulescodes/php-cs-fixer-custom-fixers
```
## Usage
- Using `.php-cs-fixer.php` config file by [ PHP CS Fixer ](https://github.com/junstyle/vscode-php-cs-fixer)
```php
registerCustomFixers( [
...
new \CapsulesCodes\PhpCsFixerCustomFixers\Fixers()
...
or
...
new \CapsulesCodes\PhpCsFixerCustomFixers\MethodChainingIndentationFixer(),
new \CapsulesCodes\PhpCsFixerCustomFixers\MultipleLinesAfterImportsFixer(),
new \CapsulesCodes\PhpCsFixerCustomFixers\SpacesInsideSquareBracesFixer()
...
] )
->setRules( [
...
"CapsulesCodes/method_chaining_indentation" : { "multi-line" : 4 },
"CapsulesCodes/multiple_lines_after_imports" : { "lines" : 2 },
"CapsulesCodes/spaces_inside_square_braces" : { "space" : "single" }
...
] )
;
```
---
## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
## Credits
[Capsules Codes](https://github.com/capsulescodes)
## License
[MIT](https://choosealicense.com/licenses/mit/)