File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -303,8 +303,13 @@ jobs:
303303 cd e2e/report-ignores-without-comments
304304 OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan --error-format=raw")
305305 echo "$OUTPUT"
306- ../bashunit -a contains 'test.php:4:Ignore with identifier variable.undefined has no comment' "$OUTPUT"
306+ ../bashunit -a contains 'test.php:4:Ignore with identifier variable.undefined has no comment.' "$OUTPUT"
307+ ../bashunit -a contains 'test.php:4:Variable $undefined might not be defined.' "$OUTPUT"
307308 ../bashunit -a not_contains 'test.php:7' "$OUTPUT"
309+ ../bashunit -a contains 'test.php:10:Ignoring all errors on a line is not allowed.' "$OUTPUT"
310+ ../bashunit -a contains 'test.php:10:Variable $yetAnotherUndefined might not be defined.' "$OUTPUT"
311+ ../bashunit -a contains 'test.php:12:Ignoring all errors on a line is not allowed.' "$OUTPUT"
312+ ../bashunit -a contains 'test.php:12:Variable $yetYetAnotherUndefined might not be defined.' "$OUTPUT"
308313
309314 steps :
310315 - name : Harden the runner (Audit all outbound calls)
Original file line number Diff line number Diff line change 55
66// @phpstan-ignore variable.undefined (this one has a comment so no error)
77echo $ anotherUndefined ;
8+
9+ // @phpstan-ignore-next-line
10+ echo $ yetAnotherUndefined ;
11+
12+ echo $ yetYetAnotherUndefined ; // @phpstan-ignore-line
Original file line number Diff line number Diff line change @@ -135,6 +135,17 @@ public function analyseFile(
135135 foreach ($ linesToIgnore as $ ignoredFile => $ lines ) {
136136 foreach ($ lines as $ line => $ identifiers ) {
137137 if ($ identifiers === null ) {
138+ $ fileErrors [] = (new Error (
139+ 'Ignoring all errors on a line is not allowed. ' ,
140+ $ ignoredFile ,
141+ $ line ,
142+ false ,
143+ $ ignoredFile ,
144+ null ,
145+ 'Use @phpstan-ignore with an identifier and a comment (in parentheses). ' ,
146+ ))->withIdentifier ('ignore.allLineErrors ' );
147+ unset($ linesToIgnore [$ ignoredFile ][$ line ]);
148+ unset($ unmatchedLineIgnores [$ ignoredFile ][$ line ]);
138149 continue ;
139150 }
140151
@@ -152,6 +163,8 @@ public function analyseFile(
152163 null ,
153164 'Explain why this ignore is necessary in parentheses after the identifier. ' ,
154165 ))->withIdentifier ('ignore.noComment ' );
166+ unset($ linesToIgnore [$ ignoredFile ][$ line ]);
167+ unset($ unmatchedLineIgnores [$ ignoredFile ][$ line ]);
155168 }
156169 }
157170 }
You can’t perform that action at this time.
0 commit comments