@@ -112,10 +112,11 @@ public function processMemberVar(File $phpcsFile, $stackPtr)
112112 if ($ varParts [1 ]) {
113113 return ;
114114 }
115- $ error = 'Short description duplicates class property name . ' ;
116- $ phpcsFile ->addWarning ($ error , $ isShortDescriptionAfterVar , 'AlreadyHaveMeaningFulNameVar ' );
115+ $ error = 'Short description must be before @var tag . ' ;
116+ $ phpcsFile ->addWarning ($ error , $ isShortDescriptionAfterVar , 'ShortDescriptionAfterVar ' );
117117 return ;
118118 }
119+
119120 // Check if class has already have meaningful description before @var tag
120121 $ isShortDescriptionPreviousVar = $ phpcsFile ->findPrevious (
121122 T_DOC_COMMENT_STRING ,
@@ -125,23 +126,28 @@ public function processMemberVar(File $phpcsFile, $stackPtr)
125126 null ,
126127 false
127128 );
128- if ($ this ->PHPDocFormattingValidator ->providesMeaning (
129- $ isShortDescriptionPreviousVar ,
130- $ commentStart ,
131- $ tokens
132- ) !== true ) {
133- preg_match (
134- '`^((?:\|?(?:array\([^\)]*\)|[ \\\\\[\]]+))*)( .*)?`i ' ,
135- $ tokens [($ foundVar + 2 )]['content ' ],
136- $ varParts
137- );
138- if ($ varParts [1 ]) {
139- return ;
140- }
129+
130+ if (stripos ($ tokens [$ isShortDescriptionPreviousVar ]['content ' ], $ tokens [$ string ]['content ' ]) !== false ) {
141131 $ error = 'Short description duplicates class property name. ' ;
142- $ phpcsFile ->addWarning ($ error , $ isShortDescriptionPreviousVar , 'AlreadyHaveMeaningFulNameVar ' );
132+ $ phpcsFile ->addWarning ($ error , $ isShortDescriptionPreviousVar , 'AlreadyHaveMeaningfulNameVar ' );
143133 return ;
144134 }
135+ $ re = '/
136+ # Split camelCase "words". Two global alternatives. Either g1of2:
137+ (?<=[a-z]) # Position is after a lowercase,
138+ (?=[A-Z]) # and before an uppercase letter.
139+ | (?<=[A-Z]) # Or g2of2; Position is after uppercase,
140+ (?=[A-Z][a-z]) # and before upper-then-lower case.
141+ /x ' ;
142+ $ varTagParts = preg_split ($ re , $ tokens [$ string ]['content ' ]);
143+
144+ foreach ($ varTagParts as $ part ) {
145+ if (stripos ($ tokens [$ isShortDescriptionPreviousVar ]['content ' ], $ part ) === false ) {
146+ return ;
147+ }
148+ }
149+ $ error = 'Short description duplicates class property name. ' ;
150+ $ phpcsFile ->addWarning ($ error , $ isShortDescriptionPreviousVar , 'AlreadyHaveMeaningfulNameVar ' );
145151 }
146152
147153 /**
0 commit comments