Skip to content

Commit 74cd7bc

Browse files
author
Vincent Langlet
committed
🐛 Fix FunctionComment fixer
1 parent 6bf6047 commit 74cd7bc

File tree

4 files changed

+126
-2
lines changed

4 files changed

+126
-2
lines changed

Symfony3Custom/Sniffs/Commenting/FunctionCommentSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,11 @@ protected function processWhitespace(
140140
if ($fix === true) {
141141
if ($found > 1) {
142142
$phpcsFile->fixer->beginChangeset();
143+
143144
for ($i = ($before + 1); $i < ($commentStart - 1); $i++) {
144145
$phpcsFile->fixer->replaceToken($i, '');
145146
}
146147

147-
$phpcsFile->fixer->replaceToken($i, $phpcsFile->eolChar);
148148
$phpcsFile->fixer->endChangeset();
149149
} else {
150150
// Try and maintain indentation.

Symfony3Custom/Tests/Commenting/FunctionCommentUnitTest.inc

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,25 @@ function functionTest1($test)
77
{
88
return 42;
99
}
10+
/**
11+
* @return int
12+
*/
13+
function functionTest2($test)
14+
{
15+
return 42;
16+
}
1017

1118
/**
1219
* @param string $test Test Argument
1320
*
1421
* @return int
1522
*/
16-
function functionTest2($test)
23+
function functionTest3($test)
1724
{
1825
return 42;
1926
}
2027

28+
2129
/**
2230
* @param array $tab Test Argument
2331
*/
@@ -27,3 +35,40 @@ function functionTestWithCallBack($tab)
2735
return $t[0];
2836
}, $tab);
2937
}
38+
39+
class classToTestIndentation
40+
{
41+
/**
42+
* @param string $test Test Argument
43+
*/
44+
function functionTest1($test)
45+
{
46+
return 42;
47+
}
48+
/**
49+
* @return int
50+
*/
51+
function functionTest2($test)
52+
{
53+
return 42;
54+
}
55+
56+
57+
/**
58+
* @param array $tab Test Argument
59+
*/
60+
function functionTestWithCallBack($tab)
61+
{
62+
$thing = array_map(function ($t) {
63+
return $t[0];
64+
}, $tab);
65+
}
66+
}
67+
68+
/**
69+
* #{@inheritdoc}
70+
*/
71+
function functionTestInherit($test)
72+
{
73+
return 42;
74+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
3+
/**
4+
* @param string $test Test Argument
5+
*/
6+
function functionTest1($test)
7+
{
8+
return 42;
9+
}
10+
11+
/**
12+
* @return int
13+
*/
14+
function functionTest2($test)
15+
{
16+
return 42;
17+
}
18+
19+
/**
20+
* @param string $test Test Argument
21+
*
22+
* @return int
23+
*/
24+
function functionTest3($test)
25+
{
26+
return 42;
27+
}
28+
29+
/**
30+
* @param array $tab Test Argument
31+
*/
32+
function functionTestWithCallBack($tab)
33+
{
34+
$thing = array_map(function ($t) {
35+
return $t[0];
36+
}, $tab);
37+
}
38+
39+
class classToTestIndentation
40+
{
41+
/**
42+
* @param string $test Test Argument
43+
*/
44+
function functionTest1($test)
45+
{
46+
return 42;
47+
}
48+
49+
/**
50+
* @return int
51+
*/
52+
function functionTest2($test)
53+
{
54+
return 42;
55+
}
56+
57+
/**
58+
* @param array $tab Test Argument
59+
*/
60+
function functionTestWithCallBack($tab)
61+
{
62+
$thing = array_map(function ($t) {
63+
return $t[0];
64+
}, $tab);
65+
}
66+
}
67+
68+
/**
69+
* #{@inheritdoc}
70+
*/
71+
function functionTestInherit($test)
72+
{
73+
return 42;
74+
}

Symfony3Custom/Tests/Commenting/FunctionCommentUnitTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ public function getErrorList()
2121
{
2222
return array(
2323
5 => 1,
24+
10 => 2,
25+
29 => 1,
26+
43 => 1,
27+
48 => 2,
28+
57 => 1,
2429
);
2530
}
2631

0 commit comments

Comments
 (0)