Skip to content

Fixed wrongly returning error for valid descriptions #270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Sep 14, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed wrongly returning error for valid descriptions
  • Loading branch information
svera committed Sep 14, 2021
commit e92e17db5e3eae31dc258cbe2ed0ac8f6a36df19
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,17 @@ public function processMemberVar(File $phpcsFile, $stackPtr)
return;
};
$propertyName = trim($tokens[$propertyNamePosition]['content'], '$');
$shortDescription = strtolower($tokens[$isShortDescriptionPreviousVar]['content']);

if (strtolower($tokens[$isShortDescriptionPreviousVar]['content']) === strtolower($propertyName)) {
if ($shortDescription === strtolower($propertyName)) {
$error = 'Short description duplicates class property name.';
$phpcsFile->addWarning($error, $isShortDescriptionPreviousVar, 'AlreadyHaveMeaningfulNameVar');
return;
}

$propertyNameParts = array_filter(preg_split('/(?=[A-Z])/', $propertyName));

if (strtolower($tokens[$isShortDescriptionPreviousVar]['content']) === strtolower(implode(' ', $propertyNameParts))) {
if ($shortDescription === strtolower(implode(' ', $propertyNameParts))) {
$error = 'Short description duplicates class property name.';
$phpcsFile->addWarning($error, $isShortDescriptionPreviousVar, 'AlreadyHaveMeaningfulNameVar');
}
Expand Down