@@ -20,18 +20,30 @@ public function process(File $phpcsFile, $stackPtr) {
20
20
$ tokens = $ phpcsFile ->getTokens ();
21
21
22
22
$ content = $ tokens [$ stackPtr ]['content ' ];
23
- if (substr_count ($ content , '| ' ) !== 1 ) {
24
- return ;
23
+
24
+ // Fix inline doc blocks
25
+ $ appendix = '' ;
26
+ $ varIndex = strpos ($ content , '$ ' );
27
+ if ($ varIndex ) {
28
+ $ appendix = substr ($ content , $ varIndex );
29
+ $ content = trim (substr ($ content , 0 , $ varIndex ));
25
30
}
26
31
27
- list ($ left , $ right ) = explode ('| ' , $ content );
28
- $ newContent = trim ($ left ) . '| ' . trim ($ right );
32
+ $ pieces = explode ('| ' , $ content );
33
+ $ newContent = [];
34
+ foreach ($ pieces as $ piece ) {
35
+ $ newContent [] = trim ($ piece );
36
+ }
37
+ $ newContent = implode ('| ' , $ newContent );
29
38
30
39
if ($ newContent !== $ content ) {
31
40
$ fix = $ phpcsFile ->addFixableError ('There should be no space around pipes in doc blocks. ' , $ stackPtr ,
32
41
'PipeSpacing ' );
33
42
if ($ fix ) {
34
- $ phpcsFile ->fixer ->replaceToken ($ stackPtr , $ newContent );
43
+ if ($ appendix ) {
44
+ $ appendix = ' ' . $ appendix ;
45
+ }
46
+ $ phpcsFile ->fixer ->replaceToken ($ stackPtr , $ newContent . $ appendix );
35
47
}
36
48
}
37
49
}
0 commit comments