diff --git a/moodle/Tests/Sniffs/Commenting/MissingDocblockSniffTest.php b/moodle/Tests/Sniffs/Commenting/MissingDocblockSniffTest.php index 9d95312..0f92795 100644 --- a/moodle/Tests/Sniffs/Commenting/MissingDocblockSniffTest.php +++ b/moodle/Tests/Sniffs/Commenting/MissingDocblockSniffTest.php @@ -108,6 +108,23 @@ public static function docblockCorrectnessProvider(): array { 'fixtureFilename' => null, 'errors' => [ 13 => 'Missing docblock for class class_only_with_attributes_incorrect_whitespace', + 20 => 'Missing docblock for function method_only_with_attributes_incorrect_whitespace', + ], + 'warnings' => [], + ], + 'Interface only with attributes and incorrect whitespace' => [ + 'fixture' => 'interface_only_with_attributes_incorrect_whitespace', + 'fixtureFilename' => null, + 'errors' => [ + 13 => 'Missing docblock for interface interface_only_with_attributes_incorrect_whitespace', + ], + 'warnings' => [], + ], + 'Trait only with attributes and incorrect whitespace' => [ + 'fixture' => 'trait_only_with_attributes_incorrect_whitespace', + 'fixtureFilename' => null, + 'errors' => [ + 13 => 'Missing docblock for trait trait_only_with_attributes_incorrect_whitespace', ], 'warnings' => [], ], @@ -142,6 +159,20 @@ public static function docblockCorrectnessProvider(): array { ], ]; + if (version_compare(PHP_VERSION, '8.0.0') >= 0) { + $cases['Multiline attributes'] = [ + 'fixture' => 'docblock_with_multiline_attributes', + 'fixtureFilename' => null, + 'errors' => [ + 59 => 'Missing docblock for class class_multiline_attribute_space_between', + 69 => 'Missing docblock for function method_multiline_attribute_space_between', + 81 => 'Missing docblock for interface interface_multiline_attribute_space_between', + 92 => 'Missing docblock for trait trait_multiline_attribute_space_between', + ], + 'warnings' => [], + ]; + } + if (version_compare(PHP_VERSION, '8.1.0') >= 0) { $cases['Enum only (correct)'] = [ 'fixture' => 'enum_only', diff --git a/moodle/Tests/Sniffs/Commenting/fixtures/MissingDocblock/class_only_with_attributes_incorrect_whitespace.php b/moodle/Tests/Sniffs/Commenting/fixtures/MissingDocblock/class_only_with_attributes_incorrect_whitespace.php index 33c021e..6d50083 100644 --- a/moodle/Tests/Sniffs/Commenting/fixtures/MissingDocblock/class_only_with_attributes_incorrect_whitespace.php +++ b/moodle/Tests/Sniffs/Commenting/fixtures/MissingDocblock/class_only_with_attributes_incorrect_whitespace.php @@ -11,4 +11,12 @@ #[with_multiple_attributes, and_another_attribute] class class_only_with_attributes_incorrect_whitespace { + /** + * Method level docblock. + */ + #[example_attribute] + #[with_multiple_attributes, and_another_attribute] + + function method_only_with_attributes_incorrect_whitespace(): void { + } } diff --git a/moodle/Tests/Sniffs/Commenting/fixtures/MissingDocblock/docblock_with_multiline_attributes.php b/moodle/Tests/Sniffs/Commenting/fixtures/MissingDocblock/docblock_with_multiline_attributes.php new file mode 100644 index 0000000..f516255 --- /dev/null +++ b/moodle/Tests/Sniffs/Commenting/fixtures/MissingDocblock/docblock_with_multiline_attributes.php @@ -0,0 +1,93 @@ +