File tree Expand file tree Collapse file tree 1 file changed +21
-8
lines changed Expand file tree Collapse file tree 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)
4141 try {
4242 $ xml = simplexml_load_string ($ this ->getFormattedXML ($ phpcsFile ));
4343 } 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 );
5249 return ;
5350 }
5451
@@ -87,6 +84,22 @@ public function process(File $phpcsFile, $stackPtr)
8784 }
8885 }
8986
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+
90103 /**
91104 * Check if the element passed is in the currently sniffed line
92105 *
You can’t perform that action at this time.
0 commit comments