@@ -32,7 +32,6 @@ public function register()
3232 public function process (File $ phpcsFile , $ stackPtr )
3333 {
3434 $ tokens = $ phpcsFile ->getTokens ();
35- //T_DOC_COMMENT_STRING;PHPCS_T_DOC_COMMENT_TAG;
3635
3736 // Only check use statements in the global scope.
3837 if (empty ($ tokens [$ stackPtr ]['conditions ' ]) === false ) {
@@ -127,7 +126,7 @@ public function process(File $phpcsFile, $stackPtr)
127126 }
128127
129128 $ classUsed = $ phpcsFile ->findNext (
130- [T_STRING , T_DOC_COMMENT_STRING , T_RETURN_TYPE ],
129+ [T_STRING , T_RETURN_TYPE ],
131130 ($ classUsed + 1 )
132131 );
133132 }
@@ -144,10 +143,20 @@ public function process(File $phpcsFile, $stackPtr)
144143
145144 // Check for @param Truc or @return Machin
146145 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 ) {
151160 $ beforeUsage = $ phpcsFile ->findPrevious (
152161 Tokens::$ emptyTokens ,
153162 ($ classUsed - 1 ),
0 commit comments