matraux/php-cs-fixer-config

Shared PHP-CS-Fixer configuration with reusable rule sets for PHP 8.3+.

Maintainers

Package info

github.com/matraux/php-cs-fixer-config

pkg:composer/matraux/php-cs-fixer-config

Statistics

Installs: 43

Dependents: 4

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-05-15 13:08 UTC

This package is auto-updated.

Last update: 2026-05-15 13:08:50 UTC


README

Latest Version on Packagist Last release License: MIT PHP Security Policy Contributing QA Status Issues Last Commit


Introduction

A PHP 8.3+ package that provides the shared MATRAUX configuration for friendsofphp/php-cs-fixer.

It exposes a ready-to-use Matraux\PhpCsFixer\Config for project .php-cs-fixer.dist.php files and reusable grouped rule sets for custom PHP-CS-Fixer configurations.

Useful for keeping formatting, imports, strict typing, class layout, PHPDoc cleanup, indentation, and line endings consistent across multiple PHP packages.


Features

  • Ready-to-use PHP-CS-Fixer configuration via Matraux\PhpCsFixer\Config
  • Public grouped rule sets for syntax, imports, operators, functions, PHPDoc, and classes
  • PER-CS baseline with automatic PHP migration rules
  • Strict typing, strict comparisons, strict parameters, and function alias cleanup
  • Import ordering, unused import removal, and fully qualified type normalization
  • Class member ordering and class element separation
  • Tabs and LF line endings configured by default
  • Risky PHP-CS-Fixer rules enabled explicitly

Installation

composer require --dev matraux/php-cs-fixer-config

Requirements

version PHP Note
1.0.0 8.3+ Support PHP 8.3

Examples

Full configuration

Create file .php-cs-fixer.dist.php or .php-cs-fixer.php in root.

<?php declare(strict_types=1);

use Matraux\PhpCsFixer\Config;

return new Config(__DIR__ . '/src');

Custom PHP-CS-Fixer configuration

<?php declare(strict_types=1);

use Matraux\PhpCsFixer\RuleSet\Sets\Imports;
use Matraux\PhpCsFixer\RuleSet\Sets\PhpDoc;
use PhpCsFixer\Config;

$imports = new Imports();
$phpDoc = new PhpDoc();

return (new Config())
	->registerCustomRuleSets([
		$imports,
		$phpDoc,
	])
	->setRules([
		'@PER-CS' => true,
		$imports->getName() => true,
		$phpDoc->getName() => true,
	]);

Run code style check

vendor/bin/php-cs-fixer check

Run code style fixer

vendor/bin/php-cs-fixer fix

Visual Studio Code

Visual Studio Code format setup is documented in Visual Studio Code.

Development

See Development for debug, static analysis, and coding standards.


Support

For bug reports and feature requests, please use the issue tracker.