Skip to content

Commit 05a090b

Browse files
authored
Don't add invalid regions to SARIF report (#3193)
1 parent 4123eff commit 05a090b

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

phpstan.neon.dist

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ parameters:
1313

1414
ignoreErrors:
1515
- '#Unsafe usage of new static#'
16-
- '#Call to an undefined method [a-zA-Z0-9\\_\<\>]+::[a-zA-Z]+\(\)#'
16+
- '#Call to an undefined method [a-zA-Z0-9\\_\<\>\(\)]+::[a-zA-Z]+\(\)#'
1717

1818
services:
1919
errorFormatter.sarif:

tests/PHPStan/SarifErrorFormatter.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ public function formatErrors(AnalysisResult $analysisResult, Output $output): in
6363
'uri' => $this->relativePathHelper->getRelativePath($fileSpecificError->getFile()),
6464
'uriBaseId' => self::URI_BASE_ID,
6565
],
66-
'region' => [
67-
'startLine' => $fileSpecificError->getLine(),
68-
],
6966
],
7067
],
7168
],
@@ -78,6 +75,10 @@ public function formatErrors(AnalysisResult $analysisResult, Output $output): in
7875
$result['properties']['tip'] = $fileSpecificError->getTip();
7976
}
8077

78+
if ($fileSpecificError->getLine() !== null) {
79+
$result['locations'][0]['physicalLocation']['region']['startLine'] = $fileSpecificError->getLine();
80+
}
81+
8182
$results[] = $result;
8283
}
8384

0 commit comments

Comments
 (0)