arispati/phpcs-pre-commit
最新稳定版本:v1.2.1
Composer 安装命令:
composer require arispati/phpcs-pre-commit
包简介
Run phpcs before git commit
README 文档
README
Run phpcs before git commit
Table of Contents
Requirement
- PHP >= ^8.2 | ^8.3
- Laravel >= ^10.0 | ^11.0
Installation
- Add this command to your composer.json on script section at
post-install-cmdandpost-update-cmdattribute
@php artisan arispati:phpcs-install
// composer.json { ... "scripts": { "post-install-cmd": [ "@php artisan arispati:phpcs-install" ], "post-update-cmd": [ "@php artisan arispati:phpcs-install" ], }, ... }
- Then install the package with composer
composer require --dev arispati/phpcs-pre-commit
- Now when you commit the changes and got an error, its look like this
[PRE-COMMIT] Running PHP_CodeSniffer using the PSR12 standard E 1 / 1 (100%) FILE: ...~/HomeController.php -------------------------------------------------------------------------------- FOUND 5 ERRORS AFFECTING 4 LINES -------------------------------------------------------------------------------- 11 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 4 11 | ERROR | [x] Expected 1 space after closing parenthesis; found newline 12 | ERROR | [x] Line indented incorrectly; expected at least 8 spaces, found 4 13 | ERROR | [x] Line indented incorrectly; expected at least 12 spaces, found 8 14 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 4 -------------------------------------------------------------------------------- PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY -------------------------------------------------------------------------------- Time: 138ms; Memory: 10MB [PRE-COMMIT] Please fix all of the violations or commit with the --no-verify option
Uninstall
- Run this command to remove git hook script
php artisan arispati:phpcs-uninstall
- Remove composer script
@php artisan arispati:phpcs-installbothpost-install-cmdandpost-update-cmdattribute - Then remove the package with composer
composer remove --dev arispati/phpcs-pre-commit
统计信息
- 总下载量: 228
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-06-07