uptimeproject / php-cs-fixer-config
此软件包已被放弃,不再维护。没有建议的替代软件包。
UptimeProject.io PHP 代码的常用编码风格配置。
1.3.4
2022-09-08 07:23 UTC
Requires
- php: ^7.4 || ^8.0 || ^8.1
- friendsofphp/php-cs-fixer: ^3.0
This package is auto-updated.
Last update: 2022-10-04 15:55:00 UTC
README
这是UptimeProject.io项目中主要使用的FriendsOfPHP/php-cs-fixer配置。但如果你愿意,也可以在你的项目中使用它。另外,如果你想提出更改,请随意创建一个PR 😁
此软件包可用于PHP 7.4、8.0和8.1。
安装
composer require --dev uptimeproject/php-cs-fixer-config
PHP-CS-Fixer 2.0
如果你在项目中仍在使用PHP-CS-Fixer的v2.x版本,你应该使用此软件包的版本<1.2.x。
composer require --dev uptimeproject/php-cs-fixer-config:1.2.*
请注意,此版本不再维护,你应该升级到PHP-CS-Fixer的最新版本
用法
在你的项目根目录中创建一个.php-cs-fixer.php配置文件。
<?php $config = new UptimeProject\PhpCsFixerConfig\Config; $config->getFinder() ->in(__DIR__ . "/src") ->in(__DIR__ . "/tests"); return $config;
同时,请确保在git仓库中忽略.php_cs.cache文件。
添加/覆盖规则
可能存在你想要更改规则的情况。没问题,你可以按以下方式覆盖或添加规则
<?php $config = new UptimeProject\PhpCsFixerConfig\Config([ 'declare_strict_types' => true, ]); $config->getFinder() ->in(__DIR__ . "/src") ->in(__DIR__ . "/tests"); return $config;
当你这样做时,请注意,默认情况下允许有风险的修复器!
无风险修复器的示例
<?php $ruleOverrides = [ 'no_php4_constructor' => false, 'pow_to_exponentiation' => false, 'no_unneeded_final_method' => false, 'no_unreachable_default_argument_value' => false, 'php_unit_strict' => false, 'psr4' => false, ]; $config = new UptimeProject\PhpCsFixerConfig\Config($ruleOverrides, false); $config->getFinder() ->in(__DIR__ . '/src') ->in(__DIR__ . '/tests'); return $config;
许可协议
MIT许可协议(MIT)。有关更多信息,请参阅许可文件。