@@ -88,11 +88,30 @@ public function processMemberVar(File $phpcsFile, $stackPtr)
8888 return ;
8989 }
9090
91- // Check if class has already have meaningful description
92- $ isShortDescription = $ phpcsFile ->findPrevious (T_DOC_COMMENT_STRING , $ commentEnd , $ foundVar , false );
93- if ($ this ->PHPDocFormattingValidator ->providesMeaning ($ isShortDescription , $ commentStart , $ tokens ) !== true ) {
91+ // Check if class has already have meaningful description after @var tag
92+ $ isShortDescriptionAfterVar = $ phpcsFile ->findNext (T_DOC_COMMENT_STRING , $ foundVar + 4 , $ commentEnd , false ,
93+ null ,
94+ false );
95+ if ($ this ->PHPDocFormattingValidator ->providesMeaning ($ isShortDescriptionAfterVar , $ commentStart , $ tokens ) !== true ) {
96+ preg_match ('`^((?:\|?(?:array\([^\)]*\)|[ \\\\\[\]]+))*)( .*)?`i ' , $ tokens [($ foundVar + 2 )]['content ' ], $ varParts );
97+ if ($ varParts [1 ]) {
98+ return ;
99+ }
100+ $ error = 'Short description duplicates class property name. ' ;
101+ $ phpcsFile ->addWarning ($ error , $ isShortDescriptionAfterVar , 'AlreadyHaveMeaningFulNameVar ' );
102+ return ;
103+ }
104+ // Check if class has already have meaningful description before @var tag
105+ $ isShortDescriptionPreviousVar = $ phpcsFile ->findPrevious (T_DOC_COMMENT_STRING , $ foundVar , $ commentStart , false ,
106+ null ,
107+ false );
108+ if ($ this ->PHPDocFormattingValidator ->providesMeaning ($ isShortDescriptionPreviousVar , $ commentStart , $ tokens ) !== true ) {
109+ preg_match ('`^((?:\|?(?:array\([^\)]*\)|[ \\\\\[\]]+))*)( .*)?`i ' , $ tokens [($ foundVar + 2 )]['content ' ], $ varParts );
110+ if ($ varParts [1 ]) {
111+ return ;
112+ }
94113 $ error = 'Short description duplicates class property name. ' ;
95- $ phpcsFile ->addWarning ($ error , $ isShortDescription , 'AlreadyHaveMeaningFulNameVar ' );
114+ $ phpcsFile ->addWarning ($ error , $ isShortDescriptionPreviousVar , 'AlreadyHaveMeaningFulNameVar ' );
96115 return ;
97116 }
98117 }
0 commit comments