litus / php-cs-fixer
此包已被废弃,不再维护。未建议替代包。
dev-master
2018-03-02 11:31 UTC
Requires
- friendsofphp/php-cs-fixer: @stable
This package is not auto-updated.
Last update: 2019-01-31 13:08:16 UTC
README
此项目包含对 php-cs-fixer 的自定义修复器。如果 PHP 文件不包含许可证头,则将其添加。如果 PHP 文件中的许可证头与提供的文件不同,则更新 PHP 文件。
使用方法
将以下内容添加到 composer.json
{ ... "require": { "litus/php-cs": "dev-master" }, "repositories": [ { "type": "vcs", "url": "https://github.com/LitusProject/PhpCodeStyle" } ], ... }
创建一个 .license_header
文件(或选择任何你想要的文件名)并将许可证头放入此文件。
注意:添加许可证头的非格式化版本!
创建一个 .php_cs
文件
<?php $finder = Symfony\CS\Finder\DefaultFinder::create() ->in(__DIR__); return Litus\CodeStyle\Config\Config::create() ->setLicense(__DIR__ . '/.license_header') // or the filename you chose ->finder($finder);
代码风格
我们遵循以下代码风格: PSR-2 和 PSR-4,但有以下例外
- 每个文件只有一个
use
语句,而不是每个声明一个语句 - 有时我们在私有变量和方法前加上下划线 ('_')
备注:这里的“有时”表示我们在错误地这样做 - 我们不为主项目使用供应商命名空间 Litus