An open API service indexing awesome lists of open source software.

https://github.com/erickskrauch/php-cs-fixer-custom-fixers

A set of custom fixers for PHP-CS-Fixer
https://github.com/erickskrauch/php-cs-fixer-custom-fixers

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

Last synced: 10 months ago
JSON representation

A set of custom fixers for PHP-CS-Fixer

Awesome Lists containing this project

README

          

# PHP-CS-Fixer custom fixers

A set of custom fixers for [PHP-CS-Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer).

[![Latest Version on Packagist][ico-version]][link-packagist]
[![Total Downloads][ico-downloads]][link-downloads]
[![Software License][ico-license]](LICENSE.md)
[![Build Status][ico-build-status]][link-build-status]

## Installation

Run:

```sh
composer require --dev erickskrauch/php-cs-fixer-custom-fixers
```

Then in your configuration file (`.php-cs-fixer.php`) register fixers and use them:

```php
registerCustomFixers(new \ErickSkrauch\PhpCsFixer\Fixers())
->setRules([
'ErickSkrauch/align_multiline_parameters' => true,
// See the rest of the fixers below
]);
```

## Fixers

Table of contents:

* [`ErickSkrauch/align_multiline_parameters`](#erickskrauchalign_multiline_parameters) - Align multiline function params (or remove alignment).
* [`ErickSkrauch/blank_line_around_class_body`](#erickskrauchblank_line_around_class_body) - Add space inside class body.
* [`ErickSkrauch/blank_line_before_return`](#erickskrauchblank_line_before_return) - Add blank line before `return`.
* [`ErickSkrauch/line_break_after_statements`](#erickskrauchline_break_after_statements) - Add blank line after control structures.
* [`ErickSkrauch/multiline_if_statement_braces`](#erickskrauchmultiline_if_statement_braces) - Fix brace position for multiline `if` statements.
* [`ErickSkrauch/ordered_overrides`](#erickskrauchordered_overrides) - Sort overridden methods.
* [`ErickSkrauch/remove_class_name_method_usages`](#erickskrauchremove_class_name_method_usages-yii2) - Replace `::className()` with `:class` (Yii2).

### `ErickSkrauch/align_multiline_parameters`

Forces aligned or not aligned multiline function parameters:

```diff
--- Original
+++ New
@@ @@
function foo(
string $string,
- int $index = 0,
- $arg = 'no type',
- ...$variadic,
+ int $index = 0,
+ $arg = 'no type',
+ ...$variadic
): void {}
```

**Configuration:**

* `variables` - when set to `true`, forces variables alignment. On `false` forces strictly no alignment.
You can set it to `null` to disable touching of variables. **Default**: `true`.

* `defaults` - when set to `true`, forces defaults alignment. On `false` forces strictly no alignment.
You can set it to `null` to disable touching of defaults. **Default**: `false`.

### `ErickSkrauch/blank_line_around_class_body`

Ensure that a class body contains one blank line after its definition and before its end:

```diff
--- Original
+++ New
@@ @@
foo();
return 'okay';
}
```

### `ErickSkrauch/line_break_after_statements`

Ensures that there is one blank line above the next statements: `if`, `switch`, `for`, `foreach`, `while`, `do-while` and `try-catch-finally`.

```diff
--- Original
+++ New
@@ @@