Skip to content

Commit cdce50d

Browse files
committed
Use PHPCS itself to validate our sniffs
That's easier than doing some workarounds on PHPUnit.
1 parent 4bd6c9b commit cdce50d

11 files changed

+394
-1
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/Tests export-ignore
1+
/tests export-ignore
22
.gitattributes export-ignore
33
.gitignore export-ignore
44
.travis.yml export-ignore

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
vendor/
22
phpcs.xml
33
composer.lock
4+
tests/input2
5+
phpcs.log

tests/expected_report.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
PHP CODE SNIFFER REPORT SUMMARY
3+
----------------------------------------------------------------------
4+
FILE ERRORS WARNINGS
5+
----------------------------------------------------------------------
6+
tests/input/concatenation_spacing.php 19 0
7+
tests/input/not_spacing.php 7 0
8+
tests/input/return_type_on_closures.php 21 0
9+
tests/input/return_type_on_methods.php 16 0
10+
----------------------------------------------------------------------
11+
A TOTAL OF 63 ERRORS AND 0 WARNINGS WERE FOUND IN 4 FILES
12+
----------------------------------------------------------------------
13+
PHPCBF CAN FIX 63 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
14+
----------------------------------------------------------------------
15+
16+
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
$string = 'Doctrine' . 'rulez';
4+
$string = 'Doctrine' . 'rulez';
5+
$string = 'Doctrine' . 'rulez';
6+
$string = 'Doctrine' . 'rulez';
7+
8+
$doctrine = 'Doctrine';
9+
$rulez = 'rulez';
10+
$string = $doctrine . $rulez;
11+
$string = $doctrine . $rulez;
12+
$string = $doctrine . $rulez;
13+
$string = $doctrine . $rulez;
14+
15+
$string = 'Doctrine' . $rulez;
16+
$string = 'Doctrine' . $rulez;
17+
$string = 'Doctrine' . $rulez;
18+
$string = 'Doctrine' . $rulez;
19+
20+
$string = $doctrine . 'rulez';
21+
$string = $doctrine . 'rulez';
22+
$string = $doctrine . 'rulez';
23+
$string = $doctrine . 'rulez';
24+
$string = $doctrine . 'rulez';
25+
26+
$string = $doctrine . $rulez . 'even' . 'more' . $string;
27+
28+
$string .=$doctrine;
29+
$string .= $doctrine;
30+
$string .=$doctrine;
31+
32+
$string = $doctrine .
33+
$rulez .
34+
'all'
35+
. $string;

tests/fixed/not_spacing.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
$test = 1;
4+
5+
if ( ! $test > 0) {
6+
echo 1;
7+
} elseif ( ! $test === 0) {
8+
echo 0;
9+
} else {
10+
echo -1;
11+
}
12+
13+
while ( ! true) {
14+
echo 1;
15+
}
16+
17+
do {
18+
echo 1;
19+
} while ( ! true);
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
function () : void {
4+
}
5+
6+
function () : void {
7+
}
8+
9+
function () : void {
10+
}
11+
12+
function () : void {
13+
}
14+
15+
function () : void {
16+
}
17+
18+
function (
19+
$a,
20+
$c,
21+
$d,
22+
$e,
23+
$b
24+
) : void {
25+
}
26+
27+
function (
28+
$a,
29+
$c,
30+
$d,
31+
$e,
32+
$b
33+
) : void {
34+
}
35+
36+
function (
37+
$a,
38+
$c,
39+
$d,
40+
$e,
41+
$b
42+
) : void {
43+
}
44+
45+
function (
46+
$a,
47+
$c,
48+
$d,
49+
$e,
50+
$b
51+
) : void {
52+
}
53+
54+
function (
55+
$a,
56+
$c,
57+
$d,
58+
$e,
59+
$b
60+
) : void {
61+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
namespace Blah;
3+
4+
class Test
5+
{
6+
public function a() : void
7+
{
8+
}
9+
10+
public function b() : void
11+
{
12+
}
13+
14+
public function c() : void
15+
{
16+
}
17+
18+
public function d() : void
19+
{
20+
}
21+
22+
public function e() : void
23+
{
24+
}
25+
26+
public function f(
27+
$a,
28+
$c,
29+
$d,
30+
$e,
31+
$b
32+
) : void {
33+
}
34+
35+
public function g(
36+
$a,
37+
$c,
38+
$d,
39+
$e,
40+
$b
41+
) : void {
42+
}
43+
44+
public function h(
45+
$a,
46+
$c,
47+
$d,
48+
$e,
49+
$b
50+
) : void {
51+
}
52+
53+
public function i(
54+
$a,
55+
$c,
56+
$d,
57+
$e,
58+
$b
59+
) : void {
60+
}
61+
62+
public function j(
63+
$a,
64+
$c,
65+
$d,
66+
$e,
67+
$b
68+
) : void {
69+
}
70+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
$string = 'Doctrine' . 'rulez';
4+
$string = 'Doctrine'. 'rulez';
5+
$string = 'Doctrine' .'rulez';
6+
$string = 'Doctrine'.'rulez';
7+
8+
$doctrine = 'Doctrine';
9+
$rulez = 'rulez';
10+
$string = $doctrine . $rulez;
11+
$string = $doctrine. $rulez;
12+
$string = $doctrine .$rulez;
13+
$string = $doctrine.$rulez;
14+
15+
$string = 'Doctrine' . $rulez;
16+
$string = 'Doctrine'. $rulez;
17+
$string = 'Doctrine' .$rulez;
18+
$string = 'Doctrine'.$rulez;
19+
20+
$string = $doctrine . 'rulez';
21+
$string = $doctrine . 'rulez';
22+
$string = $doctrine. 'rulez';
23+
$string = $doctrine .'rulez';
24+
$string = $doctrine.'rulez';
25+
26+
$string = $doctrine . $rulez. 'even' .'more'.$string;
27+
28+
$string.=$doctrine;
29+
$string .= $doctrine;
30+
$string .=$doctrine;
31+
32+
$string = $doctrine.
33+
$rulez .
34+
'all'
35+
.$string;

tests/input/not_spacing.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
$test = 1;
4+
5+
if (!$test > 0) {
6+
echo 1;
7+
} elseif ( !$test === 0) {
8+
echo 0;
9+
} else {
10+
echo -1;
11+
}
12+
13+
while ( ! true) {
14+
echo 1;
15+
}
16+
17+
do {
18+
echo 1;
19+
} while ( ! true);
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
3+
function ():void
4+
{
5+
}
6+
7+
function (): void
8+
{
9+
}
10+
11+
function (): void
12+
{
13+
}
14+
15+
function () :void
16+
{
17+
}
18+
19+
function () :void
20+
{
21+
}
22+
23+
function (
24+
$a,
25+
$c,
26+
$d,
27+
$e,
28+
$b
29+
):void {
30+
}
31+
32+
function (
33+
$a,
34+
$c,
35+
$d,
36+
$e,
37+
$b
38+
) :void {
39+
}
40+
41+
function (
42+
$a,
43+
$c,
44+
$d,
45+
$e,
46+
$b
47+
) :void {
48+
}
49+
50+
function (
51+
$a,
52+
$c,
53+
$d,
54+
$e,
55+
$b
56+
): void {
57+
}
58+
59+
function (
60+
$a,
61+
$c,
62+
$d,
63+
$e,
64+
$b
65+
): void {
66+
}

0 commit comments

Comments
 (0)