@@ -32,7 +32,6 @@ public function register()
32
32
public function process (File $ phpcsFile , $ stackPtr )
33
33
{
34
34
$ tokens = $ phpcsFile ->getTokens ();
35
- //T_DOC_COMMENT_STRING;PHPCS_T_DOC_COMMENT_TAG;
36
35
37
36
// Only check use statements in the global scope.
38
37
if (empty ($ tokens [$ stackPtr ]['conditions ' ]) === false ) {
@@ -127,7 +126,7 @@ public function process(File $phpcsFile, $stackPtr)
127
126
}
128
127
129
128
$ classUsed = $ phpcsFile ->findNext (
130
- [T_STRING , T_DOC_COMMENT_STRING , T_RETURN_TYPE ],
129
+ [T_STRING , T_RETURN_TYPE ],
131
130
($ classUsed + 1 )
132
131
);
133
132
}
@@ -144,10 +143,20 @@ public function process(File $phpcsFile, $stackPtr)
144
143
145
144
// Check for @param Truc or @return Machin
146
145
if ('T_DOC_COMMENT_STRING ' === $ token ['type ' ]) {
147
- // Handle @return Machin|Machine
148
- if (preg_match ('/^ ' .$ lowerClassName .'\|/i ' , $ token ['content ' ]) === 1
149
- || preg_match ('/\| ' .$ lowerClassName .'\|/i ' , $ token ['content ' ]) === 1
150
- || preg_match ('/\| ' .$ lowerClassName .'$/i ' , $ token ['content ' ]) === 1 ) {
146
+ if (trim (strtolower ($ token ['content ' ])) === $ lowerClassName
147
+ // Handle @return Machin|Machine|AnotherMachin
148
+ || preg_match ('/^ ' .$ lowerClassName .'\|/i ' , trim ($ token ['content ' ])) === 1
149
+ || preg_match ('/\| ' .$ lowerClassName .'\|/i ' , trim ($ token ['content ' ])) === 1
150
+ || preg_match ('/\| ' .$ lowerClassName .'$/i ' , trim ($ token ['content ' ])) === 1
151
+ // Handle @var Machin $machin
152
+ || preg_match ('/^ ' .$ lowerClassName .' /i ' , trim ($ token ['content ' ])) === 1
153
+ // Handle @var $machin Machin
154
+ || preg_match ('/ ' .$ lowerClassName .' /i ' , trim ($ token ['content ' ])) === 1
155
+ || preg_match ('/ ' .$ lowerClassName .'$/i ' , trim ($ token ['content ' ])) === 1
156
+ // Handle @var Machin|Machine $machin
157
+ || preg_match ('/\| ' .$ lowerClassName .' /i ' , trim ($ token ['content ' ])) === 1
158
+ // Handle @var $machin Machin|Machine
159
+ || preg_match ('/ ' .$ lowerClassName .'\|/i ' , trim ($ token ['content ' ])) === 1 ) {
151
160
$ beforeUsage = $ phpcsFile ->findPrevious (
152
161
Tokens::$ emptyTokens ,
153
162
($ classUsed - 1 ),
0 commit comments