fusionspim/php-cs-fixer-config

该软件包已被弃用且不再维护。未建议替代软件包。

friendsofphp/php-cs-fixer的默认配置,由Fusions PIM开发团队使用

10.4.0 2022-08-19 08:28 UTC

This package is auto-updated.

Last update: 2022-12-02 12:41:59 UTC


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工具中,让您可以直观地检查所有可用的修复器和内置预设。这有助于识别新引入的规则,以及收紧(或采用现有规则的默认值)的机会。

PHP-CS-Fixer Configurator

致谢

灵感来源于localheinz/php-cs-fixer-configrefinery29/php-cs-fixer-config