@@ -31,52 +31,52 @@ class FileCommentSniff implements Sniff
3131 *
3232 * @var array
3333 */
34- protected $ tags = array (
35- '@package ' => array (
36- 'required ' => true ,
37- 'allow_multiple ' => false ,
38- ) ,
39- '@subpackage ' => array (
40- 'required ' => false ,
41- 'allow_multiple ' => false ,
42- ) ,
43- '@category ' => array (
44- 'required ' => false ,
45- 'allow_multiple ' => false ,
46- ) ,
47- '@author ' => array (
48- 'required ' => true ,
49- 'allow_multiple ' => true ,
50- ) ,
51- '@copyright ' => array (
52- 'required ' => false ,
53- 'allow_multiple ' => true ,
54- ) ,
55- '@license ' => array (
56- 'required ' => true ,
57- 'allow_multiple ' => false ,
58- ) ,
59- '@link ' => array (
60- 'required ' => false ,
61- 'allow_multiple ' => true ,
62- ) ,
63- '@since ' => array (
64- 'required ' => false ,
65- 'allow_multiple ' => false ,
66- ) ,
67- '@version ' => array (
68- 'required ' => false ,
69- 'allow_multiple ' => false ,
70- ) ,
71- '@see ' => array (
72- 'required ' => false ,
73- 'allow_multiple ' => true ,
74- ) ,
75- '@deprecated ' => array (
76- 'required ' => false ,
77- 'allow_multiple ' => false ,
78- ) ,
79- ) ;
34+ protected $ tags = [
35+ '@package ' => [
36+ 'required ' => true ,
37+ 'allow_multiple ' => false ,
38+ ] ,
39+ '@subpackage ' => [
40+ 'required ' => false ,
41+ 'allow_multiple ' => false ,
42+ ] ,
43+ '@category ' => [
44+ 'required ' => false ,
45+ 'allow_multiple ' => false ,
46+ ] ,
47+ '@author ' => [
48+ 'required ' => true ,
49+ 'allow_multiple ' => true ,
50+ ] ,
51+ '@copyright ' => [
52+ 'required ' => false ,
53+ 'allow_multiple ' => true ,
54+ ] ,
55+ '@license ' => [
56+ 'required ' => true ,
57+ 'allow_multiple ' => false ,
58+ ] ,
59+ '@link ' => [
60+ 'required ' => false ,
61+ 'allow_multiple ' => true ,
62+ ] ,
63+ '@since ' => [
64+ 'required ' => false ,
65+ 'allow_multiple ' => false ,
66+ ] ,
67+ '@version ' => [
68+ 'required ' => false ,
69+ 'allow_multiple ' => false ,
70+ ] ,
71+ '@see ' => [
72+ 'required ' => false ,
73+ 'allow_multiple ' => true ,
74+ ] ,
75+ '@deprecated ' => [
76+ 'required ' => false ,
77+ 'allow_multiple ' => false ,
78+ ] ,
79+ ] ;
8080
8181
8282 /**
@@ -86,7 +86,7 @@ class FileCommentSniff implements Sniff
8686 */
8787 public function register ()
8888 {
89- return array ( T_OPEN_TAG ) ;
89+ return [ T_OPEN_TAG ] ;
9090
9191 }//end register()
9292
@@ -156,7 +156,7 @@ public function process(File $phpcsFile, $stackPtr)
156156 $ nextContentPtr = $ phpcsFile ->findNext (T_WHITESPACE , ($ commentCloser + 1 ), null , true );
157157 $ lineDiff = ($ tokens [$ nextContentPtr ]['line ' ] - $ tokens [$ commentCloser ]['line ' ]);
158158 if ($ lineDiff === 1 ) {
159- $ data = array ( 1 ) ;
159+ $ data = [ 1 ] ;
160160 $ error = 'Expected %s empty line after file doc comment ' ;
161161 $ fix = $ phpcsFile ->addFixableError ($ error , ($ commentCloser + 1 ), 'NoEmptyLineAfterFileDocComment ' , $ data );
162162 if ($ fix === true ) {
@@ -194,8 +194,8 @@ protected function processTags(File $phpcsFile, $stackPtr, $commentStart)
194194
195195 $ commentEnd = $ tokens [$ commentStart ]['comment_closer ' ];
196196
197- $ foundTags = array () ;
198- $ tagTokens = array () ;
197+ $ foundTags = [] ;
198+ $ tagTokens = [] ;
199199 foreach ($ tokens [$ commentStart ]['comment_tags ' ] as $ tag ) {
200200 $ name = $ tokens [$ tag ]['content ' ];
201201 if (isset ($ this ->tags [$ name ]) === false ) {
@@ -204,10 +204,10 @@ protected function processTags(File $phpcsFile, $stackPtr, $commentStart)
204204
205205 if ($ this ->tags [$ name ]['allow_multiple ' ] === false && isset ($ tagTokens [$ name ]) === true ) {
206206 $ error = 'Only one %s tag is allowed in a %s comment ' ;
207- $ data = array (
208- $ name ,
209- $ docBlock ,
210- ) ;
207+ $ data = [
208+ $ name ,
209+ $ docBlock ,
210+ ] ;
211211 $ phpcsFile ->addError ($ error , $ tag , 'Duplicate ' .ucfirst (substr ($ name , 1 )).'Tag ' , $ data );
212212 }
213213
@@ -217,10 +217,10 @@ protected function processTags(File $phpcsFile, $stackPtr, $commentStart)
217217 $ string = $ phpcsFile ->findNext (T_DOC_COMMENT_STRING , $ tag , $ commentEnd );
218218 if ($ string === false || $ tokens [$ string ]['line ' ] !== $ tokens [$ tag ]['line ' ]) {
219219 $ error = 'Content missing for %s tag in %s comment ' ;
220- $ data = array (
221- $ name ,
222- $ docBlock ,
223- ) ;
220+ $ data = [
221+ $ name ,
222+ $ docBlock ,
223+ ] ;
224224 $ phpcsFile ->addError ($ error , $ tag , 'Empty ' .ucfirst (substr ($ name , 1 )).'Tag ' , $ data );
225225 continue ;
226226 }
@@ -232,10 +232,10 @@ protected function processTags(File $phpcsFile, $stackPtr, $commentStart)
232232 if (isset ($ tagTokens [$ tag ]) === false ) {
233233 if ($ tagData ['required ' ] === true ) {
234234 $ error = 'Missing %s tag in %s comment ' ;
235- $ data = array (
236- $ tag ,
237- $ docBlock ,
238- ) ;
235+ $ data = [
236+ $ tag ,
237+ $ docBlock ,
238+ ] ;
239239 $ phpcsFile ->addError ($ error , $ commentEnd , 'Missing ' .ucfirst (substr ($ tag , 1 )).'Tag ' , $ data );
240240 }
241241
@@ -244,7 +244,7 @@ protected function processTags(File $phpcsFile, $stackPtr, $commentStart)
244244 $ method = 'process ' .substr ($ tag , 1 );
245245 if (method_exists ($ this , $ method ) === true ) {
246246 // Process each tag if a method is defined.
247- call_user_func (array ( $ this , $ method) , $ phpcsFile , $ tagTokens [$ tag ]);
247+ call_user_func ([ $ this , $ method] , $ phpcsFile , $ tagTokens [$ tag ]);
248248 }
249249 }
250250
@@ -254,10 +254,10 @@ protected function processTags(File $phpcsFile, $stackPtr, $commentStart)
254254
255255 if ($ foundTags [$ pos ] !== $ tag ) {
256256 $ error = 'The tag in position %s should be the %s tag ' ;
257- $ data = array (
258- ($ pos + 1 ),
259- $ tag ,
260- ) ;
257+ $ data = [
258+ ($ pos + 1 ),
259+ $ tag ,
260+ ] ;
261261 $ phpcsFile ->addError ($ error , $ tokens [$ commentStart ]['comment_tags ' ][$ pos ], ucfirst (substr ($ tag , 1 )).'TagOrder ' , $ data );
262262 }
263263
@@ -302,10 +302,10 @@ protected function processPackage(File $phpcsFile, array $tags)
302302 if ($ isInvalidPackage === true ) {
303303 $ error = 'Package name "%s" is not valid. Use "%s" instead ' ;
304304 $ validName = trim ($ newName , '_ ' );
305- $ data = array (
306- $ content ,
307- $ validName ,
308- ) ;
305+ $ data = [
306+ $ content ,
307+ $ validName ,
308+ ] ;
309309 $ phpcsFile ->addWarning ($ error , $ tag , 'InvalidPackage ' , $ data );
310310 }
311311 }//end foreach
@@ -415,7 +415,7 @@ protected function processCopyright(File $phpcsFile, array $tags)
415415 }
416416
417417 $ content = $ tokens [($ tag + 2 )]['content ' ];
418- $ matches = array () ;
418+ $ matches = [] ;
419419 if (preg_match ('/^([0-9]{4})((.{1})([0-9]{4}))? (.+)$/ ' , $ content , $ matches ) !== 0 ) {
420420 // Check earliest-latest year order.
421421 if ($ matches [3 ] !== '' ) {
@@ -456,7 +456,7 @@ protected function processLicense(File $phpcsFile, array $tags)
456456 }
457457
458458 $ content = $ tokens [($ tag + 2 )]['content ' ];
459- $ matches = array () ;
459+ $ matches = [] ;
460460 preg_match ('/^([^\s]+)\s+(.*)/ ' , $ content , $ matches );
461461
462462 if (count ($ matches ) !== 3 ) {
@@ -467,7 +467,7 @@ protected function processLicense(File $phpcsFile, array $tags)
467467 // Check the url is before the text part if it's included.
468468 $ parts = explode (' ' , $ content );
469469 if ((count ($ parts ) > 1 )) {
470- $ matches = array () ;
470+ $ matches = [] ;
471471 preg_match ("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i " , $ parts [0 ], $ matches );
472472 if (count ($ matches ) !== 1 ) {
473473 $ error = 'The URL must come before the license name ' ;
@@ -497,12 +497,12 @@ protected function processLink(File $phpcsFile, array $tags)
497497 }
498498
499499 $ content = $ tokens [($ tag + 2 )]['content ' ];
500- $ matches = array () ;
500+ $ matches = [] ;
501501
502502 // Check the url is before the text part if it's included.
503503 $ parts = explode (' ' , $ content );
504504 if ((count ($ parts ) > 1 )) {
505- $ matches = array () ;
505+ $ matches = [] ;
506506 preg_match ("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i " , $ parts [0 ], $ matches );
507507 if (count ($ matches ) !== 1 ) {
508508 $ error = 'The URL must come before the description ' ;
@@ -535,7 +535,7 @@ protected function processVersion(File $phpcsFile, array $tags)
535535 // Split into parts if content has a space.
536536 $ parts = explode (' ' , $ content );
537537 // Check if the first part contains a semantic version number.
538- $ matches = array () ;
538+ $ matches = [] ;
539539 preg_match ('/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/ ' , $ parts [0 ], $ matches );
540540
541541 if (strstr ($ content , 'CVS: ' ) === false
0 commit comments