Skip to content

Commit 282febc

Browse files
VasekPurchartkukulich
authored andcommitted
Remove throwing exception in register method - prevented using the standard out of the box
1 parent e083ac0 commit 282febc

File tree

3 files changed

+4
-45
lines changed

3 files changed

+4
-45
lines changed

SlevomatCodingStandard/Sniffs/Namespaces/FullyQualifiedClassNameAfterKeywordSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ private function getKeywordsToCheck(): array
3939
public function register(): array
4040
{
4141
if (count($this->getKeywordsToCheck()) === 0) {
42-
throw new \SlevomatCodingStandard\Sniffs\Namespaces\NoKeywordsException(self::class, 'keywordsToCheck');
42+
return [];
4343
}
4444
return array_map(function (string $keyword) {
4545
if (!defined($keyword)) {

SlevomatCodingStandard/Sniffs/Namespaces/NoKeywordsException.php

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

tests/Sniffs/Namespaces/FullyQualifiedClassNameAfterKeywordSniffTest.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,10 @@ public function testThrowExceptionForUndefinedConstant()
1919
}
2020
}
2121

22-
public function testThrowExceptionWhenNoKeywordsAreConfigured()
22+
public function testCheckNothingWhenNoKeywordsAreConfigured()
2323
{
24-
try {
25-
$this->checkFile(__DIR__ . '/data/fullyQualifiedExtends.php');
26-
$this->fail();
27-
} catch (\SlevomatCodingStandard\Sniffs\Namespaces\NoKeywordsException $e) {
28-
$this->assertSame('Sniff SlevomatCodingStandard\Sniffs\Namespaces\FullyQualifiedClassNameAfterKeywordSniff requires an array of keywords set in property keywordsToCheck', $e->getMessage());
29-
$this->assertSame(FullyQualifiedClassNameAfterKeywordSniff::class, $e->getSniffClassName());
30-
$this->assertSame('keywordsToCheck', $e->getPropertyName());
31-
}
24+
$fileReport = $this->checkFile(__DIR__ . '/data/fullyQualifiedExtends.php');
25+
$this->assertEmpty($fileReport->getErrors());
3226
}
3327

3428
}

0 commit comments

Comments
 (0)