-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PHPCS-242 No whitespace allowed before return type colon (backport)
Signed-off-by: Björn Lange <[email protected]>
- Loading branch information
Showing
9 changed files
with
133 additions
and
1 deletion.
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
18 changes: 18 additions & 0 deletions
18
src/Standards/BestIt/Sniffs/Formatting/ReturnTypeHintSpacingSniff.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 BestIt\Sniffs\Formatting; | ||
|
||
use SlevomatCodingStandard\Sniffs\TypeHints\ReturnTypeHintSpacingSniff as BaseReturnTypeHintSpacingSniff; | ||
|
||
/** | ||
* Checks that there is no whitespace before the return type. | ||
* | ||
* @author blange <[email protected]> | ||
* @package BestIt\Sniffs\Formatting | ||
*/ | ||
class ReturnTypeHintSpacingSniff extends BaseReturnTypeHintSpacingSniff | ||
{ | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
tests/Sniffs/Formatting/Fixtures/ReturnTypeHintSpacingSniff/correct/CorrectClass.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,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BestIt\Sniffs\Formatting\ReturnTypeHintSpacingSniff\Fixtures; | ||
|
||
class CorrectClass | ||
{ | ||
public function isCorrect(): bool | ||
{ | ||
return true; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...ixtures/ReturnTypeHintSpacingSniff/with_errors/NoSpaceBetweenColonAndTypeHint.9.fixed.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,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BestIt\Sniffs\Formatting\ReturnTypeHintSpacingSniff\Fixtures; | ||
|
||
class NoSpaceBetweenColonAndTypeHint | ||
{ | ||
public function isCorrect(): bool | ||
{ | ||
return true; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...ting/Fixtures/ReturnTypeHintSpacingSniff/with_errors/NoSpaceBetweenColonAndTypeHint.9.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,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BestIt\Sniffs\Formatting\ReturnTypeHintSpacingSniff\Fixtures; | ||
|
||
class NoSpaceBetweenColonAndTypeHint | ||
{ | ||
public function isCorrect():bool | ||
{ | ||
return true; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...matting/Fixtures/ReturnTypeHintSpacingSniff/with_errors/WhitespaceBeforeColon.9.fixed.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,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BestIt\Sniffs\Formatting\ReturnTypeHintSpacingSniff\Fixtures; | ||
|
||
class WhitespaceBeforeColon | ||
{ | ||
public function isCorrect(): bool | ||
{ | ||
return true; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...fs/Formatting/Fixtures/ReturnTypeHintSpacingSniff/with_errors/WhitespaceBeforeColon.9.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,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BestIt\Sniffs\Formatting\ReturnTypeHintSpacingSniff\Fixtures; | ||
|
||
class WhitespaceBeforeColon | ||
{ | ||
public function isCorrect() : bool | ||
{ | ||
return true; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
tests/Sniffs/Formatting/ReturnTypeHintSpacingSniffTest.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,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BestIt\Sniffs\Formatting; | ||
|
||
use BestIt\Sniffs\DefaultSniffIntegrationTestTrait; | ||
use BestIt\SniffTestCase; | ||
use SlevomatCodingStandard\Sniffs\TypeHints\ReturnTypeHintSpacingSniff as BaseReturnTypeHintSpacingSniff; | ||
|
||
/** | ||
* Tests ReturnTypeHintSpacingSniff | ||
* | ||
* @author blange <[email protected]> | ||
* @package BestIt\Sniffs\Formatting | ||
*/ | ||
class ReturnTypeHintSpacingSniffTest extends SniffTestCase | ||
{ | ||
use DefaultSniffIntegrationTestTrait; | ||
|
||
/** | ||
* The tested class. | ||
* | ||
* @var ReturnTypeHintSpacingSniff | ||
*/ | ||
private $fixture; | ||
|
||
/** | ||
* Sets up the test. | ||
* | ||
* @return void | ||
*/ | ||
protected function setUp(): void | ||
{ | ||
$this->fixture = new ReturnTypeHintSpacingSniff(); | ||
} | ||
|
||
/** | ||
* Checks the inheritance of the class. | ||
* | ||
* @return void | ||
*/ | ||
public function testInstance(): void | ||
{ | ||
static::assertInstanceOf(BaseReturnTypeHintSpacingSniff::class, $this->fixture); | ||
} | ||
} |