Skip to content

Commit a4d68e3

Browse files
authored
✨ Disable SlevomatCodingStandard.TypeHints.ReturnTypeHint.UselessAnnotation (#52)
1 parent 38c0556 commit a4d68e3

File tree

5 files changed

+5
-38
lines changed

5 files changed

+5
-38
lines changed

PreviousNextDrupal/ruleset.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification"/>
4343
</rule>
4444
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing" />
45+
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.UselessAnnotation"><severity>0</severity></rule>
4546

4647
<!-- Squiz.PHP -->
4748
<rule ref="Squiz.PHP.NonExecutableCode.Unreachable"><severity>0</severity></rule>

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ Developers are entrusted to properly self-describe code. Suggestions to improve
161161

162162
This rule has trouble with newer PHP syntax, especially expression throwables. In any case this rule is best enforced with static analysis.
163163

164+
#### SlevomatCodingStandard.TypeHints.ReturnTypeHint.UselessAnnotation
165+
166+
This rule is too greedy about what it thinks is 'useless'. Unique detail is removed.
167+
164168
---
165169

166170
_Drupal is a registered trademark of Dries Buytaert._

tests/Sniffs/ReturnTypeHintTest.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
namespace PreviousNext\CodingStandard\Tests\Sniffs;
66

7-
use SlevomatCodingStandard\Sniffs\TypeHints\ReturnTypeHintSniff;
8-
97
/**
108
* @covers \SlevomatCodingStandard\Sniffs\TypeHints\ReturnTypeHintSniff
119
* @see https://github.com/slevomat/coding-standard/blob/master/doc/type-hints.md#slevomatcodingstandardtypehintsreturntypehint-
@@ -28,17 +26,6 @@ public function testIgnoreTraversable(): void {
2826
self::assertNoSniffError($report, 8);
2927
}
3028

31-
public function testUseless(): void {
32-
$report = self::checkFile(__DIR__ . '/fixtures/ReturnTypeHintUseless.php');
33-
self::assertSniffError($report, 8, code: ReturnTypeHintSniff::CODE_USELESS_ANNOTATION);
34-
}
35-
36-
public function testUselessWithDescription(): void {
37-
$report = self::checkFile(__DIR__ . '/fixtures/ReturnTypeHintUselessWithDescription.php');
38-
self::assertSame(0, $report->getErrorCount());
39-
self::assertNoSniffError($report, 8);
40-
}
41-
4229
protected static function getSniffName(): string {
4330
return 'SlevomatCodingStandard.TypeHints.ReturnTypeHint';
4431
}

tests/Sniffs/fixtures/ReturnTypeHintUseless.php

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/Sniffs/fixtures/ReturnTypeHintUselessWithDescription.php

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)