Skip to content

Commit 4486f89

Browse files
authored
Add condition to handle empty input (#7)
1 parent d1abe22 commit 4486f89

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

cs2pr

+10-8
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,18 @@ if ($argc === 1) {
3232
$exit = 0;
3333
$root = simplexml_load_string($xml);
3434

35-
foreach($root as $file) {
36-
$filename = (string)$file['name'];
35+
if($root) {
36+
foreach($root as $file) {
37+
$filename = (string)$file['name'];
3738

38-
foreach($file as $error) {
39-
$type = (string) $error['severity'];
40-
$line = (string) $error['line'];
41-
$message = (string) $error['message'];
39+
foreach($file as $error) {
40+
$type = (string) $error['severity'];
41+
$line = (string) $error['line'];
42+
$message = (string) $error['message'];
4243

43-
annotateCheck(annotateType($type), relativePath($filename), $line, $message);
44-
$exit = 1;
44+
annotateCheck(annotateType($type), relativePath($filename), $line, $message);
45+
$exit = 1;
46+
}
4547
}
4648
}
4749

0 commit comments

Comments
 (0)