-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Require multiline constructor parameters and trailing comma (#75)
- Loading branch information
Showing
9 changed files
with
170 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace PreviousNext\CodingStandard\Tests\Sniffs; | ||
|
||
/** | ||
* @covers \SlevomatCodingStandard\Sniffs\Classes\RequireMultiLineMethodSignatureSniff | ||
*/ | ||
final class RequireMultiLineMethodSignatureTest extends Base { | ||
|
||
public function testNoError(): void { | ||
$report = self::checkFile(__DIR__ . '/fixtures/RequireMultiLineMethodSignatureNoError.php'); | ||
self::assertNoSniffErrorInFile($report); | ||
} | ||
|
||
public function testError(): void { | ||
$report = self::checkFile(__DIR__ . '/fixtures/RequireMultiLineMethodSignatureError.php'); | ||
self::assertSame(1, $report->getErrorCount()); | ||
self::assertSniffError($report, 15, sniffName: 'SlevomatCodingStandard.Classes.RequireMultiLineMethodSignature', code: 'RequiredMultiLineSignature'); | ||
} | ||
|
||
protected static function getSniffName(): string { | ||
return 'SlevomatCodingStandard.Classes.RequireMultiLineMethodSignature'; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace PreviousNext\CodingStandard\Tests\Sniffs; | ||
|
||
/** | ||
* @covers \SlevomatCodingStandard\Sniffs\Classes\RequireMultiLineMethodSignatureSniff | ||
*/ | ||
final class RequireTrailingCommaInDeclarationTest extends Base { | ||
|
||
public function testNoError(): void { | ||
$report = self::checkFile(__DIR__ . '/fixtures/RequireTrailingCommaInDeclarationNoError.php'); | ||
self::assertNoSniffErrorInFile($report); | ||
} | ||
|
||
public function testNoErrorSingleLine(): void { | ||
$report = self::checkFile(__DIR__ . '/fixtures/RequireTrailingCommaInDeclarationSingleLineNoError.php'); | ||
self::assertNoSniffErrorInFile($report); | ||
} | ||
|
||
public function testError(): void { | ||
$report = self::checkFile(__DIR__ . '/fixtures/RequireTrailingCommaInDeclarationError.php'); | ||
self::assertSame(1, $report->getErrorCount()); | ||
self::assertSniffError($report, 17, sniffName: 'SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration', code: 'MissingTrailingComma'); | ||
} | ||
|
||
protected static function getSniffName(): string { | ||
return 'SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration'; | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
tests/Sniffs/fixtures/RequireMultiLineMethodSignatureError.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Sniffs\fixtures; | ||
|
||
/** | ||
* The class. | ||
*/ | ||
final class RequireMultiLineMethodSignatureError { | ||
|
||
/** | ||
* Constructor. | ||
*/ | ||
public function __construct(protected string $fooBar, protected string $helloWorld) { | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
tests/Sniffs/fixtures/RequireMultiLineMethodSignatureNoError.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Sniffs\fixtures; | ||
|
||
/** | ||
* The class. | ||
*/ | ||
final class RequireMultiLineMethodSignatureNoError { | ||
|
||
/** | ||
* Constructor. | ||
*/ | ||
public function __construct( | ||
protected string $fooBar, | ||
protected string $helloWorld, | ||
) { | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
tests/Sniffs/fixtures/RequireTrailingCommaInDeclarationError.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Sniffs\fixtures; | ||
|
||
/** | ||
* The class. | ||
*/ | ||
final class RequireTrailingCommaInDeclarationError { | ||
|
||
/** | ||
* Constructor. | ||
*/ | ||
public function __construct( | ||
protected string $fooBar, | ||
protected string $helloWorld | ||
) { | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
tests/Sniffs/fixtures/RequireTrailingCommaInDeclarationNoError.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Sniffs\fixtures; | ||
|
||
/** | ||
* The class. | ||
*/ | ||
final class RequireTrailingCommaInDeclarationNoError { | ||
|
||
/** | ||
* Constructor. | ||
*/ | ||
public function __construct( | ||
protected string $fooBar, | ||
protected string $helloWorld, | ||
) { | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
tests/Sniffs/fixtures/RequireTrailingCommaInDeclarationSingleLineNoError.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace PreviousNext\CodingStandard\Tests\Sniffs\fixtures; | ||
|
||
/** | ||
* The class. | ||
*/ | ||
final class RequireTrailingCommaInDeclarationSingleLineNoError { | ||
|
||
/** | ||
* Constructor. | ||
*/ | ||
public function __construct(protected string $fooBar) { | ||
} | ||
|
||
} |