Skip to content

Commit 8c43f5e

Browse files
Merge pull request #15 from VincentLanglet/staging
Staging
2 parents 5bb89ce + e6d7ded commit 8c43f5e

24 files changed

+162
-167
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Symfony3 Custom PHP CodeSniffer Coding Standard
22

3+
[![CircleCI](https://circleci.com/gh/VincentLanglet/Symfony3-custom-coding-standard.svg?style=svg&circle-token=04bcfbcceb34f9644561c0a9ef27e935ff467705)](https://circleci.com/gh/VincentLanglet/Symfony3-custom-coding-standard)
4+
35
Documentation
46
-------------
57
* [Coding Standard](docs/standards.md)

Symfony3Custom/Sniffs/Arrays/ArrayDeclarationSniff.php

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,8 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
118118
} else {
119119
$this->processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $arrayEnd);
120120
}
121-
122121
}
123122

124-
125123
/**
126124
* Processes a single-line array definition.
127125
*
@@ -183,9 +181,9 @@ public function processSingleLineArray(PHP_CodeSniffer_File $phpcsFile, $stackPt
183181
$content = $tokens[($nextArrow - 2)]['content'];
184182
$error = 'Expected 1 space between "%s" and double arrow; %s found';
185183
$data = array(
186-
$content,
187-
$spaceLength,
188-
);
184+
$content,
185+
$spaceLength,
186+
);
189187

190188
$fix = $phpcsFile->addFixableError($error, $nextArrow, 'SpaceBeforeDoubleArrow', $data);
191189
if ($fix === true) {
@@ -208,9 +206,9 @@ public function processSingleLineArray(PHP_CodeSniffer_File $phpcsFile, $stackPt
208206
$content = $tokens[($nextArrow + 2)]['content'];
209207
$error = 'Expected 1 space between double arrow and "%s"; %s found';
210208
$data = array(
211-
$content,
212-
$spaceLength,
213-
);
209+
$content,
210+
$spaceLength,
211+
);
214212

215213
$fix = $phpcsFile->addFixableError($error, $nextArrow, 'SpaceAfterDoubleArrow', $data);
216214
if ($fix === true) {
@@ -266,7 +264,6 @@ public function processSingleLineArray(PHP_CodeSniffer_File $phpcsFile, $stackPt
266264
}
267265
}
268266

269-
270267
/**
271268
* Processes a multi-line array definition.
272269
*
@@ -417,9 +414,9 @@ public function processMultiLineArray(PHP_CodeSniffer_File $phpcsFile, $stackPtr
417414

418415
$error = 'Expected 0 spaces between "%s" and comma; %s found';
419416
$data = array(
420-
$content,
421-
$spaceLength,
422-
);
417+
$content,
418+
$spaceLength,
419+
);
423420

424421
$fix = $phpcsFile->addFixableError($error, $nextToken, 'SpaceBeforeComma', $data);
425422
if ($fix === true) {
@@ -547,9 +544,9 @@ public function processMultiLineArray(PHP_CodeSniffer_File $phpcsFile, $stackPtr
547544
if ($found !== $expected) {
548545
$error = 'Array value not aligned correctly; expected %s spaces but found %s';
549546
$data = array(
550-
$expected,
551-
$found,
552-
);
547+
$expected,
548+
$found,
549+
);
553550

554551
$fix = $phpcsFile->addFixableError($error, $value['value'], 'ValueNotAligned', $data);
555552
if ($fix === true) {
@@ -646,9 +643,9 @@ public function processMultiLineArray(PHP_CodeSniffer_File $phpcsFile, $stackPtr
646643
$found = ($tokens[$index['index']]['column'] - 1);
647644
$error = 'Array key not aligned correctly; expected %s spaces but found %s';
648645
$data = array(
649-
$expected,
650-
$found,
651-
);
646+
$expected,
647+
$found,
648+
);
652649

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

@@ -665,17 +662,18 @@ public function processMultiLineArray(PHP_CodeSniffer_File $phpcsFile, $stackPtr
665662

666663
if ($tokens[$index['arrow']]['column'] !== $arrowStart) {
667664
$expected = ($arrowStart - (strlen($index['index_content']) + $tokens[$index['index']]['column']));
668-
$found = ($tokens[$index['arrow']]['column'] - (strlen($index['index_content']) + $tokens[$index['index']]['column']));
665+
$found = $tokens[$index['arrow']]['column']
666+
- (strlen($index['index_content']) + $tokens[$index['index']]['column']);
669667

670668
if ($found < 0) {
671669
$found = 'newline';
672670
}
673671

674672
$error = 'Array double arrow not aligned correctly; expected %s space(s) but found %s';
675673
$data = array(
676-
$expected,
677-
$found,
678-
);
674+
$expected,
675+
$found,
676+
);
679677

680678
if ($found !== 'newline' || $this->ignoreNewLine === false) {
681679
$fix = $phpcsFile->addFixableError($error, $index['arrow'], 'DoubleArrowNotAligned', $data);
@@ -702,7 +700,9 @@ public function processMultiLineArray(PHP_CodeSniffer_File $phpcsFile, $stackPtr
702700

703701
if ($tokens[$index['value']]['column'] !== $valueStart) {
704702
$expected = ($valueStart - ($tokens[$index['arrow']]['length'] + $tokens[$index['arrow']]['column']));
705-
$found = ($tokens[$index['value']]['column'] - ($tokens[$index['arrow']]['length'] + $tokens[$index['arrow']]['column']));
703+
$found = $tokens[$index['value']]['column']
704+
- ($tokens[$index['arrow']]['length'] + $tokens[$index['arrow']]['column']);
705+
706706
if ($found < 0) {
707707
$found = 'newline';
708708
}
@@ -799,9 +799,9 @@ public function processMultiLineArray(PHP_CodeSniffer_File $phpcsFile, $stackPtr
799799
$spaceLength = $tokens[($nextComma - 1)]['length'];
800800
$error = 'Expected 0 spaces between "%s" and comma; %s found';
801801
$data = array(
802-
$content,
803-
$spaceLength,
804-
);
802+
$content,
803+
$spaceLength,
804+
);
805805

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

Symfony3Custom/Sniffs/Commenting/ClassCommentSniff.php

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -32,60 +32,60 @@ class Symfony3Custom_Sniffs_Commenting_ClassCommentSniff extends PEAR_Sniffs_Com
3232
* @var array
3333
*/
3434
protected $tags = array(
35-
'category' => array(
36-
'required' => false,
35+
'category' => array(
36+
'required' => false,
3737
'allow_multiple' => false,
38-
'order_text' => 'precedes @package',
38+
'order_text' => 'precedes @package',
3939
),
40-
'package' => array(
41-
'required' => false,
40+
'package' => array(
41+
'required' => false,
4242
'allow_multiple' => false,
43-
'order_text' => 'follows @category',
43+
'order_text' => 'follows @category',
4444
),
4545
'subpackage' => array(
46-
'required' => false,
46+
'required' => false,
4747
'allow_multiple' => false,
48-
'order_text' => 'follows @package',
48+
'order_text' => 'follows @package',
4949
),
50-
'author' => array(
51-
'required' => false,
50+
'author' => array(
51+
'required' => false,
5252
'allow_multiple' => true,
53-
'order_text' => 'follows @subpackage (if used) or @package',
53+
'order_text' => 'follows @subpackage (if used) or @package',
5454
),
55-
'copyright' => array(
56-
'required' => false,
55+
'copyright' => array(
56+
'required' => false,
5757
'allow_multiple' => true,
58-
'order_text' => 'follows @author',
58+
'order_text' => 'follows @author',
5959
),
60-
'license' => array(
61-
'required' => false,
60+
'license' => array(
61+
'required' => false,
6262
'allow_multiple' => false,
63-
'order_text' => 'follows @copyright (if used) or @author',
63+
'order_text' => 'follows @copyright (if used) or @author',
6464
),
65-
'version' => array(
66-
'required' => false,
65+
'version' => array(
66+
'required' => false,
6767
'allow_multiple' => false,
68-
'order_text' => 'follows @license',
68+
'order_text' => 'follows @license',
6969
),
70-
'link' => array(
71-
'required' => false,
70+
'link' => array(
71+
'required' => false,
7272
'allow_multiple' => true,
73-
'order_text' => 'follows @version',
73+
'order_text' => 'follows @version',
7474
),
75-
'see' => array(
76-
'required' => false,
75+
'see' => array(
76+
'required' => false,
7777
'allow_multiple' => true,
78-
'order_text' => 'follows @link',
78+
'order_text' => 'follows @link',
7979
),
80-
'since' => array(
81-
'required' => false,
80+
'since' => array(
81+
'required' => false,
8282
'allow_multiple' => false,
83-
'order_text' => 'follows @see (if used) or @link',
83+
'order_text' => 'follows @see (if used) or @link',
8484
),
8585
'deprecated' => array(
86-
'required' => false,
86+
'required' => false,
8787
'allow_multiple' => false,
88-
'order_text' => 'follows @since (if used) or @see (if used) or @link',
88+
'order_text' => 'follows @since (if used) or @see (if used) or @link',
8989
),
9090
);
9191
}

Symfony3Custom/Sniffs/Commenting/DocCommentGroupSameTypeSniff.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,14 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
8686
$previousTagLine = $tokens[$previousTag]['line'];
8787
$previousLine = max($previousStringLine, $previousTagLine);
8888

89-
$currentIsCustom = ! in_array($currentType, $this->tags);
89+
$currentIsCustom = !in_array($currentType, $this->tags);
9090
$previousIsCustom = ($previousType !== '')
91-
&& ! in_array($previousType, $this->tags);
91+
&& !in_array($previousType, $this->tags);
9292

9393
if (($previousType === $currentType)
9494
|| ($currentIsCustom && $previousIsCustom)
9595
) {
9696
if ($previousLine !== $commentTagLine - 1) {
97-
9897
if ($previousType === $currentType) {
9998
$fix = $phpcsFile->addFixableError(
10099
'Expected no empty lines '

Symfony3Custom/Sniffs/Commenting/FunctionCommentSniff.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ protected function processReturn(
181181
// There is no doc and we need one with @return
182182
$error = 'Missing @return tag in function comment';
183183
$phpcsFile->addError($error, $stackPtr, 'MissingReturn');
184-
185184
}
186185

187186
break;

Symfony3Custom/Sniffs/Commenting/VariableCommentSniff.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ public function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
2222
{
2323
$tokens = $phpcsFile->getTokens();
2424
$ignore = array(
25-
T_PUBLIC,
26-
T_PRIVATE,
27-
T_PROTECTED,
28-
T_VAR,
29-
T_STATIC,
30-
T_WHITESPACE,
31-
);
25+
T_PUBLIC,
26+
T_PRIVATE,
27+
T_PROTECTED,
28+
T_VAR,
29+
T_STATIC,
30+
T_WHITESPACE,
31+
);
3232

3333
$commentEnd = $phpcsFile->findPrevious($ignore, ($stackPtr - 1), null, true);
3434
if ($commentEnd === false

Symfony3Custom/Sniffs/Formatting/BlankLineBeforeReturnSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
7070
if ($fix === true) {
7171
$phpcsFile->fixer->beginChangeset();
7272
$i = 1;
73-
while ($tokens[$stackPtr-$i]['type'] == "T_WHITESPACE") {
73+
while ($tokens[$stackPtr - $i]['type'] == 'T_WHITESPACE') {
7474
$i++;
7575
}
76-
$phpcsFile->fixer->addNewLine($stackPtr-$i);
76+
$phpcsFile->fixer->addNewLine($stackPtr - $i);
7777
$phpcsFile->fixer->endChangeset();
7878
}
7979
}

Symfony3Custom/Sniffs/Functions/ScopeOrderSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
6767
);
6868

6969
if (isset($tokens[$function]['parenthesis_opener'])) {
70-
$scope = $phpcsFile->findPrevious($scopes, $function -1, $stackPtr);
70+
$scope = $phpcsFile->findPrevious($scopes, $function - 1, $stackPtr);
7171
$name = $phpcsFile->findNext(
7272
T_STRING,
7373
$function + 1,

Symfony3Custom/Sniffs/NamingConventions/ValidScalarTypeNameSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ class Symfony3Custom_Sniffs_NamingConventions_ValidScalarTypeNameSniff implement
1212
*/
1313
public $types = array(
1414
'boolean' => 'bool',
15-
'double' => 'float',
15+
'double' => 'float',
1616
'integer' => 'int',
17-
'real' => 'float',
17+
'real' => 'float',
1818
);
1919

2020
/**

Symfony3Custom/Sniffs/WhiteSpace/OpenBracketSpacingSniff.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public function register()
2727
T_OPEN_CURLY_BRACKET,
2828
T_OPEN_PARENTHESIS,
2929
);
30-
3130
}
3231

3332
/**

0 commit comments

Comments
 (0)