Skip to content

Commit

Permalink
Cover methods, interfaces and traits with space after attributes
Browse files Browse the repository at this point in the history
Plus fix some `#[\Attribute(` wrong constructors
by renaming to custom one.
  • Loading branch information
stronk7 committed Mar 23, 2024
1 parent 6a18118 commit 38a3204
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 9 deletions.
17 changes: 17 additions & 0 deletions moodle/Tests/Sniffs/Commenting/MissingDocblockSniffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
defined('MOODLE_INTERNAL') || die(); // Make this always the 1st line in all CS fixtures.

/**
* Example class.
* Example class.
*/
#[\Attribute(
#[someattribute(
attr1: 'asdf',
attr2: 'asdf',
)]
Expand All @@ -20,7 +20,7 @@ class class_multiline_attribute {
/**
* Method attribute.
*/
#[\Attribute(
#[someattribute(
attr1: 'asdf',
attr2: 'asdf',
)]
Expand All @@ -31,7 +31,7 @@ function method_multiline_attribute(): void {
/**
* Interface with multiline attributes.
*/
#[\Attribute(
#[someattribute(
attr1: 'asdf',
attr2: 'asdf',
)]
Expand All @@ -41,7 +41,7 @@ interface interface_multiline_attribute {
/**
* Trait with multiline attributes.
*/
#[\Attribute(
#[someattribute(
attr1: 'asdf',
attr2: 'asdf',
)]
Expand All @@ -52,7 +52,7 @@ trait trait_multiline_attribute {
* Example class.
*/

#[\Attribute(
#[someattribute(
attr1: 'asdf',
attr2: 'asdf',
)]
Expand All @@ -62,7 +62,7 @@ class class_multiline_attribute_space_between {
* Method attribute.
*/

#[\Attribute(
#[someattribute(
attr1: 'asdf',
attr2: 'asdf',
)]
Expand All @@ -74,7 +74,7 @@ function method_multiline_attribute_space_between(): void {
* Interface with multiline attributes.
*/

#[\Attribute(
#[someattribute(
attr1: 'asdf',
attr2: 'asdf',
)]
Expand All @@ -85,7 +85,7 @@ interface interface_multiline_attribute_space_between {
* Trait with multiline attributes and space between.
*/

#[\Attribute(
#[someattribute(
attr1: 'asdf',
attr2: 'asdf',
)]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

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

use example;

/**
* Interface level docblock.
*/
#[example_attribute]
#[with_multiple_attributes, and_another_attribute]

interface interface_only_with_attributes_incorrect_whitespace {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

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

use example;

/**
* Trait level docblock.
*/
#[example_attribute]
#[with_multiple_attributes, and_another_attribute]

trait trait_only_with_attributes_incorrect_whitespace {
}

0 comments on commit 38a3204

Please sign in to comment.