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
17
17
{
18
18
/**
19
19
* Error violation code.
20
- *
21
- * @var string
22
20
*/
23
- protected $ warningCode = 'FoundObsoleteAttribute ' ;
21
+ const WARNING_CODE = 'FoundObsoleteAttribute ' ;
24
22
25
23
/**
26
24
* @inheritdoc
@@ -43,6 +41,16 @@ public function process(File $phpcsFile, $stackPtr)
43
41
}
44
42
45
43
$ 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
+ }
46
54
47
55
$ foundElements = $ xml ->xpath ('/config/module ' );
48
56
if ($ foundElements === false ) {
@@ -58,7 +66,7 @@ public function process(File $phpcsFile, $stackPtr)
58
66
$ phpcsFile ->addWarning (
59
67
'The "version" attribute is obsolete. Use "setup_version" instead. ' ,
60
68
$ stackPtr ,
61
- $ this -> warningCode
69
+ self :: WARNING_CODE
62
70
);
63
71
}
64
72
@@ -67,7 +75,7 @@ public function process(File $phpcsFile, $stackPtr)
67
75
'The "active" attribute is obsolete. The list of active modules ' .
68
76
'is defined in deployment configuration. ' ,
69
77
$ stackPtr ,
70
- $ this -> warningCode
78
+ self :: WARNING_CODE
71
79
);
72
80
}
73
81
}
You can’t perform that action at this time.
0 commit comments