fusionspim / php-cs-fixer-config
该软件包已被弃用且不再维护。未建议替代软件包。
friendsofphp/php-cs-fixer的默认配置,由Fusions PIM开发团队使用
10.4.0
2022-08-19 08:28 UTC
Requires
- php: ^8.0
- friendsofphp/php-cs-fixer: ^3.1.0
- kubawerlos/php-cs-fixer-custom-fixers: ^3.0
Requires (Dev)
- ergebnis/composer-normalize: ^2.13
README
此存储库提供了friendsofphp/php-cs-fixer的配置,我们使用它来验证和强制执行Fusions PIM中PHP代码的单一代码标准。
安装
运行composer require --dev fusionspim/php-cs-fixer-config
。
使用
在项目根目录创建配置文件.php-cs-fixer.dist.php
。
<?php return FusionsPim\PhpCsFixer\Factory::fromDefaults();
规则
默认规则可以在项目中通过传递一个可选数组来覆盖。
<?php return FusionsPim\PhpCsFixer\Factory::fromDefaults([ 'void_return' => false, // We'll do this later since it affects too many closures right now ]);
文件
检查项目根目录下的所有.php
、.phtml
和.phpt
文件(除了在Factory::DEFAULT_EXCLUDED_DIRS
中或以Factory::DEFAULT_EXCLUDED_NAME
命名的文件),尽管可以通过Finder
轻松地为项目重新配置。
<?php $config = FusionsPim\PhpCsFixer\Factory::fromDefaults(); $finder = $config->getFinder()->name('*.phtml')->notName('Factory.php'); return $config->setFinder($finder);
改进
将Factory::DEFAULT_RULES
粘贴到PHP-CS-Fixer Configurator工具中,让您可以直观地检查所有可用的修复器和内置预设。这有助于识别新引入的规则,以及收紧(或采用现有规则的默认值)的机会。
致谢
灵感来源于localheinz/php-cs-fixer-config和refinery29/php-cs-fixer-config。