Skip to content

Commit

Permalink
Add test for multiline attributes for MissingDocblockSniff
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Ziegenberg <[email protected]>
  • Loading branch information
ziegenberg committed Mar 22, 2024
1 parent c453d81 commit 7d97fed
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
13 changes: 13 additions & 0 deletions moodle/Tests/Sniffs/Commenting/MissingDocblockSniffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,19 @@ public static function docblockCorrectnessProvider(): array {
'errors' => [],
'warnings' => [],
],
'Docblock with attributes on function (correct)' => [
'fixture' => 'docblock_with_multiline_attributes',
'fixtureFilename' => null,
'errors' => [],
'warnings' => [],
],

// Per PER-2.0:
// > If a comment docblock is present on a structure that also includes an
// > attribute, the comment block MUST come first, followed by any
// > attributes, followed by the structure itself. There MUST NOT be any
// > blank lines between the docblock and attributes, or the attributes and
// > the structure.
'Testcase' => [
'fixture' => 'testcase_class',
'fixtureFilename' => '/lib/tests/example_test.php',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace MoodleHQ\MoodleCS\moodle\Tests\Sniffs\PHPUnit;

defined('MOODLE_INTERNAL') || die(); // Make this always the 1st line in all CS fixtures.

/**
* Example class.
*/
#[\Attribute(
attr1: 'asdf',
attr2: 'asdf',
)]
class class_multiline_attribute {

/**
* Method attribute.
*/
#[\Attribute(
attr1: 'asdf',
attr2: 'asdf',
)]
function method_multiline_attribute(): void {
}
}

0 comments on commit 7d97fed

Please sign in to comment.