-
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.
✨ Add
SlevomatCodingStandard.Functions.StaticClosure
Fixes #18
- Loading branch information
Showing
4 changed files
with
70 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
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\Functions\StaticClosureSniff | ||
*/ | ||
final class FunctionsStaticClosureTest extends Base { | ||
|
||
public function testNoError(): void { | ||
$report = self::checkFile(__DIR__ . '/fixtures/FunctionsStaticClosureNoError.php'); | ||
self::assertNoSniffErrorInFile($report); | ||
} | ||
|
||
public function testError(): void { | ||
$report = self::checkFile(__DIR__ . '/fixtures/FunctionsStaticClosureError.php'); | ||
self::assertSame(1, $report->getErrorCount()); | ||
self::assertSniffError($report, 16, sniffName: 'SlevomatCodingStandard.Functions.StaticClosure', code: 'ClosureNotStatic'); | ||
} | ||
|
||
protected static function getSniffName(): string { | ||
return 'SlevomatCodingStandard.Functions.StaticClosure'; | ||
} | ||
|
||
} |
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 PreviousNext\CodingStandard\Tests\Sniffs\fixtures; | ||
|
||
/** | ||
* The class. | ||
*/ | ||
final class FunctionsStaticClosureError { | ||
|
||
/** | ||
* Foo. | ||
*/ | ||
public function foo(): void { | ||
$a = function (): void { | ||
$a = 1; | ||
}; | ||
} | ||
|
||
} |
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 FunctionsStaticClosureNoError { | ||
|
||
/** | ||
* Foo. | ||
*/ | ||
public function foo(): void { | ||
$a = static function (): void { | ||
$a = 1; | ||
}; | ||
} | ||
|
||
} |