kaiseki / php-coding-standard
分析 PHP 编码规范
dev-master
2024-03-05 08:46 UTC
Requires
- php: ^8.1
- friendsofphp/php-cs-fixer: ^3.32
This package is auto-updated.
Last update: 2024-09-05 09:55:17 UTC
README
PHP-CS-Fixer
将以下 .php-cs-fixer.dist.php
文件添加到项目的根目录。这将创建一个包含 . 中所有内容并排除 vendor 的基本配置。
<?php declare(strict_types=1); use Kaiseki\CodingStandard\PhpCsFixer\Config; return Config::get();
如果您需要更精细的目录指定,您可以传递一个自定义的 Finder。您还可以通过传递自己的规则作为第二个参数来覆盖规则。
<?php declare(strict_types=1); use Kaiseki\CodingStandard\PhpCsFixer\Config; use PhpCsFixer\Finder; $finder = Finder::create() ->in(__DIR__ . '/src'); $rules = [ // Your custom rules here ]; return Config::get($finder, $rules);
将此脚本添加到您的 composer.json
{ "scripts": { "cs-check": "php-cs-fixer fix --dry-run", "cs-fix": "php-cs-fixer fix --allow-risky=yes" } }