Skip to content

Commit 107799a

Browse files
authored
✨ Add PSR2.Methods.FunctionClosingBrace.SpacingBeforeClose (#4)
1 parent af26a09 commit 107799a

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed

PreviousNextDrupal/ruleset.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
<arg name="extensions" value="php,module,inc,install,test,profile,theme"/>
44
<arg name="ignore" value="*\.css,*\.md"/>
55

6+
<!-- PSR2.Methods -->
7+
<rule ref="PSR2.Methods.FunctionClosingBrace.SpacingBeforeClose"/>
8+
69
<!-- Drupal -->
710
<rule ref="Drupal" />
811

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types = 1);
4+
5+
namespace PreviousNext\CodingStandard\Tests\Sniffs;
6+
7+
/**
8+
* @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\FunctionOpeningBraceSpaceSniff
9+
*/
10+
final class FunctionClosingBraceSpacingBeforeCloseTest extends Base {
11+
12+
public function testNoError(): void {
13+
$report = self::checkFile(__DIR__ . '/fixtures/FunctionClosingBraceSpacingBeforeCloseNoError.php');
14+
self::assertNoSniffErrorInFile($report);
15+
}
16+
17+
public function testError(): void {
18+
$report = self::checkFile(__DIR__ . '/fixtures/FunctionClosingBraceSpacingBeforeCloseError.php');
19+
self::assertSame(1, $report->getErrorCount());
20+
self::assertSniffError($report, 18, sniffName: 'PSR2.Methods.FunctionClosingBrace', code: 'SpacingBeforeClose');
21+
}
22+
23+
protected static function getSniffName(): string {
24+
return 'PSR2.Methods.FunctionClosingBrace.SpacingBeforeClose';
25+
}
26+
27+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
declare(strict_types = 1);
4+
5+
namespace Sniffs\fixtures;
6+
7+
/**
8+
* The class.
9+
*/
10+
final class FunctionClosingBraceSpacingBeforeCloseError {
11+
12+
/**
13+
* Test method.
14+
*/
15+
public function foo(): int {
16+
return 1;
17+
18+
}
19+
20+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
declare(strict_types = 1);
4+
5+
namespace Sniffs\fixtures;
6+
7+
/**
8+
* The class.
9+
*/
10+
final class FunctionClosingBraceSpacingBeforeCloseNoError {
11+
12+
/**
13+
* Test method.
14+
*/
15+
public function foo(): int {
16+
return 1;
17+
}
18+
19+
}

0 commit comments

Comments
 (0)