chieftools/php-cs-fixer

Opinionated PHP CS Fixer configuration for Chief Tools projects.

Maintainers

Package info

github.com/chieftools/php-cs-fixer

Homepage

Type:composer-plugin

pkg:composer/chieftools/php-cs-fixer

Statistics

Installs: 701

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.4 2026-06-09 11:28 UTC

This package is auto-updated.

Last update: 2026-06-09 11:29:27 UTC


README

Total Downloads Monthly Downloads Latest Stable Version License

Opinionated PHP CS Fixer configuration for Chief Tools projects.

Installation

Install the package as a development dependency:

composer require --dev chieftools/php-cs-fixer

Allow the Composer plugin so the shared .editorconfig can be copied to your project:

{
    "config": {
        "allow-plugins": {
            "chieftools/php-cs-fixer": true
        }
    }
}

Create a .php-cs-fixer.php file in your project:

<?php

$finder = PhpCsFixer\Finder::create()
    ->in(__DIR__ . '/app')
    ->in(__DIR__ . '/tests')
    ->in(__DIR__ . '/config')
    ->in(__DIR__ . '/routes')
    ->in(__DIR__ . '/database')
    ->name('*.php')
    ->ignoreDotFiles(true)
    ->ignoreVCS(true);

return ChiefTools\PhpCsFixer\Config::make($finder);

Custom project rules

Project rules may be merged on top of the Chief Tools defaults:

return ChiefTools\PhpCsFixer\Config::make($finder, [
    'yoda_style'      => true,
    'ordered_imports' => [
        'sort_algorithm' => 'alpha',
    ],
]);

EditorConfig

This package contains the canonical Chief Tools .editorconfig in the package root. When the Composer plugin is allowed, it copies that file into the consuming project on install and update.

The plugin:

  • creates .editorconfig when missing
  • skips it when it already matches the package version
  • overwrites it when it differs from the package version

If plugins are disabled, copy it manually from:

vendor/chieftools/php-cs-fixer/.editorconfig

Custom rules

ChiefTools/phpdoc_fqcn

This rule expands imported class names inside PHPDoc annotations:

  use App\Models\User;
  use Illuminate\Database\Eloquent\Relations\HasMany;

- /** @return HasMany<Domain> */
+ /** @return \Illuminate\Database\Eloquent\Relations\HasMany<\App\Models\Domain> */

Executable PHP type hints may still use normal imports.

ChiefTools/binary_operator_alignment

This rule keeps contiguous assignment and array-pair operators minimally aligned, while blank lines split alignment groups:

- $data      = [];
- $otherDate = $date
+ $data       = [];
+ $otherDate  = $date
      ->addDays(5);
  $commonDate = now();

ChiefTools/nested_method_chaining_indentation

This rule keeps nested argument method chains aligned with the first object operator on the expression line:

  return wrap(
      $service->items()
-         ->filter()
+             ->filter()
  );

Statement-level chains still use PHP CS Fixer's regular method_chaining_indentation behavior.