plumthedev / yii2-php-cs-fixer-config
Yii2 PHP编码规范配置
1.2.0
2019-12-14 03:03 UTC
Requires
- ext-json: *
- friendsofphp/php-cs-fixer: ^2.16
- yiisoft/yii2: ~2.0.0
- yiisoft/yii2-dev: ^2.0
Requires (Dev)
- phpunit/phpunit: 4.3.*
This package is auto-updated.
Last update: 2024-09-04 22:02:40 UTC
README
Yii2 PHP CS Fixer Config
为Yii2项目提供的PHP CS Fixer配置。包含配置和查找器,默认排除Yii2应用程序的基本和高级目录。
规则集来自Yii 2生态系统,并与它自动更新。
安装
$ composer require --dev plumthedev/yii2-php-cs-fixer-config
使用
在项目根目录下创建配置文件.php_cs
<?php $composerJsonPath = __DIR__ . '/composer.json'; $composerJson = file_get_contents($composerJsonPath); $composerProject = json_decode($composerJson); $currentYear = date('Y'); $projectHeader = <<<HEADER Yii2 PHP CS Fixer Config @author Kacper Pruszynski (plumthedev) @link https://github.com/plumthedev/yii2-php-cs-fixer-config @copyright Copyright (c) 2019 - {$currentYear} plumthedev @license https://github.com/plumthedev/yii2-php-cs-fixer-config/blob/master/LICENSE @version {$composerProject->version} HEADER; use plumthedev\PhpCsFixer\Config; $csConfig = Config::create(); // CS Config setup $csConfig->mergeRules([ 'header_comment' => [ 'header' => $projectHeader, 'commentType' => 'PHPDoc', 'separate' => 'bottom', ] ]); // CS Finder setup $csConfigFinder = $csConfig->getFinder(); $csConfigFinder->in(__DIR__); // set current project directory $csConfig->setFinder($csConfigFinder); return $csConfig;
运行测试
PHPUnit
$ composer unit-tests
PHP CS Fixer
$ composer cs-fix
贡献
这个库是开源的,所以如果你想贡献,你可以。
请将错误报告、建议和拉取请求提交到GitHub问题跟踪器。
许可证
本项目使用MIT许可证 - 详细内容请参阅LICENSE文件。