gomzyakov/php-style

该软件包已被弃用且不再维护。作者建议使用https://github.com/gomzyakov/php-cs-fixer-config软件包代替。

基于PSR-12的`php-cs-fixer`代码风格配置。


README

packagist downloads_count license codecov

此软件包允许您在不复制粘贴配置文件的情况下,在整个项目中共享相同的php-cs-fixer格式化规则。

快速入门

第1步,共3步

使用Composer安装friendsofphp/php-cs-fixer和此软件包

composer require --dev friendsofphp/php-cs-fixer gomzyakov/php-cs-fixer-config

第2步,共3步

然后在项目的根目录下创建文件.php-cs-fixer.dist.php,内容如下

<?php

use Gomzyakov\CS\Finder;
use Gomzyakov\CS\Config;

// Routes for analysis with `php-cs-fixer`
$routes = ['./src', './tests'];

return Config::createWithFinder(Finder::createWithRoutes($routes));

根据项目源代码的位置更改$routes的值。

第3步,共3步

就这样!现在您可以使用以下命令查找代码风格违规

./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --dry-run

然后使用以下命令完全修复它们

./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php

配置

您必须向Finder::createWithRoutes()调用传递一组路由。例如,对于Laravel项目,这将是这样

Finder::createWithRoutes(['./app', './config', './database', './resources', './routes', './tests'])

此外,您还可以向Config::createWithFinder()调用传递自定义规则集

Config::createWithFinder($finder, [
    '@PHP81Migration'   => true,
    'array_indentation' => false
])

Laravel Pint

以下描述了结合使用friendsofphp/php-cs-fixer的样式。您还可以使用这些样式设置Laravel Pint

支持

如果您发现任何软件包错误,请在当前存储库中创建一个问题

许可证

这是一个开源软件,使用MIT许可证

特别感谢