triopsi/triopsics

Triopsi 代码规范(针对 phpcs)

安装: 93

依赖项: 1

建议者: 0

安全: 0

星级: 0

关注者: 1

分支: 0

开放问题: 0

类型:phpcodesniffer-standard

v1.0.0 2022-06-27 10:43 UTC

This package is auto-updated.

Last update: 2024-09-22 16:34:36 UTC


README

简介

本项目收集了 PHP_CodeSniffer 规则(sniffs),用于验证为 Triopsi Hosting 包开发的代码。它确保代码质量和遵循编码规范,特别是官方的 Triopsi Hosting 编码标准。

安装

需求

Triopsi Hosting 编码标准要求 PHP 5.4 或更高版本以及 PHP_CodeSniffer 版本 3.3.1 或更高。

独立

  1. 按照其 安装说明 安装 PHP_CodeSniffer(通过 Composer、Phar 文件、PEAR 或 Git checkout)。

    请确保 PHP_CodeSniffer 的版本与我们的 需求 相匹配,如果您,例如,使用 VVV

  2. 克隆 Triopsi Hosting 标准存储库

     git clone -b master https://github.com/Triopsi-Hosting/code-standard.git thcs
    
  3. 将其路径添加到 PHP_CodeSniffer 配置中

     phpcs --config-set installed_paths /path/to/thcs
    

    提示:另外,您可以通过将以下片段添加到您的自定义规则集中来告诉 PHP_CodeSniffer Triopsi 标准的路径

    <config name="installed_paths" value="/path/to/thcs" />

总结

cd ~/projects
git clone https://github.com/Triopsi-Hosting/code-standard.git thcs
git clone -b master https://github.com/Triopsi-Hosting/code-standard.git thcs
cd phpcs
./bin/phpcs --config-set installed_paths ../thcs

然后通过您的 .bashrc~/projects/phpcs/bin 目录添加到您的 PATH 环境变量中。

然后您应该会在运行 phpcs -i 时看到 Triopsi 等条目。

如何使用

命令行

在指定的文件或目录上运行 phpcs 命令行工具,例如

phpcs --standard=Triopsi index.php