1. PHP_CodeSniffer tokenizes PHP, JavaScript, and CSS files to detect and fix violations of a defined set of coding standards. When running phpcs, it reports “FILE: FOUND 1 ERROR AFFECTING 1 LINE”. The analysis is 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, checking the first file, line 182 contains ;;, and one ; needs to be removed. As shown in Figure 2.

3. Next, checking the second file at lines 66 and 128, respectively. At line 66, the line is indented incorrectly; 8 spaces were expected, but 12 were found. At line 128, the function closing brace must be on the line following the body; 1 blank line was found before the brace. For line 66, the code can be formatted using an IDE. As shown in Figure 3.

4. When running phpcs, the error is no longer reported. As shown in Figure 4.

