Skip to content

Commit 1161b6c

Browse files
authored
✨ Add SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing (#11)
1 parent 6b55213 commit 1161b6c

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed

PreviousNextDrupal/ruleset.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
4242
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification"/>
4343
</rule>
44+
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing" />
45+
4446
<!-- Drupal -->
4547
<rule ref="Drupal" />
4648

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\TypeHints\ReturnTypeHintSpacingSniff;
8+
9+
/**
10+
* @covers \SlevomatCodingStandard\Sniffs\TypeHints\ReturnTypeHintSpacingSniff
11+
*/
12+
final class ReturnTypeHintSpacingTest extends Base {
13+
14+
public function testNoError(): void {
15+
$report = self::checkFile(__DIR__ . '/fixtures/ReturnTypeHintSpacingNoError.php');
16+
self::assertNoSniffErrorInFile($report);
17+
}
18+
19+
public function testError(): void {
20+
$report = self::checkFile(__DIR__ . '/fixtures/ReturnTypeHintSpacingError.php');
21+
self::assertSame(1, $report->getErrorCount());
22+
self::assertSniffError($report, 8, ReturnTypeHintSpacingSniff::CODE_WHITESPACE_BEFORE_COLON);
23+
}
24+
25+
protected static function getSniffName(): string {
26+
return 'SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing';
27+
}
28+
29+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
declare(strict_types = 1);
4+
5+
/**
6+
* A function.
7+
*/
8+
function foo() : ?int {
9+
return NULL;
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
declare(strict_types = 1);
4+
5+
/**
6+
* A function.
7+
*/
8+
function foo(): ?int {
9+
return NULL;
10+
}

0 commit comments

Comments
 (0)