@@ -112,10 +112,11 @@ public function processMemberVar(File $phpcsFile, $stackPtr)
112
112
if ($ varParts [1 ]) {
113
113
return ;
114
114
}
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 ' );
117
117
return ;
118
118
}
119
+
119
120
// Check if class has already have meaningful description before @var tag
120
121
$ isShortDescriptionPreviousVar = $ phpcsFile ->findPrevious (
121
122
T_DOC_COMMENT_STRING ,
@@ -125,23 +126,28 @@ public function processMemberVar(File $phpcsFile, $stackPtr)
125
126
null ,
126
127
false
127
128
);
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 ) {
141
131
$ error = 'Short description duplicates class property name. ' ;
142
- $ phpcsFile ->addWarning ($ error , $ isShortDescriptionPreviousVar , 'AlreadyHaveMeaningFulNameVar ' );
132
+ $ phpcsFile ->addWarning ($ error , $ isShortDescriptionPreviousVar , 'AlreadyHaveMeaningfulNameVar ' );
143
133
return ;
144
134
}
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 ' );
145
151
}
146
152
147
153
/**
0 commit comments