421p/php-quality-tool-cli

智能伽马 PHP CLI 质量工具

1.0.0 2018-08-23 12:51 UTC

This package is auto-updated.

Last update: 2024-09-23 13:23:41 UTC


README

交互式工具将允许项目团队根据 pre-commit git 钩子保持常见的开发代码风格标准

此工具允许自动将 git pre-commit 钩子添加到本地开发机器,并运行一系列质量断言

  • PHPLint
  • PHPCS
  • php-cs-fixer
  • PHPMD
  • PhpSpec
  • PhpUnit (待办事项)
  • 提交信息具有 Jira 功能编号,例如 AB-123 (待办事项)

作为附加功能,它允许使用带有自动修复已提交文件的 php-cs-fixer

安装

composer require --dev 421p/php-quality-tool-cli

用法

vendor/bin/quality

可用选项

--config-folder # Folder that contains config file.
--config-file # Name of config file.
--no-commit-autofixed # Disables adding autofixed files to commit

配置

配置示例

# config.yml

phpmd: true
lint: true
phpcs: true
phpcs_standard: PSR2
phpfixer: true
phpfixer_standard: Symfony
phpspec: false
self_fix: true
exclude_dirs: /app/bin

PHPCS & php-cs-fixer

将启动断言,如果在提交中应用的文件中找到代码风格违规,则将提示自动修复这些违规并重新扫描文件。如果未提交 --no-commit-autofixed 选项,则自动修复的文件将自动添加到最新提交中。

PHPMD

工具将扫描 PhpMD 警告,但不会阻止提交,但会输出列表并提示重新扫描您的提交文件,如果您想通过 IDE 修复某些指示的警告。

Docker

选项 --no-commit-autofixed 在质量工具通过 git 钩子调用但在 Docker 容器内运行时很有用。否则,可能发生 2 个 git 进程冲突。