@@ -88,11 +88,30 @@ public function processMemberVar(File $phpcsFile, $stackPtr)
88
88
return ;
89
89
}
90
90
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
+ }
94
113
$ error = 'Short description duplicates class property name. ' ;
95
- $ phpcsFile ->addWarning ($ error , $ isShortDescription , 'AlreadyHaveMeaningFulNameVar ' );
114
+ $ phpcsFile ->addWarning ($ error , $ isShortDescriptionPreviousVar , 'AlreadyHaveMeaningFulNameVar ' );
96
115
return ;
97
116
}
98
117
}
0 commit comments