11
11
* @package StellarWP\Sniffs\Whitespace
12
12
*/
13
13
final class DocCommentSpacingSniff implements Sniff {
14
+ /**
15
+ * Register the sniff.
16
+ *
17
+ * @return array<string>
18
+ */
14
19
public function register () {
15
20
return [ T_DOC_COMMENT_TAG ];
16
21
}
17
22
23
+ /**
24
+ * Process the doc comment.
25
+ *
26
+ * @param File $phpcsFile The file being scanned.
27
+ * @param int $stackPtr The position of the current token in the stack.
28
+ */
18
29
public function process ( File $ phpcsFile , $ stackPtr ) {
19
30
$ tokens = $ phpcsFile ->getTokens ();
20
31
$ full_tag = $ tokens [ $ stackPtr ]['content ' ];
@@ -52,6 +63,14 @@ public function process( File $phpcsFile, $stackPtr ) {
52
63
}
53
64
}
54
65
66
+ /**
67
+ * Fix the spacing issue in the doc comment.
68
+ *
69
+ * @param File $phpcsFile The file being scanned.
70
+ * @param int $stackPtr The position of the current token in the stack.
71
+ * @param string $tag The tag name.
72
+ * @param string $version The version number.
73
+ */
55
74
private function fixSpacing ( File $ phpcsFile , $ stackPtr , $ tag , $ version ) {
56
75
$ correctedComment = sprintf ( '%s %s ' , $ tag , $ version );
57
76
@@ -60,6 +79,12 @@ private function fixSpacing( File $phpcsFile, $stackPtr, $tag, $version ) {
60
79
$ phpcsFile ->fixer ->endChangeset ();
61
80
}
62
81
82
+ /**
83
+ * Fix the multiple space trails in the doc comment.
84
+ *
85
+ * @param File $phpcsFile The file being scanned.
86
+ * @param int $stackPtr The position of the current token in the stack.
87
+ */
63
88
private function fixMultipleSpaces ( File $ phpcsFile , $ stackPtr ) {
64
89
$ phpcsFile ->fixer ->beginChangeset ();
65
90
$ phpcsFile ->fixer ->replaceToken ( $ stackPtr , " " );
0 commit comments