没有不值得去解决的问题,也没有不值得去学习的技术!

When executing PHPCS, it prompts the analysis of File: Found 1 Error Affecting 1 Line

PHP_CodeSniffer 对 PHP、JavaScript 和 CSS 文件进行标记,以检测和修复违反一组定义的编码标准的情况。执行 phpcs 时,提示 FILE: FOUND 1 ERROR AFFECTING 1 LINE 的分析

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

PHP_CodeSniffer 对 PHP、JavaScript 和 CSS 文件进行标记,以检测和修复违反一组定义的编码标准的情况。执行 phpcs 时,提示 FILE: FOUND 1 ERROR AFFECTING 1 LINE 的分析
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

先确认第一个文件,在 182 行,存在 ;; ,需要删除掉一个 ;
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

再确认第二个文件,分别在 66 、128 行。在 66 行,行缩进不正确;预计 8 个空格,找到 12 个。在 128 行,函数右大括号必须在正文的下一行;在大括号前找到 1 个空行。在 66 行,可以通过 IDE 格式化代码
Figure 3

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

执行 phpcs 时,不再提示
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

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理