File tree Expand file tree Collapse file tree 5 files changed +228
-66
lines changed Expand file tree Collapse file tree 5 files changed +228
-66
lines changed Original file line number Diff line number Diff line change @@ -9,10 +9,11 @@ tests/input/class-references.php 10 0
9
9
tests/input/concatenation_spacing.php 24 0
10
10
tests/input/constants-no-lsb.php 2 0
11
11
tests/input/constants-var.php 4 0
12
+ tests/input/ControlStructures.php 13 0
12
13
tests/input/doc-comment-spacing.php 10 0
13
14
tests/input/duplicate-assignment-variable.php 1 0
14
15
tests/input/EarlyReturn.php 6 0
15
- tests/input/example-class.php 45 0
16
+ tests/input/example-class.php 34 0
16
17
tests/input/forbidden-comments.php 8 0
17
18
tests/input/forbidden-functions.php 6 0
18
19
tests/input/inline_type_hint_assertions.php 7 0
@@ -38,9 +39,9 @@ tests/input/use-ordering.php 1 0
38
39
tests/input/useless-semicolon.php 2 0
39
40
tests/input/UselessConditions.php 20 0
40
41
----------------------------------------------------------------------
41
- A TOTAL OF 290 ERRORS AND 0 WARNINGS WERE FOUND IN 34 FILES
42
+ A TOTAL OF 292 ERRORS AND 0 WARNINGS WERE FOUND IN 35 FILES
42
43
----------------------------------------------------------------------
43
- PHPCBF CAN FIX 229 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
44
+ PHPCBF CAN FIX 231 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
44
45
----------------------------------------------------------------------
45
46
46
47
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace ControlStructures ;
6
+
7
+ use InvalidArgumentException ;
8
+ use Throwable ;
9
+ use const PHP_VERSION ;
10
+
11
+ class ControlStructures
12
+ {
13
+ private const VERSION = PHP_VERSION ;
14
+
15
+ /**
16
+ * @return iterable<int>
17
+ */
18
+ public function varAndIfNoSpaceBetween () : iterable
19
+ {
20
+ $ var = 1 ;
21
+ if (self ::VERSION === 0 ) {
22
+ yield 0 ;
23
+ }
24
+ }
25
+
26
+ /**
27
+ * @return iterable<int>
28
+ */
29
+ public function ifAndYieldSpaceBetween () : iterable
30
+ {
31
+ if (self ::VERSION === 0 ) {
32
+ yield 0 ;
33
+ }
34
+
35
+ yield 1 ;
36
+ }
37
+
38
+ /**
39
+ * @return iterable<int>
40
+ */
41
+ public function ifAndYieldFromSpaceBetween () : iterable
42
+ {
43
+ if (self ::VERSION === 0 ) {
44
+ yield 0 ;
45
+ }
46
+
47
+ yield from [];
48
+ }
49
+
50
+ public function ifAndThrowSpaceBetween () : void
51
+ {
52
+ if (self ::VERSION === 0 ) {
53
+ return ;
54
+ }
55
+
56
+ throw new InvalidArgumentException ();
57
+ }
58
+
59
+ public function ifAndReturnSpaceBetween () : int
60
+ {
61
+ if (self ::VERSION === 0 ) {
62
+ return 0 ;
63
+ }
64
+
65
+ return 1 ;
66
+ }
67
+
68
+ public function noSpaceAroundCase () : void
69
+ {
70
+ switch (self ::VERSION ) {
71
+ case 1 :
72
+ case 2 :
73
+ // do something
74
+ break ;
75
+ case 3 :
76
+ // do something else
77
+ break ;
78
+ default :
79
+ }
80
+ }
81
+
82
+ public function spaceBellowBlocks () : void
83
+ {
84
+ if (true ) {
85
+ echo 1 ;
86
+ }
87
+
88
+ do {
89
+ echo 2 ;
90
+ } while (true );
91
+
92
+ while (true ) {
93
+ echo 3 ;
94
+ }
95
+
96
+ for ($ i = 0 ; $ i < 1 ; $ i ++) {
97
+ echo $ i ;
98
+ }
99
+
100
+ foreach ([] as $ item ) {
101
+ echo $ item ;
102
+ }
103
+
104
+ switch (true ) {
105
+ default :
106
+ }
107
+
108
+ try {
109
+ echo 4 ;
110
+ } catch (Throwable $ throwable ) {
111
+ }
112
+
113
+ echo 5 ;
114
+ }
115
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace ControlStructures ;
6
+
7
+ use InvalidArgumentException ;
8
+ use Throwable ;
9
+ use const PHP_VERSION ;
10
+
11
+ class ControlStructures
12
+ {
13
+ private const VERSION = PHP_VERSION ;
14
+
15
+ /**
16
+ * @return iterable<int>
17
+ */
18
+ public function varAndIfNoSpaceBetween () : iterable
19
+ {
20
+ $ var = 1 ;
21
+ if (self ::VERSION === 0 ) {
22
+ yield 0 ;
23
+ }
24
+ }
25
+
26
+ /**
27
+ * @return iterable<int>
28
+ */
29
+ public function ifAndYieldSpaceBetween () : iterable
30
+ {
31
+ if (self ::VERSION === 0 ) {
32
+ yield 0 ;
33
+ }
34
+ yield 1 ;
35
+ }
36
+
37
+ /**
38
+ * @return iterable<int>
39
+ */
40
+ public function ifAndYieldFromSpaceBetween () : iterable
41
+ {
42
+ if (self ::VERSION === 0 ) {
43
+ yield 0 ;
44
+ }
45
+ yield from [];
46
+ }
47
+
48
+ public function ifAndThrowSpaceBetween () : void
49
+ {
50
+ if (self ::VERSION === 0 ) {
51
+ return ;
52
+ }
53
+ throw new InvalidArgumentException ();
54
+ }
55
+
56
+ public function ifAndReturnSpaceBetween () : int
57
+ {
58
+ if (self ::VERSION === 0 ) {
59
+ return 0 ;
60
+ }
61
+
62
+ return 1 ;
63
+ }
64
+
65
+ public function noSpaceAroundCase () : void
66
+ {
67
+ switch (self ::VERSION ) {
68
+ case 1 :
69
+ case 2 :
70
+ // do something
71
+ break ;
72
+ case 3 :
73
+ // do something else
74
+ break ;
75
+ default :
76
+ }
77
+ }
78
+
79
+ public function spaceBellowBlocks () : void
80
+ {
81
+ if (true ) {
82
+ echo 1 ;
83
+ }
84
+ do {
85
+ echo 2 ;
86
+ } while (true );
87
+ while (true ) {
88
+ echo 3 ;
89
+ }
90
+ for ($ i = 0 ; $ i < 1 ; $ i ++) {
91
+ echo $ i ;
92
+ }
93
+ foreach ([] as $ item ) {
94
+ echo $ item ;
95
+ }
96
+ switch (true ) {
97
+ default :
98
+ }
99
+ try {
100
+ echo 4 ;
101
+ } catch (Throwable $ throwable ) {
102
+ }
103
+ echo 5 ;
104
+ }
105
+ }
Original file line number Diff line number Diff line change @@ -89,63 +89,4 @@ public static function getTestCase() : TestCase
89
89
return new TestCase ();
90
90
}
91
91
92
- /**
93
- * @return iterable<int>
94
- */
95
- public function yieldSomething () : iterable
96
- {
97
- if (self ::VERSION === 0 ) {
98
- yield 0 ;
99
- }
100
- yield 1 ;
101
- }
102
-
103
- /**
104
- * @return iterable<int>
105
- */
106
- public function yieldFromSomething () : iterable
107
- {
108
- if (self ::VERSION === 0 ) {
109
- yield 0 ;
110
- }
111
- yield from [];
112
- }
113
-
114
- public function throwWhenInvalid () : void
115
- {
116
- if (self ::VERSION === 0 ) {
117
- return ;
118
- }
119
- throw new \InvalidArgumentException ();
120
- }
121
-
122
- public function trySwitchSpace () : void
123
- {
124
- try {
125
- $ var = 1 ;
126
- switch (self ::VERSION ) {
127
- case 1 :
128
- case 2 :
129
- // do something
130
- break ;
131
- case 3 :
132
- // do something else
133
- break ;
134
- default :
135
- }
136
- foreach ([] as $ item ) {
137
- echo $ item ;
138
- }
139
- while (true ) {
140
- echo 2 ;
141
- }
142
- if (true ) {
143
- echo 3 ;
144
- }
145
- echo 1 ;
146
- } catch (Throwable $ throwable ) {
147
- }
148
- echo 2 ;
149
- }
150
-
151
92
}
Original file line number Diff line number Diff line change @@ -22,11 +22,11 @@ index 855edfd..5653a39 100644
22
22
tests/input/useless-semicolon.php 2 0
23
23
tests/input/UselessConditions.php 20 0
24
24
----------------------------------------------------------------------
25
- - A TOTAL OF 290 ERRORS AND 0 WARNINGS WERE FOUND IN 34 FILES
26
- + A TOTAL OF 294 ERRORS AND 0 WARNINGS WERE FOUND IN 34 FILES
25
+ - A TOTAL OF 292 ERRORS AND 0 WARNINGS WERE FOUND IN 35 FILES
26
+ + A TOTAL OF 296 ERRORS AND 0 WARNINGS WERE FOUND IN 35 FILES
27
27
----------------------------------------------------------------------
28
- - PHPCBF CAN FIX 229 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
29
- + PHPCBF CAN FIX 233 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
28
+ - PHPCBF CAN FIX 231 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
29
+ + PHPCBF CAN FIX 235 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
30
30
----------------------------------------------------------------------
31
31
32
32
You can’t perform that action at this time.
0 commit comments