Skip to content

Commit dcf33da

Browse files
author
Vincent Langlet
committed
🔧 Avoid duplicate
1 parent 60160dc commit dcf33da

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

Symfony3Custom/Sniffs/Commenting/FunctionCommentSniff.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
5757

5858
if ($commentRequired) {
5959
$phpcsFile->addError('Missing function doc comment', $stackPtr, 'Missing');
60+
6061
return;
6162
} else {
6263
// The comment may not be required, we'll see in next checks
@@ -69,7 +70,11 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
6970
$commentStart = null;
7071
if ($hasComment) {
7172
if ($tokens[$commentEnd]['code'] === T_COMMENT) {
72-
$phpcsFile->addError('You must use "/**" style comments for a function comment', $stackPtr, 'WrongStyle');
73+
$phpcsFile->addError(
74+
'You must use "/**" style comments for a function comment',
75+
$stackPtr,
76+
'WrongStyle'
77+
);
7378

7479
return;
7580
}
@@ -192,7 +197,7 @@ protected function processWhitespace(
192197
$found = $startLine - $prevLine - 1;
193198

194199
// Skip for class opening
195-
if ($found !== 1 && !($found === 0 && $tokens[$before]['type'] === 'T_OPEN_CURLY_BRACKET')) {
200+
if ($found < 1 && !($found === 0 && $tokens[$before]['type'] === 'T_OPEN_CURLY_BRACKET')) {
196201
if ($found < 0) {
197202
$found = 0;
198203
}
@@ -241,8 +246,6 @@ protected function processWhitespace(
241246
*/
242247
protected function isInheritDoc(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
243248
{
244-
$tokens = $phpcsFile->getTokens();
245-
246249
$start = $phpcsFile->findPrevious(T_DOC_COMMENT_OPEN_TAG, $stackPtr - 1);
247250
$end = $phpcsFile->findNext(T_DOC_COMMENT_CLOSE_TAG, $start);
248251

@@ -267,8 +270,6 @@ protected function processParams(
267270
$stackPtr,
268271
$commentStart
269272
) {
270-
$tokens = $phpcsFile->getTokens();
271-
272273
if ($this->isInheritDoc($phpcsFile, $stackPtr)) {
273274
return;
274275
}

Symfony3Custom/Tests/Commenting/FunctionCommentUnitTest.inc.fixed

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ function functionTest3($test)
2626
return 42;
2727
}
2828

29+
2930
/**
3031
* @param array $tab Test Argument
3132
*/
@@ -54,6 +55,7 @@ class classToTestIndentation
5455
return 42;
5556
}
5657

58+
5759
/**
5860
* @param array $tab Test Argument
5961
*/

Symfony3Custom/Tests/Commenting/FunctionCommentUnitTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ public function getErrorList()
2121
return array(
2222
5 => 1,
2323
10 => 2,
24-
29 => 1,
2524
43 => 1,
2625
48 => 2,
27-
57 => 1,
2826
76 => 2,
2927
83 => 1,
3028
93 => 1,

0 commit comments

Comments
 (0)