Skip to content

Commit 06ad6e4

Browse files
authored
✨ Add SlevomatCodingStandard.Commenting.UselessInheritDocComment (#83)
Fixes #21
1 parent cca85bb commit 06ad6e4

File tree

7 files changed

+103
-0
lines changed

7 files changed

+103
-0
lines changed

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
check: test lint
2+
3+
test:
4+
bin/phpunit
5+
6+
lint: codestyle static-analysis
7+
8+
fix:
9+
bin/phpcbf
10+
11+
codestyle:
12+
bin/phpcs
13+
14+
static-analysis:
15+
bin/phpstan

PreviousNextDrupal/ruleset.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
</properties>
3434
</rule>
3535

36+
<!-- SlevomatCodingStandard.Commenting -->
37+
<rule ref="SlevomatCodingStandard.Commenting.UselessInheritDocComment" />
38+
3639
<!-- SlevomatCodingStandard.Functions -->
3740
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInCall" />
3841
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration" />

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ function doesAThing(array $data): int {
131131
#### PSR2.Methods.FunctionClosingBrace.SpacingBeforeClose
132132
#### SlevomatCodingStandard.Classes.ClassStructure
133133
#### SlevomatCodingStandard.Classes.RequireMultiLineMethodSignature
134+
#### SlevomatCodingStandard.Commenting.UselessInheritDocComment
134135
#### SlevomatCodingStandard.Functions.RequireTrailingCommaInCall
135136
#### SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration
136137
#### SlevomatCodingStandard.Functions.StaticClosure
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PreviousNext\CodingStandard\Tests\Sniffs;
6+
7+
use SlevomatCodingStandard\Sniffs\Commenting\UselessInheritDocCommentSniff;
8+
9+
/**
10+
* @covers \SlevomatCodingStandard\Sniffs\Commenting\UselessInheritDocCommentSniff
11+
*/
12+
final class UselessInheritDocCommentTest extends Base {
13+
14+
public function testNoError(): void {
15+
$report = self::checkFile(__DIR__ . '/fixtures/UselessInheritDocCommentNoError.php');
16+
self::assertNoSniffErrorInFile($report);
17+
}
18+
19+
public function testMissing(): void {
20+
$report = self::checkFile(__DIR__ . '/fixtures/UselessInheritDocCommentError.php');
21+
self::assertSame(1, $report->getErrorCount());
22+
self::assertSniffError($report, 14, UselessInheritDocCommentSniff::CODE_USELESS_INHERIT_DOC_COMMENT);
23+
}
24+
25+
protected static function getSniffName(): string {
26+
return 'SlevomatCodingStandard.Commenting.UselessInheritDocComment';
27+
}
28+
29+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Sniffs\fixtures;
6+
7+
use PreviousNext\CodingStandard\Tests\Sniffs\fixtures\UselessInheritDocCommentParent;
8+
9+
/**
10+
* The class.
11+
*/
12+
final class UselessInheritDocCommentError extends UselessInheritDocCommentParent {
13+
14+
/**
15+
* {@inheritdoc}
16+
*/
17+
public function foo(): void {
18+
parent::foo();
19+
}
20+
21+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PreviousNext\CodingStandard\Tests\Sniffs\fixtures;
6+
7+
/**
8+
* The class.
9+
*/
10+
final class UselessInheritDocCommentNoError extends UselessInheritDocCommentParent {
11+
12+
/**
13+
* Foo.
14+
*/
15+
public function foo(): void {
16+
parent::foo();
17+
}
18+
19+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PreviousNext\CodingStandard\Tests\Sniffs\fixtures;
6+
7+
/**
8+
* The parent class.
9+
*/
10+
abstract class UselessInheritDocCommentParent {
11+
12+
public function foo(): void {
13+
}
14+
15+
}

0 commit comments

Comments
 (0)