thuanpt / pscs-commit-hook

提交前进行PHPCS检查

安装: 72

依赖: 0

建议者: 0

安全: 0

星级: 0

关注者: 1

分支: 0

开放问题: 0

语言:PowerShell

类型:脚本

v1.0 2020-05-13 04:58 UTC

This package is auto-updated.

Last update: 2024-09-12 16:22:24 UTC


README

关于

自动安装git预提交钩子,用于运行PHP Code Sniffer代码检查以符合PSR2编码标准。它仅检查要提交的文件。

灵感来自使用composer、git钩子和phpcs强制执行代码标准https://github.com/smgladkovskiy/phpcs-git-pre-commit 以及 https://gist.github.com/BrizzleRocker/62ed61b37acf05344d4bce894e719251。安装程序检查托管机器上的操作系统并安装平台所需的钩子。

安装

使用composer require命令安装 thuanpt/phpcs-commit-hook

composer require "thuanpt/phpcs-commit-hook"

或者,可以在您的composer.json文件中手动包含对 thuanpt/phpcs-commit-hook 的依赖关系

{
    "require-dev": {
        "thuanpt/phpcs-commit-hook": "*"
    }
}

为了启用代码嗅探,请将 post-install-cmdpost-update-cmd 添加到 composer.json 安装脚本中

"scripts": {
    "post-install-cmd": [
        "PHPCodeChecker\\Installer::postInstall"
    ],
    "post-update-cmd": [
        "PHPCodeChecker\\Installer::postInstall"
    ]
}

然后运行 composer installcomposer update。如果 pre-commit 钩子已存在,则会安装或更新。

使用方法

运行 git commit,预提交钩子将检查您的提交文件,就像您运行

php phpcs.phar --standard=PSR2 --colors --encoding=utf-8 -n -p /path/to/file.php