Skip to content

Commit 4337ddf

Browse files
committed
fix(DocCommentAlignment): Allow @see references to be indented under @param docs (#3073750)
1 parent 284b518 commit 4337ddf

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

coder_sniffer/Drupal/Sniffs/Commenting/DocCommentAlignmentSniff.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,10 @@ public function process(File $phpcsFile, $stackPtr)
137137
}
138138
} else if ($tokens[($i + 2)]['code'] === T_DOC_COMMENT_TAG
139139
&& $tokens[($i + 1)]['content'] !== ' '
140-
// Special @code/@endcode tags can have more than 1 space.
140+
// Special @code/@endcode/@see tags can have more than 1 space.
141141
&& $tokens[($i + 2)]['content'] !== '@code'
142142
&& $tokens[($i + 2)]['content'] !== '@endcode'
143+
&& $tokens[($i + 2)]['content'] !== '@see'
143144
) {
144145
$error = 'Expected 1 space after asterisk; %s found';
145146
$data = [strlen($tokens[($i + 1)]['content'])];

coder_sniffer/Drupal/Sniffs/Commenting/DocCommentSniff.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ public function process(File $phpcsFile, $stackPtr)
378378
$ignoreTags = [
379379
'@code',
380380
'@endcode',
381+
'@see',
381382
];
382383
foreach ($tokens[$commentStart]['comment_tags'] as $pos => $tag) {
383384
if ($pos > 0) {

coder_sniffer/Drupal/Test/Commenting/DocCommentAlignmentUnitTest.inc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,14 @@ class Test {
1616
var $varStyle;
1717

1818
}
19+
20+
/**
21+
* Short description.
22+
*
23+
* @param string $a
24+
* The following reference is allowed to be indented.
25+
* @see my_function()
26+
*/
27+
function test31($a) {
28+
29+
}

coder_sniffer/Drupal/Test/Commenting/DocCommentAlignmentUnitTest.inc.fixed

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,14 @@ class Test {
1616
public $varStyle;
1717

1818
}
19+
20+
/**
21+
* Short description.
22+
*
23+
* @param string $a
24+
* The following reference is allowed to be indented.
25+
* @see my_function()
26+
*/
27+
function test31($a) {
28+
29+
}

0 commit comments

Comments
 (0)