File tree Expand file tree Collapse file tree 1 file changed +15
-10
lines changed Expand file tree Collapse file tree 1 file changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -131,16 +131,21 @@ public function processMemberVar(File $phpcsFile, $stackPtr)
131
131
return ;
132
132
}
133
133
134
- $ regularExpression = '/
135
- # Split camelCase "words". Two global alternatives. Either g1of2:
136
- (?<=[a-z]) # Position is after a lowercase,
137
- (?=[A-Z]) # and before an uppercase letter.
138
- | (?<=[A-Z]) # Or g2of2; Position is after uppercase,
139
- (?=[A-Z][a-z]) # and before upper-then-lower case.
140
- /x ' ;
141
- $ varTagParts = preg_split ($ regularExpression , $ tokens [$ string ]['content ' ]);
142
-
143
- if (stripos ($ tokens [$ isShortDescriptionPreviousVar ]['content ' ], implode ('' , $ varTagParts )) !== false ) {
134
+ $ propertyNamePosition = $ phpcsFile ->findNext (
135
+ T_VARIABLE ,
136
+ $ foundVar ,
137
+ null ,
138
+ false ,
139
+ null ,
140
+ false
141
+ );
142
+ if ($ propertyNamePosition === false ) {
143
+ return ;
144
+ };
145
+ $ propertyName = trim ($ tokens [$ propertyNamePosition ]['content ' ], '$ ' );
146
+ $ propertyNameParts = array_filter (preg_split ('/(?=[A-Z])/ ' , $ propertyName ));
147
+
148
+ if (stripos ($ tokens [$ isShortDescriptionPreviousVar ]['content ' ], implode ('' , $ propertyNameParts )) !== false ) {
144
149
$ error = 'Short description duplicates class property name. ' ;
145
150
$ phpcsFile ->addWarning ($ error , $ isShortDescriptionPreviousVar , 'AlreadyHaveMeaningfulNameVar ' );
146
151
}
You can’t perform that action at this time.
0 commit comments