File tree 1 file changed +21
-8
lines changed
1 file changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -41,14 +41,11 @@ public function process(File $phpcsFile, $stackPtr)
41
41
try {
42
42
$ xml = simplexml_load_string ($ this ->getFormattedXML ($ phpcsFile ));
43
43
} catch (\Exception $ e ) {
44
- $ phpcsFile ->addError (
45
- sprintf (
46
- "Couldn't parse contents of '%s', check that they are in valid XML format " ,
47
- $ phpcsFile ->getFilename (),
48
- ),
49
- $ stackPtr ,
50
- self ::ERROR_CODE_XML
51
- );
44
+ $ this ->invalidXML ($ phpcsFile , $ stackPtr );
45
+ return ;
46
+ }
47
+ if ($ xml === false ) {
48
+ $ this ->invalidXML ($ phpcsFile , $ stackPtr );
52
49
return ;
53
50
}
54
51
@@ -87,6 +84,22 @@ public function process(File $phpcsFile, $stackPtr)
87
84
}
88
85
}
89
86
87
+ /**
88
+ * @param File $phpcsFile
89
+ * @param int $stackPtr
90
+ */
91
+ protected function invalidXML (File $ phpcsFile , int $ stackPtr ): void
92
+ {
93
+ $ phpcsFile ->addError (
94
+ sprintf (
95
+ "Couldn't parse contents of '%s', check that they are in valid XML format " ,
96
+ $ phpcsFile ->getFilename (),
97
+ ),
98
+ $ stackPtr ,
99
+ self ::ERROR_CODE_XML
100
+ );
101
+ }
102
+
90
103
/**
91
104
* Check if the element passed is in the currently sniffed line
92
105
*
You can’t perform that action at this time.
0 commit comments