prezly / code-style
Prezly 代码风格配置
v5.4.4
2024-09-12 10:44 UTC
Requires
- php: >=7.1
- symplify/easy-coding-standard: ^11.1
- dev-main
- v5.4.4
- v5.4.3
- v5.4.2
- v5.4.1
- v5.4.0
- v5.3.2
- v5.3.1
- v5.3.0
- v5.2.0
- v5.1.0
- v5.0.2
- v5.0.1
- v5.0.0
- v4.5.0
- v4.4.1
- v4.4.0
- v4.3.2
- v4.3.1
- v4.3.0
- v4.2.0
- v4.1.0
- v4.0.0
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.0.0
- 1.0.0
- dev-fix/eslint-config-next-peer-deps-version
- dev-chore/make-some-libs-to-be-peer-deps
- dev-dependabot/npm_and_yarn/http-cache-semantics-4.1.1
This package is auto-updated.
Last update: 2024-09-12 10:45:19 UTC
README
PHP 代码风格检查器(修复器)是用 Easy-Coding-Standard 构建的。
使用方法
-
(可选) 将前缀 ECS CLI 工具添加到您的 composer 需求中(如果您不喜欢与
simplify/easy-coding-standard
的巨大依赖列表解决冲突)。composer require --dev symplify/easy-coding-standard-prefixed
-
将 prezly/code-style 仓库作为 composer 依赖项链接
composer require prezly/code-style:~4.0
-
将提供的配置包含到您的项目中。
简单地在项目根目录下创建一个 ecs.php 文件,并将此包提供的 ecs.php 包含进去。
<?php // Include the stock prezly/code-style config as is. return require __DIR__ . '/vendor/prezly/code-style/ecs.php';
-
如果您需要扩展或覆盖标准配置,您当然可以通过在上面添加代码来实现
<?php declare(strict_types=1); use PhpCsFixer\Fixer\Operator\BinaryOperatorSpacesFixer; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; return static function (ContainerConfigurator $config): void { // Include the stock prezly/code-style config. (require __DIR__ . '/vendor/prezly/code-style/ecs.php')($config); $services = $config->services(); // Override stock preset configuration. $services->set(BinaryOperatorSpacesFixer::class)->call('configure', [ [ 'operators' => [ '=>' => 'align', ], ], ]); };
-
运行检查(您也可以配置 CI 在每次推送时运行此操作)
vendor/bin/ecs check src/
-
修复问题
vendor/bin/ecs check src/ --fix