axazara/php-cs

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

安装次数: 3,630

依赖者: 7

建议者: 0

安全性: 0

星标: 0

分支: 0

类型:package

v1.0 2023-09-03 17:29 UTC

This package is auto-updated.

Last update: 2024-09-22 12:17:05 UTC


README

此包提供了在 php-cs-fixer 中应用的配置,用于Axa Zara的PHP项目。这代表了Axa Zara PHP项目内应用的代码风格标准。

快速开始

第1步/3步

通过Composer安装此包

composer require --dev axazara/php-cs

第2步/3步

一旦安装了包,项目根目录将创建一个名为.php-cs-fixer.dist.php的文件,内容如下:

<?php

use AxaZara\CS\Finder;
use AxaZara\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
])

许可

这是一个开源软件,根据 MIT 许可 许可。

特别感谢