File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -17,10 +17,8 @@ class ModuleXMLSniff implements Sniff
1717{
1818 /**
1919 * Error violation code.
20- *
21- * @var string
2220 */
23- protected $ warningCode = 'FoundObsoleteAttribute ' ;
21+ const WARNING_CODE = 'FoundObsoleteAttribute ' ;
2422
2523 /**
2624 * @inheritdoc
@@ -43,6 +41,16 @@ public function process(File $phpcsFile, $stackPtr)
4341 }
4442
4543 $ xml = simplexml_load_string ($ phpcsFile ->getTokensAsString (0 , 999999 ));
44+ if ($ xml === false ) {
45+ $ phpcsFile ->addError (
46+ sprintf (
47+ "Couldn't parse contents of '%s', check that they are in valid XML format " ,
48+ basename ($ phpcsFile ->getFilename ()),
49+ ),
50+ $ stackPtr ,
51+ self ::WARNING_CODE
52+ );
53+ }
4654
4755 $ foundElements = $ xml ->xpath ('/config/module ' );
4856 if ($ foundElements === false ) {
@@ -58,7 +66,7 @@ public function process(File $phpcsFile, $stackPtr)
5866 $ phpcsFile ->addWarning (
5967 'The "version" attribute is obsolete. Use "setup_version" instead. ' ,
6068 $ stackPtr ,
61- $ this -> warningCode
69+ self :: WARNING_CODE
6270 );
6371 }
6472
@@ -67,7 +75,7 @@ public function process(File $phpcsFile, $stackPtr)
6775 'The "active" attribute is obsolete. The list of active modules ' .
6876 'is defined in deployment configuration. ' ,
6977 $ stackPtr ,
70- $ this -> warningCode
78+ self :: WARNING_CODE
7179 );
7280 }
7381 }
You can’t perform that action at this time.
0 commit comments