Skip to content

Commit

Permalink
✨ Add SlevomatCodingStandard.Commenting.UselessInheritDocComment
Browse files Browse the repository at this point in the history
Fixes #21
  • Loading branch information
dpi committed Jun 4, 2024
1 parent cca85bb commit 2cdfc44
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
check: test lint

test:
bin/phpunit

lint: codestyle static-analysis

fix:
bin/phpcbf

codestyle:
bin/phpcs

static-analysis:
bin/phpstan
3 changes: 3 additions & 0 deletions PreviousNextDrupal/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
</properties>
</rule>

<!-- SlevomatCodingStandard.Commenting -->
<rule ref="SlevomatCodingStandard.Commenting.UselessInheritDocComment" />

<!-- SlevomatCodingStandard.Functions -->
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInCall" />
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration" />
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ function doesAThing(array $data): int {
#### PSR2.Methods.FunctionClosingBrace.SpacingBeforeClose
#### SlevomatCodingStandard.Classes.ClassStructure
#### SlevomatCodingStandard.Classes.RequireMultiLineMethodSignature
#### SlevomatCodingStandard.Commenting.UselessInheritDocComment
#### SlevomatCodingStandard.Functions.RequireTrailingCommaInCall
#### SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration
#### SlevomatCodingStandard.Functions.StaticClosure
Expand Down
29 changes: 29 additions & 0 deletions tests/Sniffs/UselessInheritDocCommentTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace PreviousNext\CodingStandard\Tests\Sniffs;

use SlevomatCodingStandard\Sniffs\Commenting\UselessInheritDocCommentSniff;

/**
* @covers \SlevomatCodingStandard\Sniffs\Commenting\UselessInheritDocCommentSniff
*/
final class UselessInheritDocCommentTest extends Base {

public function testNoError(): void {
$report = self::checkFile(__DIR__ . '/fixtures/UselessInheritDocCommentNoError.php');
self::assertNoSniffErrorInFile($report);
}

public function testMissing(): void {
$report = self::checkFile(__DIR__ . '/fixtures/UselessInheritDocCommentError.php');
self::assertSame(1, $report->getErrorCount());
self::assertSniffError($report, 14, UselessInheritDocCommentSniff::CODE_USELESS_INHERIT_DOC_COMMENT);
}

protected static function getSniffName(): string {
return 'SlevomatCodingStandard.Commenting.UselessInheritDocComment';
}

}
21 changes: 21 additions & 0 deletions tests/Sniffs/fixtures/UselessInheritDocCommentError.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace Sniffs\fixtures;

use PreviousNext\CodingStandard\Tests\Sniffs\fixtures\UselessInheritDocCommentParent;

/**
* The class.
*/
final class UselessInheritDocCommentError extends UselessInheritDocCommentParent {

/**
* {@inheritdoc}
*/
public function foo(): void {
parent::foo();
}

}
19 changes: 19 additions & 0 deletions tests/Sniffs/fixtures/UselessInheritDocCommentNoError.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace PreviousNext\CodingStandard\Tests\Sniffs\fixtures;

/**
* The class.
*/
final class UselessInheritDocCommentNoError extends UselessInheritDocCommentParent {

/**
* Foo.
*/
public function foo(): void {
parent::foo();
}

}
15 changes: 15 additions & 0 deletions tests/Sniffs/fixtures/UselessInheritDocCommentParent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

namespace PreviousNext\CodingStandard\Tests\Sniffs\fixtures;

/**
* The parent class.
*/
abstract class UselessInheritDocCommentParent {

public function foo(): void {
}

}

0 comments on commit 2cdfc44

Please sign in to comment.