定制 matraux/php-cs-fixer-config 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

matraux/php-cs-fixer-config

Composer 安装命令:

composer require matraux/php-cs-fixer-config

包简介

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

README 文档

README

Latest Version on Packagist 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

PHP compatibility

This package provides separate major versions for different PHP baselines.

Version PHP
1.x 7.4+
2.x 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');

This configuration runs in risky mode by default. If you need a different rule profile, compose your own PHP-CS-Fixer config from the provided rule set definitions.

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 --diff --using-cache=no

Run code style fixer

vendor/bin/php-cs-fixer fix --using-cache=no

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.

统计信息

  • 总下载量: 473
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固