susina/coding-standard
最新稳定版本:v2.3
Composer 安装命令:
composer require susina/coding-standard
包简介
Shared config for php-cs-fixer, based on PSR1 and PSR2
README 文档
README
Susina Coding Standard library is a set of php-cs-fixer rules for Susina project repository. It's based on PSR1 and PSR12, with the following differences:
- always use declare(strict_types=1) and put it at the beginning of the file, one space after
<?phpstatement. I.e.:<?php declare(strict_types=1); - always use short array syntax
- always put one space around string concatenation operator:
'string1' . 'string2'
Installation
Run
$ composer require --dev susina/coding-standard
Configuration
Create a .php-cs-fixer.php file in the root of your project:
<?php declare(strict_types=1); $config = new Susina\CodingStandard\Config(); $config->getFinder() ->in(__DIR__ . '/src') ->in(__DIR__ . '/tests') ->excludes(['fixtures']) ; return $config;
See php-cs-fixer documentation for further information.
Composer Scripts
Add to your composer.json file the following lines:
"scripts" : { "cs" : "php-cs-fixer fix -v --diff --dry-run", "cs-fix" : "php-cs-fixer fix -v --diff" }
Now you can check your code style by running:
composer cs
and you can fix it by:
composer cs-fix
Git
We suggest adding .php-cs-fixer.cache to .gitignore:
vendor/
.php-cs-fixer.cache
Travis
You can configure Travis to cache the .php-cs-fixer.cache file. Update your .travis.yml:
cache: directories: - $HOME/.php-cs-fixer
Then run php-cs-fixer in the script section:
script: - composer cs
Github Actions
You can configure Github actions to cache .php-cs-fixer.cache file. In your workflow,
into the Cache configuration step, simply add ~/.php-cs-fixer.cache under the path key:
- name: Cache multiple paths uses: actions/cache@v2 with: path: | ~/.php-cs-fixer.cache key: your-awesome-cache-key
License
This package is licensed under the Apache2 License. For full copyright information, please see LICENSE file, in this repository.
统计信息
- 总下载量: 3.59k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 6
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2020-04-08