Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.

Commit 391acf0

Browse files
committed
Added AnonymousClassDeclaration sniff and more tests
1 parent f7454b7 commit 391acf0

File tree

6 files changed

+19
-10
lines changed

6 files changed

+19
-10
lines changed

src/ZendCodingStandard/ruleset.xml

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
<rule ref="WebimpressCodingStandard.PHP.ImportInternalConstant"/>
4444
<!-- Import internal functions -->
4545
<rule ref="WebimpressCodingStandard.PHP.ImportInternalFunction"/>
46+
<!-- Format anonymous class declaration -->
47+
<rule ref="WebimpressCodingStandard.Classes.AnonymousClassDeclaration"/>
4648
<!-- Forbid null values for class properties -->
4749
<rule ref="WebimpressCodingStandard.Classes.NoNullValues"/>
4850
<!-- Comments at the end of the line, with at least single space -->

test/expected-report.txt

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ PHP CODE SNIFFER REPORT SUMMARY
33
----------------------------------------------------------------------
44
FILE ERRORS WARNINGS
55
----------------------------------------------------------------------
6-
test/fixable/anonymous-classes.php 9 0
6+
test/fixable/anonymous-classes.php 11 0
77
test/fixable/array-indentation.php 39 1
88
test/fixable/class-name-resolution.php 15 0
99
test/fixable/class-properties.php 6 0
1010
test/fixable/classes-traits-interfaces.php 16 1
1111
test/fixable/closures.php 19 0
1212
test/fixable/commenting.php 26 0
1313
test/fixable/concatenation-spacing.php 17 0
14-
test/fixable/control-structures.php 5 0
14+
test/fixable/control-structures.php 6 0
1515
test/fixable/example-class.php 29 0
1616
test/fixable/extends-and-implements-multiline.php 10 0
17-
test/fixable/extends-and-implements.php 5 0
17+
test/fixable/extends-and-implements.php 13 0
1818
test/fixable/forbidden-comments.php 6 0
1919
test/fixable/forbidden-functions.php 6 0
2020
test/fixable/heredoc-nowdoc.php 6 0
@@ -33,13 +33,13 @@ test/fixable/statement-alignment.php 19 0
3333
test/fixable/test-case.php 4 0
3434
test/fixable/traits-uses.php 9 0
3535
test/fixable/UnusedVariables.php 1 0
36-
test/fixable/useless-semicolon.php 7 0
36+
test/fixable/useless-semicolon.php 8 0
3737
test/fixable/variable-names.php 5 2
3838
test/fixable/visibility-declaration.php 1 0
3939
----------------------------------------------------------------------
40-
A TOTAL OF 400 ERRORS AND 6 WARNINGS WERE FOUND IN 33 FILES
40+
A TOTAL OF 407 ERRORS AND 6 WARNINGS WERE FOUND IN 33 FILES
4141
----------------------------------------------------------------------
42-
PHPCBF CAN FIX 338 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
42+
PHPCBF CAN FIX 345 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
4343
----------------------------------------------------------------------
4444

4545

test/fixable/anonymous-classes.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
// Brace on the next line
1313
$instance = new class() extends \Foo implements
1414
\ArrayAccess,
15-
\Countable,
16-
\Serializable
15+
\Countable,
16+
\Serializable
1717
{
1818

1919
// Class content

test/fixable/control-structures.php

+4
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@
2121
break 2;
2222
}
2323
}
24+
25+
if ($a === ($b + 1)) {
26+
echo 1;
27+
}

test/fixed/control-structures.php

+4
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@
2121
break 2;
2222
}
2323
}
24+
25+
if ($a === $b + 1) {
26+
echo 1;
27+
}

test/fixed/useless-semicolon.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,5 @@
1919
$closure = function () {
2020
};
2121

22-
$anonym = new class()
23-
{
22+
$anonym = new class() {
2423
};

0 commit comments

Comments
 (0)