trayto-com/php-coding-standards
Composer 安装命令:
composer require trayto-com/php-coding-standards
包简介
Common coding-standard utils, tools and rules used across our PHP projects in trayto.com
README 文档
README
Common coding-standard utils, tools and rules used across our PHP projects in trayto.com
symplify/easy-coding-standard (ECS) is used under the hood. Follow configuration instructions there. Phar version is used so there should be no conflicts with projects dependencies.
Parallel Lint is available as well.
Further reading:
- How to Migrate From PHP_CodeSniffer to EasyCodingStandard in 7 Steps
- How to Migrate From PHP CS Fixer to EasyCodingStandard in 6 Steps
Installation instructions
composer require --dev trayto-com/php-coding-standards
Usage
You can use ECS directly in CLI but we do recommend to customise default rules:
vendor/bin/ecs check src tests --config vendor/trayto-com/php-coding-standards/definitions/ecs-default.php
Run PHP Parallel Lint:
vendor/bin/parallel-lint --exclude temp --exclude vendor .
Hint: do run linter before any other Standards check or Tests to fail fast in case of typo in your code
Customise ECS rules and custom usage
Recommended is to create your own configuration for project and define cache folder for EasyCodingStandard as well.
Create php file in your project root, for example ecs.php:
<?php declare(strict_types=1); use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; return static function (ContainerConfigurator $configurator): void { // make sure you import correct file $configurator->import(__DIR__ . '/vendor/trayto-com/php-coding-standards/definitions/ecs-default.php'); $services = $configurator->services(); // ... customise your services $parameters = $configurator->parameters(); // .. customise your parameters $parameters->set( Option::CACHE_DIRECTORY, __DIR__ . '/temp/ecs' ); };
统计信息
- 总下载量: 65
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-09-29