Easy Coding Standard 使用教程

Easy Coding Standard 使用教程

easy-coding-standardThe Easiest way to add coding standard to your PHP project项目地址:https://gitcode.com/gh_mirrors/ea/easy-coding-standard

项目的目录结构及介绍

Easy Coding Standard (ECS) 是一个用于 PHP 项目的代码风格检查和格式化工具。以下是其基本目录结构:

easy-coding-standard/
├── bin/
├── build/
├── config/
├── docs/
├── patches/
├── src/
├── templates/
├── tests-released/
├── tests/
├── .editorconfig
├── .gitattributes
├── .gitignore
├── LICENSE
├── README.md
├── composer.json
├── ecs.php
├── full_ecs_build.sh
├── phpstan.neon
├── phpunit.xml
├── prefix-code.sh
├── rector.php
├── scoper.php

目录介绍

  • bin/: 包含可执行文件。
  • build/: 构建相关文件。
  • config/: 配置文件。
  • docs/: 文档文件。
  • patches/: 补丁文件。
  • src/: 源代码文件。
  • templates/: 模板文件。
  • tests-released/: 已发布的测试文件。
  • tests/: 测试文件。
  • .editorconfig: 编辑器配置文件。
  • .gitattributes: Git 属性配置文件。
  • .gitignore: Git 忽略配置文件。
  • LICENSE: 许可证文件。
  • README.md: 项目说明文件。
  • composer.json: Composer 配置文件。
  • ecs.php: ECS 配置文件。
  • full_ecs_build.sh: 完整构建脚本。
  • phpstan.neon: PHPStan 配置文件。
  • phpunit.xml: PHPUnit 配置文件。
  • prefix-code.sh: 前缀代码脚本。
  • rector.php: Rector 配置文件。
  • scoper.php: Scoper 配置文件。

项目的启动文件介绍

ECS 的启动文件是 ecs.php,它位于项目的根目录下。这个文件用于配置 ECS 的规则和检查路径。

启动文件示例

<?php

declare(strict_types=1);

use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

return static function (ECSConfig $ecsConfig): void {
    $ecsConfig->sets([SetList::SYMPLIFY]);
};

启动命令

vendor/bin/ecs check

项目的配置文件介绍

ECS 的配置文件是 ecs.php,它允许你定义检查规则和路径。

配置文件示例

<?php

declare(strict_types=1);

use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

return static function (ECSConfig $ecsConfig): void {
    $ecsConfig->sets([SetList::SYMPLIFY]);
    $ecsConfig->paths([__DIR__ . '/src', __DIR__ . '/tests']);
};

配置项

  • sets: 定义使用的规则集。
  • paths: 定义检查的路径。

通过这些配置,你可以自定义 ECS 的行为,以适应你的项目需求。

easy-coding-standardThe Easiest way to add coding standard to your PHP project项目地址:https://gitcode.com/gh_mirrors/ea/easy-coding-standard

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

芮舒淑

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值