diff --git a/moodle/Sniffs/Commenting/MissingDocblockSniff.php b/moodle/Sniffs/Commenting/MissingDocblockSniff.php index 083f700..82bc55f 100644 --- a/moodle/Sniffs/Commenting/MissingDocblockSniff.php +++ b/moodle/Sniffs/Commenting/MissingDocblockSniff.php @@ -110,7 +110,7 @@ protected function processScopes(File $phpcsFile, int $stackPtr): void { $objectName = TokenUtil::getObjectName($phpcsFile, $typePtr); $objectType = TokenUtil::getObjectType($phpcsFile, $typePtr); - $phpcsFile->addError('Missing docblock for %s %s', $typePtr, $objectType, [$objectType, $objectName]); + $phpcsFile->addError('Missing docblock for %s %s', $typePtr, ucfirst($objectType), [$objectType, $objectName]); } if ($artifactCount === 1) { @@ -208,7 +208,7 @@ protected function processFunctions(File $phpcsFile, int $stackPtr): void { ); } } else { - $phpcsFile->addError('Missing docblock for %s %s', $typePtr, $objectType, [$objectType, $objectName]); + $phpcsFile->addError('Missing docblock for %s %s', $typePtr, ucfirst($objectType), [$objectType, $objectName]); } } } diff --git a/moodle/Tests/Sniffs/Commenting/MissingDocblockSniffTest.php b/moodle/Tests/Sniffs/Commenting/MissingDocblockSniffTest.php index 25da953..a46ccb5 100644 --- a/moodle/Tests/Sniffs/Commenting/MissingDocblockSniffTest.php +++ b/moodle/Tests/Sniffs/Commenting/MissingDocblockSniffTest.php @@ -52,7 +52,7 @@ public function testMissingDocblockSniff( public static function docblockCorrectnessProvider(): array { $cases = [ - 'Multiple artifacts in a file' => [ + 'Multiple artifacts in a file, check messages' => [ 'fixture' => 'multiple_artifacts', 'fixtureFilename' => null, 'errors' => [ @@ -72,6 +72,26 @@ public static function docblockCorrectnessProvider(): array { 'warnings' => [ ], ], + 'Multiple artifacts in a file, check codes' => [ + 'fixture' => 'multiple_artifacts', + 'fixtureFilename' => null, + 'errors' => [ + 1 => 'moodle.Commenting.MissingDocblock.File', + 34 => 'moodle.Commenting.MissingDocblock.Function', + 38 => 'moodle.Commenting.MissingDocblock.Class', + 95 => 'moodle.Commenting.MissingDocblock.Interface', + 118 => 'moodle.Commenting.MissingDocblock.Trait', + 151 => 'moodle.Commenting.MissingDocblock.Function', + 159 => 'moodle.Commenting.MissingDocblock.Function', + 166 => 'moodle.Commenting.MissingDocblock.Function', + 170 => 'moodle.Commenting.MissingDocblock.Class', + 171 => 'moodle.Commenting.MissingDocblock.Function', + 175 => 'moodle.Commenting.MissingDocblock.Class', + 176 => 'moodle.Commenting.MissingDocblock.Function', + ], + 'warnings' => [ + ], + ], 'File level tag, no class' => [ 'fixture' => 'class_without_docblock', 'fixtureFilename' => null,