pragmarx / laravelcs
PHP_CodeSniffer 定制的 Laravel 编码标准 Sniff
v0.1.0
2014-12-09 13:52 UTC
Requires
This package is auto-updated.
Last update: 2024-09-08 10:41:17 UTC
README
这是一个自定义 Sniff,用于检测违反规则并基于 Laravel 编码标准 重新格式化 PHP 源代码。
您的源代码将被检查 PSR-1 和 Laravel 的 "口味" PSR-2。
与 git 一起使用
克隆此仓库
git clone http://github.com/antonioribeiro/laravelcs LaravelCodeSniffer
执行 CodeSniffer
phpcs --standard=LaravelCodeSniffer/Standards/Laravel/ /path/to/your/project/files
与 Composer 一起使用
推荐的安装方式是使用以下命令全局安装
composer global require pragmarx/laravelcs
请确保您的 PATH 包含 ~/.composer/vendor/bin/
。
然后您将能够使用 Laravel 标准运行 PHP Code Sniffer
phpcs --standard=$HOME/.composer/vendor/pragmarx/laravelcs/Standards/Laravel/ /path/to/your/project/files
测试 Sniff
此 Sniff 使用 Laravel 框架源代码和一些更改进行了测试,以符合 PSR-2,需要进行一些更改,点击此处查看它们。那些是在 Filesystem.php 中发现并修复的违规行为。
--------------------------------------------------------------------------------
FOUND 14 ERRORS AFFECTING 11 LINES
--------------------------------------------------------------------------------
29 | ERROR | [x] Inline control structures are not allowed
44 | ERROR | [x] Inline control structures are not allowed
113 | ERROR | [x] Expected 1 new line after closing parenthesis; found " "
113 | ERROR | [x] Expected 1 newline after opening brace; 0 found
113 | ERROR | [x] Inline control structures are not allowed
113 | ERROR | [x] Closing brace must be on a line by itself
241 | ERROR | [x] Inline control structures are not allowed
247 | ERROR | [ ] Opening brace should be on the same line as the declaration
249 | ERROR | [x] Closing brace indented incorrectly; expected 2 spaces, found 3
310 | ERROR | [x] Inline control structures are not allowed
335 | ERROR | [x] Inline control structures are not allowed
343 | ERROR | [x] Inline control structures are not allowed
361 | ERROR | [x] Inline control structures are not allowed
384 | ERROR | [x] Inline control structures are not allowed
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 13 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
贡献
这里可能还有许多工作要做,所以请打开问题并提交 pull 请求。