Skip to content

Commit 7bc6fa5

Browse files
Merge pull request #48 from VincentLanglet/shortArray
Remove exclude pattern from ruleset and add more rules
2 parents 4161664 + 01c8b57 commit 7bc6fa5

File tree

63 files changed

+300
-228
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+300
-228
lines changed

SymfonyCustom/Sniffs/Arrays/ArrayDeclarationSniff.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ class ArrayDeclarationSniff implements Sniff
3838
*/
3939
public function register()
4040
{
41-
return array(
41+
return [
4242
T_ARRAY,
4343
T_OPEN_SHORT_ARRAY,
44-
);
44+
];
4545
}
4646

4747
/**
@@ -151,7 +151,7 @@ public function processSingleLineArray(File $phpcsFile, $stackPtr, $arrayStart,
151151
// Check if there are multiple values. If so, then it has to be multiple lines
152152
// unless it is contained inside a function call or condition.
153153
$valueCount = 0;
154-
$commas = array();
154+
$commas = [];
155155
for ($i = ($arrayStart + 1); $i < $arrayEnd; $i++) {
156156
// Skip bracketed statements, like function calls.
157157
if (T_OPEN_PARENTHESIS === $tokens[$i]['code']) {
@@ -182,7 +182,7 @@ public function processSingleLineArray(File $phpcsFile, $stackPtr, $arrayStart,
182182
if (T_WHITESPACE !== $tokens[($nextArrow - 1)]['code']) {
183183
$content = $tokens[($nextArrow - 1)]['content'];
184184
$error = 'Expected 1 space between "%s" and double arrow; 0 found';
185-
$data = array($content);
185+
$data = [$content];
186186
$fix = $phpcsFile->addFixableError($error, $nextArrow, 'NoSpaceBeforeDoubleArrow', $data);
187187
if (true === $fix) {
188188
$phpcsFile->fixer->addContentBefore($nextArrow, ' ');
@@ -192,7 +192,7 @@ public function processSingleLineArray(File $phpcsFile, $stackPtr, $arrayStart,
192192
if (1 !== $spaceLength) {
193193
$content = $tokens[($nextArrow - 2)]['content'];
194194
$error = 'Expected 1 space between "%s" and double arrow; %s found';
195-
$data = array($content, $spaceLength);
195+
$data = [$content, $spaceLength];
196196

197197
$fix = $phpcsFile->addFixableError($error, $nextArrow, 'SpaceBeforeDoubleArrow', $data);
198198
if (true === $fix) {
@@ -204,7 +204,7 @@ public function processSingleLineArray(File $phpcsFile, $stackPtr, $arrayStart,
204204
if (T_WHITESPACE !== $tokens[($nextArrow + 1)]['code']) {
205205
$content = $tokens[($nextArrow + 1)]['content'];
206206
$error = 'Expected 1 space between double arrow and "%s"; 0 found';
207-
$data = array($content);
207+
$data = [$content];
208208

209209
$fix = $phpcsFile->addFixableError($error, $nextArrow, 'NoSpaceAfterDoubleArrow', $data);
210210
if (true === $fix) {
@@ -215,7 +215,7 @@ public function processSingleLineArray(File $phpcsFile, $stackPtr, $arrayStart,
215215
if (1 !== $spaceLength) {
216216
$content = $tokens[($nextArrow + 2)]['content'];
217217
$error = 'Expected 1 space between double arrow and "%s"; %s found';
218-
$data = array($content, $spaceLength);
218+
$data = [$content, $spaceLength];
219219

220220
$fix = $phpcsFile->addFixableError($error, $nextArrow, 'SpaceAfterDoubleArrow', $data);
221221
if (true === $fix) {
@@ -300,7 +300,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
300300
$expected = ($currentIndent);
301301
$found = ($tokens[$arrayEnd]['column'] - 1);
302302
$error = 'Closing parenthesis not aligned correctly; expected %s space(s) but found %s';
303-
$data = array($expected, $found);
303+
$data = [$expected, $found];
304304

305305
$fix = $phpcsFile->addFixableError($error, $arrayEnd, 'CloseBraceNotAligned', $data);
306306
if (true === $fix) {
@@ -314,7 +314,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
314314

315315
$keyUsed = false;
316316
$singleUsed = false;
317-
$indices = array();
317+
$indices = [];
318318
$maxLength = 0;
319319

320320
if (T_ARRAY === $tokens[$stackPtr]['code']) {
@@ -340,7 +340,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
340340
) {
341341
// Let subsequent calls of this test handle nested arrays.
342342
if (T_DOUBLE_ARROW !== $tokens[$lastToken]['code']) {
343-
$indices[] = array('value' => $nextToken);
343+
$indices[] = ['value' => $nextToken];
344344
$lastToken = $nextToken;
345345
}
346346

@@ -369,7 +369,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
369369
continue;
370370
}
371371

372-
$currentEntry = array();
372+
$currentEntry = [];
373373

374374
if (T_COMMA === $tokens[$nextToken]['code']) {
375375
$stackPtrCount = 0;
@@ -410,10 +410,10 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
410410
}
411411

412412
$error = 'Expected 0 spaces between "%s" and comma; %s found';
413-
$data = array(
413+
$data = [
414414
$content,
415415
$spaceLength,
416-
);
416+
];
417417

418418
$fix = $phpcsFile->addFixableError($error, $nextToken, 'SpaceBeforeComma', $data);
419419
if (true === $fix) {
@@ -428,7 +428,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
428428
true
429429
);
430430

431-
$indices[] = array('value' => $valueContent);
431+
$indices[] = ['value' => $valueContent];
432432
$singleUsed = true;
433433
}
434434

@@ -540,7 +540,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
540540
$found = ($tokens[$first]['column'] - 1);
541541
if ($found !== $expected) {
542542
$error = 'Array value not aligned correctly; expected %s spaces but found %s';
543-
$data = array($expected, $found);
543+
$data = [$expected, $found];
544544

545545
$fix = $phpcsFile->addFixableError($error, $value['value'], 'ValueNotAligned', $data);
546546
if (true === $fix) {
@@ -636,7 +636,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
636636
$expected = ($indicesStart - 1);
637637
$found = ($tokens[$index['index']]['column'] - 1);
638638
$error = 'Array key not aligned correctly; expected %s spaces but found %s';
639-
$data = array($expected, $found);
639+
$data = [$expected, $found];
640640

641641
$fix = $phpcsFile->addFixableError($error, $index['index'], 'KeyNotAligned', $data);
642642

@@ -661,7 +661,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
661661
}
662662

663663
$error = 'Array double arrow not aligned correctly; expected %s space(s) but found %s';
664-
$data = array($expected, $found);
664+
$data = [$expected, $found];
665665

666666
if ('newline' !== $found || false === $this->ignoreNewLines) {
667667
$fix = $phpcsFile->addFixableError($error, $index['arrow'], 'DoubleArrowNotAligned', $data);
@@ -786,7 +786,7 @@ public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $
786786
$content = $tokens[($nextComma - 2)]['content'];
787787
$spaceLength = $tokens[($nextComma - 1)]['length'];
788788
$error = 'Expected 0 spaces between "%s" and comma; %s found';
789-
$data = array($content, $spaceLength);
789+
$data = [$content, $spaceLength];
790790

791791
$fix = $phpcsFile->addFixableError($error, $nextComma, 'SpaceBeforeComma', $data);
792792
if (true === $fix) {

SymfonyCustom/Sniffs/Classes/ClassDeclarationSniff.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ class ClassDeclarationSniff
1414
*/
1515
public function register()
1616
{
17-
return array(
17+
return [
1818
T_CLASS,
1919
T_INTERFACE,
2020
T_TRAIT,
21-
);
21+
];
2222
}
2323

2424
/**
@@ -39,7 +39,7 @@ public function process(File $phpcsFile, $stackPtr)
3939
return;
4040
}
4141

42-
$nextElement = $phpcsFile->findNext(array(T_WHITESPACE), $openingBrace + 1, null, true);
42+
$nextElement = $phpcsFile->findNext([T_WHITESPACE], $openingBrace + 1, null, true);
4343

4444
if ($tokens[$openingBrace]['line'] + 1 < $tokens[$nextElement]['line']) {
4545
$fix = $phpcsFile->addFixableError(

SymfonyCustom/Sniffs/Classes/PropertyDeclarationSniff.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ class PropertyDeclarationSniff implements Sniff
1717
*/
1818
public function register()
1919
{
20-
return array(
20+
return [
2121
T_CLASS,
22-
);
22+
];
2323
}
2424

2525
/**
@@ -46,11 +46,11 @@ public function process(File $phpcsFile, $stackPtr)
4646
$end
4747
);
4848

49-
$wantedTokens = array(
49+
$wantedTokens = [
5050
T_PUBLIC,
5151
T_PROTECTED,
5252
T_PRIVATE,
53-
);
53+
];
5454

5555
while ($scope) {
5656
$scope = $phpcsFile->findNext(

SymfonyCustom/Sniffs/Commenting/ClassCommentSniff.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,61 +25,61 @@ class ClassCommentSniff extends PEARClassCommentSniff
2525
*
2626
* @var array
2727
*/
28-
protected $tags = array(
29-
'category' => array(
28+
protected $tags = [
29+
'category' => [
3030
'required' => false,
3131
'allow_multiple' => false,
3232
'order_text' => 'precedes @package',
33-
),
34-
'package' => array(
33+
],
34+
'package' => [
3535
'required' => false,
3636
'allow_multiple' => false,
3737
'order_text' => 'follows @category',
38-
),
39-
'subpackage' => array(
38+
],
39+
'subpackage' => [
4040
'required' => false,
4141
'allow_multiple' => false,
4242
'order_text' => 'follows @package',
43-
),
44-
'author' => array(
43+
],
44+
'author' => [
4545
'required' => false,
4646
'allow_multiple' => true,
4747
'order_text' => 'follows @subpackage (if used) or @package',
48-
),
49-
'copyright' => array(
48+
],
49+
'copyright' => [
5050
'required' => false,
5151
'allow_multiple' => true,
5252
'order_text' => 'follows @author',
53-
),
54-
'license' => array(
53+
],
54+
'license' => [
5555
'required' => false,
5656
'allow_multiple' => false,
5757
'order_text' => 'follows @copyright (if used) or @author',
58-
),
59-
'version' => array(
58+
],
59+
'version' => [
6060
'required' => false,
6161
'allow_multiple' => false,
6262
'order_text' => 'follows @license',
63-
),
64-
'link' => array(
63+
],
64+
'link' => [
6565
'required' => false,
6666
'allow_multiple' => true,
6767
'order_text' => 'follows @version',
68-
),
69-
'see' => array(
68+
],
69+
'see' => [
7070
'required' => false,
7171
'allow_multiple' => true,
7272
'order_text' => 'follows @link',
73-
),
74-
'since' => array(
73+
],
74+
'since' => [
7575
'required' => false,
7676
'allow_multiple' => false,
7777
'order_text' => 'follows @see (if used) or @link',
78-
),
79-
'deprecated' => array(
78+
],
79+
'deprecated' => [
8080
'required' => false,
8181
'allow_multiple' => false,
8282
'order_text' => 'follows @since (if used) or @see (if used) or @link',
83-
),
84-
);
83+
],
84+
];
8585
}

SymfonyCustom/Sniffs/Commenting/DocCommentForbiddenTagsSniff.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ class DocCommentForbiddenTagsSniff implements Sniff
1515
*
1616
* @var array
1717
*/
18-
public $tags = array(
18+
public $tags = [
1919
'@package',
2020
'@subpackage',
21-
);
21+
];
2222

2323
/**
2424
* A list of tokenizers this sniff supports.
@@ -27,9 +27,9 @@ class DocCommentForbiddenTagsSniff implements Sniff
2727
*/
2828
public function register()
2929
{
30-
return array(
30+
return [
3131
T_DOC_COMMENT_TAG
32-
);
32+
];
3333
}
3434

3535
/**
@@ -53,7 +53,7 @@ public function process(File $phpcsFile, $stackPtr)
5353
'The %s annotation is forbidden to use',
5454
$stackPtr,
5555
'',
56-
array($tokens[$stackPtr]['content'])
56+
[$tokens[$stackPtr]['content']]
5757
);
5858
}
5959
}

SymfonyCustom/Sniffs/Commenting/DocCommentGroupSameTypeSniff.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class DocCommentGroupSameTypeSniff implements Sniff
1515
*
1616
* @var array
1717
*/
18-
public $tags = array(
18+
public $tags = [
1919
'@api',
2020
'@author',
2121
'@category',
@@ -46,7 +46,7 @@ class DocCommentGroupSameTypeSniff implements Sniff
4646
'@uses',
4747
'@var',
4848
'@version',
49-
);
49+
];
5050

5151
/**
5252
* A list of tokenizers this sniff supports.
@@ -55,9 +55,9 @@ class DocCommentGroupSameTypeSniff implements Sniff
5555
*/
5656
public function register()
5757
{
58-
return array(
58+
return [
5959
T_DOC_COMMENT_OPEN_TAG
60-
);
60+
];
6161
}
6262

6363
/**
@@ -148,7 +148,7 @@ public function process(File $phpcsFile, $stackPtr)
148148

149149
if ($previousLine === $commentTagLine - 1) {
150150
$firstOnLine = $phpcsFile->findFirstOnLine(
151-
array(),
151+
[],
152152
$commentTag,
153153
true
154154
);

SymfonyCustom/Sniffs/Commenting/FunctionCommentSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function process(File $phpcsFile, $stackPtr)
9999
if (count($realParams) > 0) {
100100
foreach ($realParams as $neededParam) {
101101
$error = 'Doc comment for parameter "%s" missing';
102-
$data = array($neededParam['name']);
102+
$data = [$neededParam['name']];
103103
$phpcsFile->addError($error, $stackPtr, 'MissingParamTag', $data);
104104
}
105105
}
@@ -198,7 +198,7 @@ protected function processWhitespace(
198198
$rule = 'SpacingBeforeFunction';
199199
}
200200

201-
$data = array($found);
201+
$data = [$found];
202202
$fix = $phpcsFile->addFixableError($error, $commentStart, $rule, $data);
203203

204204
if (true === $fix) {

0 commit comments

Comments
 (0)