1. PHP_CodeSniffer marks PHP, JavaScript and CSS files to detect and repair violations of a set of defined encoding standards. When executing PHPCS, you will be prompted for the analysis of File: Found 1 Error Affecting 1 Line. as shown in Figure 1

PS E:\wwwroot\object> phpcs --standard=PSR1,PSR2,./ruleset.xml --ignore=config/us-zipcode.php app/ routes/ config/
FILE: ...root\object\app\Http\Controllers\CheckoutsController.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
182 | ERROR | [x] Each PHP statement must be on a line by itself
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
FILE: E:\wwwroot\object\app\Services\ThemeService.php
----------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
66 | ERROR | [x] Line indented incorrectly; expected 8 spaces,
| | found 12
66 | ERROR | [x] Closing brace indented incorrectly; expected 8
| | spaces, found 12
128 | ERROR | [x] Function closing brace must go on the next line
| | following the body; found 1 blank lines before
| | brace
----------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
Time: 56.87 secs; Memory: 66MB
PS E:\wwwroot\object>
2. First confirm the first file, on line 182, there is ;; , you need to delete a ;. as shown in Figure 2

3. Reconfirm the second file, on lines 66 and 128 respectively. In line 66, the line indentation is incorrect; it is expected that 8 spaces are expected, and 12 are found. At line 128, the curly braces of the function must be in the next line of the body; find 1 blank line before the braces. At line 66, the code can be formatted via the IDE. as shown in Figure 3

4. When executing phpcs, no longer prompt. as shown in Figure 4

需要长期技术维护或远程问题排查?
我是拥有 15+ 年经验的 PHP / Go 后端工程师,长期关注已有系统维护、Bug 修复、性能优化、服务器排查、WordPress 网站维护和小功能迭代。
如果你的项目遇到以下情况,可以先从一次小问题排查开始合作:
- ✅ PHP / Laravel / Yii2 老项目无人维护
- ✅ Go / Gin 后端接口需要排查或优化
- ✅ WordPress 网站访问慢、报错或插件冲突
- ✅ Nginx / MySQL / Redis / Linux 服务器异常
- ✅ CDN / Cloudflare / DNS / HTTPS 配置问题
- ✅ 需要长期远程技术支持或兼职维护
更多介绍请查看:关于我 & 合作
微信:13980074657
邮箱:shuijingwanwq@gmail.com
Telegram:@shuijingwan
GitHub:https://github.com/shuijingwan


发表回复