Skip to content

Commit ebdbd15

Browse files
author
Vincent Langlet
committed
💄 Respect linter rules
1 parent 4f7f059 commit ebdbd15

12 files changed

+159
-157
lines changed

Symfony3Custom/Sniffs/Arrays/ArrayDeclarationSniff.php

Lines changed: 91 additions & 89 deletions
Large diffs are not rendered by default.

Symfony3Custom/Sniffs/Classes/PropertyDeclarationSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
6363
$end
6464
);
6565

66-
if ($scope && $tokens[$scope + 2]['code'] === T_VARIABLE) {
66+
if ($scope && T_VARIABLE === $tokens[$scope + 2]['code']) {
6767
$phpcsFile->addError(
6868
'Declare class properties before methods',
6969
$scope,

Symfony3Custom/Sniffs/Commenting/DocCommentGroupSameTypeSniff.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
8787
$previousLine = max($previousStringLine, $previousTagLine);
8888

8989
$currentIsCustom = !in_array($currentType, $this->tags);
90-
$previousIsCustom = ($previousType !== '')
90+
$previousIsCustom = ('' !== $previousType)
9191
&& !in_array($previousType, $this->tags);
9292

9393
if (($previousType === $currentType)
@@ -110,7 +110,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
110110
);
111111
}
112112

113-
if ($fix === true) {
113+
if (true === $fix) {
114114
$phpcsFile->fixer->beginChangeset();
115115
$this->removeLines(
116116
$phpcsFile,
@@ -130,7 +130,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
130130
'DifferentType'
131131
);
132132

133-
if ($fix === true) {
133+
if (true === $fix) {
134134
$phpcsFile->fixer->beginChangeset();
135135

136136
if ($previousLine === $commentTagLine - 1) {

Symfony3Custom/Sniffs/Commenting/FunctionCommentSniff.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,24 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
3333
$find[] = T_WHITESPACE;
3434

3535
$commentEnd = $phpcsFile->findPrevious($find, ($stackPtr - 1), null, true);
36-
if ($tokens[$commentEnd]['code'] === T_COMMENT) {
36+
if (T_COMMENT === $tokens[$commentEnd]['code']) {
3737
// Inline comments might just be closing comments for
3838
// control structures or functions instead of function comments
3939
// using the wrong comment type. If there is other code on the line,
4040
// assume they relate to that code.
4141
$prev = $phpcsFile->findPrevious($find, ($commentEnd - 1), null, true);
42-
if ($prev !== false && $tokens[$prev]['line'] === $tokens[$commentEnd]['line']) {
42+
if (false !== $prev && $tokens[$prev]['line'] === $tokens[$commentEnd]['line']) {
4343
$commentEnd = $prev;
4444
}
4545
}
4646

4747
$name = $phpcsFile->getDeclarationName($stackPtr);
4848
$commentRequired = strpos($name, 'test') !== 0
49-
&& $name !== 'setUp'
50-
&& $name !== 'tearDown';
49+
&& 'setUp' !== $name
50+
&& 'tearDown' !== $name;
5151

52-
if ($tokens[$commentEnd]['code'] !== T_DOC_COMMENT_CLOSE_TAG
53-
&& $tokens[$commentEnd]['code'] !== T_COMMENT
52+
if (T_DOC_COMMENT_CLOSE_TAG !== $tokens[$commentEnd]['code']
53+
&& T_COMMENT !== $tokens[$commentEnd]['code']
5454
) {
5555
$hasComment = false;
5656
$phpcsFile->recordMetric($stackPtr, 'Function has doc comment', 'no');
@@ -68,7 +68,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
6868
}
6969

7070
if ($hasComment) {
71-
if ($tokens[$commentEnd]['code'] === T_COMMENT) {
71+
if (T_COMMENT === $tokens[$commentEnd]['code']) {
7272
$phpcsFile->addError(
7373
'You must use "/**" style comments for a function comment',
7474
$stackPtr,
@@ -78,17 +78,17 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
7878
return;
7979
}
8080

81-
if ($tokens[$commentEnd]['line'] !== ($tokens[$stackPtr]['line'] - 1)) {
81+
if (($tokens[$stackPtr]['line'] - 1) !== $tokens[$commentEnd]['line']) {
8282
$error = 'There must be no blank lines after the function comment';
8383
$phpcsFile->addError($error, $commentEnd, 'SpacingAfter');
8484
}
8585

8686
$commentStart = $tokens[$commentEnd]['comment_opener'];
8787
foreach ($tokens[$commentStart]['comment_tags'] as $tag) {
88-
if ($tokens[$tag]['content'] === '@see') {
88+
if ('@see' === $tokens[$tag]['content']) {
8989
// Make sure the tag isn't empty.
9090
$string = $phpcsFile->findNext(T_DOC_COMMENT_STRING, $tag, $commentEnd);
91-
if ($string === false || $tokens[$string]['line'] !== $tokens[$tag]['line']) {
91+
if (false === $string || $tokens[$string]['line'] !== $tokens[$tag]['line']) {
9292
$error = 'Content missing for @see tag in function comment';
9393
$phpcsFile->addError($error, $tag, 'EmptySees');
9494
}
@@ -101,7 +101,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
101101
$stackPtr
102102
);
103103

104-
if ($methodPrefixes !== false) {
104+
if (false !== $methodPrefixes) {
105105
$commentStart = $methodPrefixes;
106106
} else {
107107
// No comment and no method prefix
@@ -165,14 +165,14 @@ protected function processReturn(
165165

166166
for ($i = $start; $i < $tokens[$stackPtr]['scope_closer']; ++$i) {
167167
// Skip closures
168-
if ($tokens[$i]['code'] === T_CLOSURE) {
168+
if (T_CLOSURE === $tokens[$i]['code']) {
169169
$i = $tokens[$i]['scope_closer'];
170170
continue;
171171
}
172172

173173
// Found a return not in a closure statement
174174
// Run the check on the first which is not only 'return;'
175-
if ($tokens[$i]['code'] === T_RETURN
175+
if (T_RETURN === $tokens[$i]['code']
176176
&& $this->isMatchingReturn($tokens, $i)
177177
) {
178178
if ($hasRealComment) {
@@ -208,7 +208,7 @@ protected function processWhitespace(
208208
$found = $startLine - $prevLine - 1;
209209

210210
// Skip for class opening
211-
if ($found < 1 && !($found === 0 && $tokens[$before]['type'] === 'T_OPEN_CURLY_BRACKET')) {
211+
if ($found < 1 && !(0 === $found && 'T_OPEN_CURLY_BRACKET' === $tokens[$before]['type'])) {
212212
if ($found < 0) {
213213
$found = 0;
214214
}
@@ -224,7 +224,7 @@ protected function processWhitespace(
224224
$data = array($found);
225225
$fix = $phpcsFile->addFixableError($error, $commentStart, $rule, $data);
226226

227-
if ($fix === true) {
227+
if (true === $fix) {
228228
if ($found > 1) {
229229
$phpcsFile->fixer->beginChangeset();
230230

@@ -235,7 +235,7 @@ protected function processWhitespace(
235235
$phpcsFile->fixer->endChangeset();
236236
} else {
237237
// Try and maintain indentation.
238-
if ($tokens[($commentStart - 1)]['code'] === T_WHITESPACE) {
238+
if (T_WHITESPACE === $tokens[($commentStart - 1)]['code']) {
239239
$phpcsFile->fixer->addNewlineBefore($commentStart - 1);
240240
} else {
241241
$phpcsFile->fixer->addNewlineBefore($commentStart);
@@ -301,8 +301,8 @@ protected function isMatchingReturn($tokens, $returnPos)
301301
{
302302
do {
303303
$returnPos++;
304-
} while ($tokens[$returnPos]['code'] === T_WHITESPACE);
304+
} while (T_WHITESPACE === $tokens[$returnPos]['code']);
305305

306-
return $tokens[$returnPos]['code'] !== T_SEMICOLON;
306+
return T_SEMICOLON !== $tokens[$returnPos]['code'];
307307
}
308308
}

Symfony3Custom/Sniffs/Commenting/VariableCommentSniff.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ public function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
3131
);
3232

3333
$commentEnd = $phpcsFile->findPrevious($ignore, ($stackPtr - 1), null, true);
34-
if ($commentEnd === false
35-
|| ($tokens[$commentEnd]['code'] !== T_DOC_COMMENT_CLOSE_TAG
36-
&& $tokens[$commentEnd]['code'] !== T_COMMENT)
34+
if (false === $commentEnd
35+
|| (T_DOC_COMMENT_CLOSE_TAG !== $tokens[$commentEnd]['code']
36+
&& T_COMMENT !== $tokens[$commentEnd]['code'])
3737
) {
3838
$phpcsFile->addError('Missing member variable doc comment', $stackPtr, 'Missing');
3939

4040
return;
4141
}
4242

43-
if ($tokens[$commentEnd]['code'] === T_COMMENT) {
43+
if (T_COMMENT === $tokens[$commentEnd]['code']) {
4444
$phpcsFile->addError(
4545
'You must use "/**" style comments for a member variable comment',
4646
$stackPtr,
@@ -54,40 +54,40 @@ public function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
5454

5555
$foundVar = null;
5656
foreach ($tokens[$commentStart]['comment_tags'] as $tag) {
57-
if ($tokens[$tag]['content'] === '@var') {
58-
if ($foundVar !== null) {
57+
if ('@var' === $tokens[$tag]['content']) {
58+
if (null !== $foundVar) {
5959
$error = 'Only one @var tag is allowed in a member variable comment';
6060
$phpcsFile->addError($error, $tag, 'DuplicateVar');
6161
} else {
6262
$foundVar = $tag;
6363
}
64-
} elseif ($tokens[$tag]['content'] === '@see') {
64+
} elseif ('@see' === $tokens[$tag]['content']) {
6565
// Make sure the tag isn't empty.
6666
$string = $phpcsFile->findNext(T_DOC_COMMENT_STRING, $tag, $commentEnd);
67-
if ($string === false || $tokens[$string]['line'] !== $tokens[$tag]['line']) {
67+
if (false === $string || $tokens[$string]['line'] !== $tokens[$tag]['line']) {
6868
$error = 'Content missing for @see tag in member variable comment';
6969
$phpcsFile->addError($error, $tag, 'EmptySees');
7070
}
7171
}
7272
}
7373

7474
// The @var tag is the only one we require.
75-
if ($foundVar === null) {
75+
if (null === $foundVar) {
7676
$error = 'Missing @var tag in member variable comment';
7777
$phpcsFile->addError($error, $commentEnd, 'MissingVar');
7878

7979
return;
8080
}
8181

8282
$firstTag = $tokens[$commentStart]['comment_tags'][0];
83-
if ($foundVar !== null && $tokens[$firstTag]['content'] !== '@var') {
83+
if (null !== $foundVar && '@var' !== $tokens[$firstTag]['content']) {
8484
$error = 'The @var tag must be the first tag in a member variable comment';
8585
$phpcsFile->addError($error, $foundVar, 'VarOrder');
8686
}
8787

8888
// Make sure the tag isn't empty and has the correct padding.
8989
$string = $phpcsFile->findNext(T_DOC_COMMENT_STRING, $foundVar, $commentEnd);
90-
if ($string === false || $tokens[$string]['line'] !== $tokens[$foundVar]['line']) {
90+
if (false === $string || $tokens[$string]['line'] !== $tokens[$foundVar]['line']) {
9191
$error = 'Content missing for @var tag in member variable comment';
9292
$phpcsFile->addError($error, $foundVar, 'EmptyVar');
9393

@@ -114,7 +114,7 @@ protected function processWhitespace(
114114
$found = $startLine - $prevLine - 1;
115115

116116
// Skip for class opening
117-
if ($found < 1 && !($found === 0 && $tokens[$before]['type'] === 'T_OPEN_CURLY_BRACKET')) {
117+
if ($found < 1 && !(0 === $found && 'T_OPEN_CURLY_BRACKET' === $tokens[$before]['type'])) {
118118
if ($found < 0) {
119119
$found = 0;
120120
}
@@ -125,7 +125,7 @@ protected function processWhitespace(
125125
$data = array($found);
126126
$fix = $phpcsFile->addFixableError($error, $commentStart, $rule, $data);
127127

128-
if ($fix === true) {
128+
if (true === $fix) {
129129
if ($found > 1) {
130130
$phpcsFile->fixer->beginChangeset();
131131

@@ -136,7 +136,7 @@ protected function processWhitespace(
136136
$phpcsFile->fixer->endChangeset();
137137
} else {
138138
// Try and maintain indentation.
139-
if ($tokens[($commentStart - 1)]['code'] === T_WHITESPACE) {
139+
if (T_WHITESPACE === $tokens[($commentStart - 1)]['code']) {
140140
$phpcsFile->fixer->addNewlineBefore($commentStart - 1);
141141
} else {
142142
$phpcsFile->fixer->addNewlineBefore($commentStart);

Symfony3Custom/Sniffs/Formatting/BlankLineBeforeReturnSniff.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,19 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
4545

4646
while ($current >= 0 && $tokens[$current]['line'] >= $previousLine) {
4747
if ($tokens[$current]['line'] == $previousLine
48-
&& $tokens[$current]['type'] !== 'T_WHITESPACE'
49-
&& $tokens[$current]['type'] !== 'T_COMMENT'
50-
&& $tokens[$current]['type'] !== 'T_DOC_COMMENT_CLOSE_TAG'
51-
&& $tokens[$current]['type'] !== 'T_DOC_COMMENT_WHITESPACE'
48+
&& 'T_WHITESPACE' !== $tokens[$current]['type']
49+
&& 'T_COMMENT' !== $tokens[$current]['type']
50+
&& 'T_DOC_COMMENT_CLOSE_TAG' !== $tokens[$current]['type']
51+
&& 'T_DOC_COMMENT_WHITESPACE' !== $tokens[$current]['type']
5252
) {
5353
$prevLineTokens[] = $tokens[$current]['type'];
5454
}
5555
$current--;
5656
}
5757

5858
if (isset($prevLineTokens[0])
59-
&& ($prevLineTokens[0] === 'T_OPEN_CURLY_BRACKET'
60-
|| $prevLineTokens[0] === 'T_COLON')
59+
&& ('T_OPEN_CURLY_BRACKET' === $prevLineTokens[0]
60+
|| 'T_COLON' === $prevLineTokens[0])
6161
) {
6262
return;
6363
} elseif (count($prevLineTokens) > 0) {
@@ -67,10 +67,10 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
6767
'MissedBlankLineBeforeRetrun'
6868
);
6969

70-
if ($fix === true) {
70+
if (true === $fix) {
7171
$phpcsFile->fixer->beginChangeset();
7272
$i = 1;
73-
while ($tokens[$stackPtr - $i]['type'] == 'T_WHITESPACE') {
73+
while ('T_WHITESPACE' == $tokens[$stackPtr - $i]['type']) {
7474
$i++;
7575
}
7676
$phpcsFile->fixer->addNewLine($stackPtr - $i);

Symfony3Custom/Sniffs/Objects/ObjectInstantiationSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
5555
if ($tokens[$object]['line'] === $line
5656
&& !in_array($tokens[$object + 1]['code'], $allowed)
5757
) {
58-
if ($tokens[$object + 1]['code'] !== T_OPEN_PARENTHESIS) {
58+
if (T_OPEN_PARENTHESIS !== $tokens[$object + 1]['code']) {
5959
$phpcsFile->addError(
6060
'Use parentheses when instantiating classes',
6161
$stackPtr,

Symfony3Custom/Sniffs/Scope/MethodScopeSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ protected function processTokenWithinScope(
3636
$tokens = $phpcsFile->getTokens();
3737

3838
$methodName = $phpcsFile->getDeclarationName($stackPtr);
39-
if ($methodName === null) {
39+
if (null === $methodName) {
4040
// Ignore closures.
4141
return;
4242
}
@@ -46,7 +46,7 @@ protected function processTokenWithinScope(
4646
$stackPtr
4747
);
4848

49-
if (($modifier === false)
49+
if ((false === $modifier)
5050
|| ($tokens[$modifier]['line'] !== $tokens[$stackPtr]['line'])
5151
) {
5252
$error = 'No scope modifier specified for function "%s"';

Symfony3Custom/Sniffs/WhiteSpace/CloseBracketSpacingSniff.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
4343
$tokens = $phpcsFile->getTokens();
4444

4545
// Ignore curly brackets in javascript files.
46-
if ($tokens[$stackPtr]['code'] === T_CLOSE_CURLY_BRACKET
47-
&& $phpcsFile->tokenizerType === 'JS'
46+
if (T_CLOSE_CURLY_BRACKET === $tokens[$stackPtr]['code']
47+
&& 'JS' === $phpcsFile->tokenizerType
4848
) {
4949
return;
5050
}
5151

5252
if (isset($tokens[($stackPtr - 1)]) === true
53-
&& $tokens[($stackPtr - 1)]['code'] === T_WHITESPACE
53+
&& T_WHITESPACE === $tokens[($stackPtr - 1)]['code']
5454
) {
5555
$before = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true);
56-
if ($before !== false
56+
if (false !== $before
5757
&& $tokens[$stackPtr]['line'] === $tokens[$before]['line']
5858
) {
5959
$error = 'There should be no space before a closing "%s"';
@@ -64,7 +64,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
6464
array($tokens[$stackPtr]['content'])
6565
);
6666

67-
if ($fix === true) {
67+
if (true === $fix) {
6868
$phpcsFile->fixer->replaceToken($stackPtr - 1, '');
6969
}
7070
}

Symfony3Custom/Sniffs/WhiteSpace/EmptyLinesSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
4747
$error = 'More than 1 empty lines are not allowed';
4848
$fix = $phpcsFile->addFixableError($error, $stackPtr + 2, 'EmptyLines');
4949

50-
if ($fix === true) {
50+
if (true === $fix) {
5151
$phpcsFile->fixer->replaceToken($stackPtr + 2, '');
5252
}
5353
}

0 commit comments

Comments
 (0)