Skip to content
This repository was archived by the owner on Nov 5, 2022. It is now read-only.

Commit 0aba7a0

Browse files
committed
style: coding style
As ./vendor/squizlabs/php_codesniffer/phpcs.xml.dist
1 parent b53a333 commit 0aba7a0

23 files changed

+463
-464
lines changed

CodeIgniter4/Sniffs/Arrays/ArrayDeclarationSniff.php

Lines changed: 94 additions & 95 deletions
Large diffs are not rendered by default.

CodeIgniter4/Sniffs/Commenting/ClassCommentSniff.php

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -30,52 +30,52 @@ class ClassCommentSniff extends FileCommentSniff
3030
*
3131
* @var array
3232
*/
33-
protected $tags = array(
34-
'@package' => array(
35-
'required' => true,
36-
'allow_multiple' => false,
37-
),
38-
'@subpackage' => array(
39-
'required' => false,
40-
'allow_multiple' => false,
41-
),
42-
'@category' => array(
43-
'required' => false,
44-
'allow_multiple' => false,
45-
),
46-
'@author' => array(
47-
'required' => false,
48-
'allow_multiple' => true,
49-
),
50-
'@copyright' => array(
51-
'required' => false,
52-
'allow_multiple' => true,
53-
),
54-
'@license' => array(
55-
'required' => false,
56-
'allow_multiple' => false,
57-
),
58-
'@link' => array(
59-
'required' => false,
60-
'allow_multiple' => true,
61-
),
62-
'@since' => array(
63-
'required' => false,
64-
'allow_multiple' => false,
65-
),
66-
'@version' => array(
67-
'required' => false,
68-
'allow_multiple' => false,
69-
),
70-
'@see' => array(
71-
'required' => false,
72-
'allow_multiple' => true,
73-
),
74-
'@deprecated' => array(
75-
'required' => false,
76-
'allow_multiple' => false,
77-
),
78-
);
33+
protected $tags = [
34+
'@package' => [
35+
'required' => true,
36+
'allow_multiple' => false,
37+
],
38+
'@subpackage' => [
39+
'required' => false,
40+
'allow_multiple' => false,
41+
],
42+
'@category' => [
43+
'required' => false,
44+
'allow_multiple' => false,
45+
],
46+
'@author' => [
47+
'required' => false,
48+
'allow_multiple' => true,
49+
],
50+
'@copyright' => [
51+
'required' => false,
52+
'allow_multiple' => true,
53+
],
54+
'@license' => [
55+
'required' => false,
56+
'allow_multiple' => false,
57+
],
58+
'@link' => [
59+
'required' => false,
60+
'allow_multiple' => true,
61+
],
62+
'@since' => [
63+
'required' => false,
64+
'allow_multiple' => false,
65+
],
66+
'@version' => [
67+
'required' => false,
68+
'allow_multiple' => false,
69+
],
70+
'@see' => [
71+
'required' => false,
72+
'allow_multiple' => true,
73+
],
74+
'@deprecated' => [
75+
'required' => false,
76+
'allow_multiple' => false,
77+
],
78+
];
7979

8080

8181
/**
@@ -85,10 +85,10 @@ class ClassCommentSniff extends FileCommentSniff
8585
*/
8686
public function register()
8787
{
88-
return array(
89-
T_CLASS,
90-
T_INTERFACE,
91-
);
88+
return [
89+
T_CLASS,
90+
T_INTERFACE,
91+
];
9292

9393
}//end register()
9494

@@ -108,7 +108,7 @@ public function process(File $phpcsFile, $stackPtr)
108108

109109
$tokens = $phpcsFile->getTokens();
110110
$type = strtolower($tokens[$stackPtr]['content']);
111-
$errorData = array($type);
111+
$errorData = [$type];
112112

113113
$find = Tokens::$methodPrefixes;
114114
$find[] = T_WHITESPACE;

CodeIgniter4/Sniffs/Commenting/FileCommentSniff.php

Lines changed: 77 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)