Skip to content

Commit

Permalink
Merge pull request #114 from PHPCSStandards/feature/universal.classes…
Browse files Browse the repository at this point in the history
….disallowfinalclass-bugfix-metrics

Classes/DisallowFinalClassSniff: fix incorrect recording of metrics
  • Loading branch information
jrfnl committed May 6, 2022
2 parents 7491842 + cfca53a commit 7793726
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Universal/Sniffs/Classes/DisallowFinalClassSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ public function process(File $phpcsFile, $stackPtr)
*/
$classProp = BCFile::getClassProperties($phpcsFile, $stackPtr);
if ($classProp['is_final'] === false) {
if ($classProp['is_abstract'] === false) {
if ($classProp['is_abstract'] === true) {
$phpcsFile->recordMetric($stackPtr, 'Class declaration type', 'abstract');
}

$phpcsFile->recordMetric($stackPtr, 'Class declaration type', 'final');
$phpcsFile->recordMetric($stackPtr, 'Class declaration type', 'not abstract, not final');
return;
}

Expand All @@ -70,7 +70,7 @@ public function process(File $phpcsFile, $stackPtr)
return;
}

$phpcsFile->recordMetric($stackPtr, 'Class declaration type', 'not abstract, not final');
$phpcsFile->recordMetric($stackPtr, 'Class declaration type', 'final');

// No extra safeguards needed, we know the keyword will exist based on the check above.
$finalKeyword = $phpcsFile->findPrevious(\T_FINAL, ($stackPtr - 1));
Expand Down

0 comments on commit 7793726

Please sign in to comment.