airlst / php-cs-fixer-config
AirLST项目的PHP CS Fixer配置
2.6.0
2024-09-03 08:43 UTC
Requires
- php: ^8.2
- friendsofphp/php-cs-fixer: 3.64.0
Requires (Dev)
- airlst/phpstan-config: ^8.1.0
- airlst/rector-config: ^4.3.5
- ergebnis/composer-normalize: ^2.43
README
AirLST项目的PHP CS Fixer配置。
安装
您可以通过Composer安装此包
composer require --dev airlst/php-cs-fixer-config
使用方法
在项目根目录创建一个.php-cs-fixer.php
文件,内容如下
<?php declare(strict_types=1); $factory = new Airlst\PhpCsFixerConfig\Factory(['src', 'tests']); return $factory->create();
Factory
类的构造函数接受一个数组,该数组包含要扫描并修复的PHP文件路径。您可以传递任意数量的路径给它。
运行CS Fixer
使用以下命令运行CS Fixer
./vendor/bin/php-cs-fixer fix
PHP 8.2支持
默认情况下,它使用PHP 8.3作为目标版本。您可以通过在工厂对象上调用php82()
方法来切换到PHP 8.2。
<?php declare(strict_types=1); $factory = new Airlst\PhpCsFixerConfig\Factory(['src', 'tests']); return $factory->php82()->create();
仅支持PHP 8.2和8.3。
自定义规则
您可以通过在工厂对象上调用customRules
方法来向配置提供自定义规则。它将添加或覆盖工厂提供的现有规则。
<?php declare(strict_types=1); $factory = new Airlst\PhpCsFixerConfig\Factory(['src', 'tests']); return $factory ->customRules([ 'static_lambda' => true, 'no_null_property_initialization' => false, ]) ->create();
更新日志
请参阅更新日志以获取更多关于最近更改的信息。
贡献
请参阅贡献指南以获取详细信息。
许可证
MIT许可证(MIT)。请参阅许可证文件以获取更多信息。