rebuy / php-cs
为 reBuy 项目配置的 PHP 代码风格
v1.0.0
2017-01-17 15:23 UTC
Requires
This package is auto-updated.
Last update: 2024-09-22 20:53:27 UTC
README
文件 .php_cs.dist 包含适用于 rebuy 的所有编码标准规则。您可以在 PHP-CS-Fixer 仓库中找到这些规则的描述。
示例
Travis 代码风格检查
vendor/bin/php-cs-fixer fix --config=vendor/rebuy/php-cs/.php_cs.dist -v --dry-run --using-cache=no `git diff --name-only --diff-filter=ACMRTUXB $TRAVIS_COMMIT_RANGE`
注意:如果您在自己的 .php_cs.dist
文件中定义了路径,您可能想要使用 --path-mode intersection
。
修复代码风格
vendor/bin/php-cs-fixer fix --config=vendor/rebuy/php-cs/.php_cs.dist yourDirectory/`
从 $yourBranch 修复到 master
vendor/bin/php-cs-fixer fix --config=.php_cs.dist `git diff --name-only --diff-filter=ACMRTUXB master`
覆盖规则
可能存在一些场景,您需要调整此处定义的规则,在这种情况下,您可以包含基本文件并将其扩展到您的需求。
<?php $config = include 'vendor/rebuy/php-cs/.php_cs.dist'; $currentRules = $config->getRules(); $newRules = [ 'phpdoc_no_empty_return' => false, ]; $config->setRules(array_merge($currentRules, $newRules));