Skip to content

Commit 44632ed

Browse files
committed
Moved tests to 1 test file
1 parent 41ef918 commit 44632ed

5 files changed

Lines changed: 192 additions & 202 deletions

File tree

src/Standards/PSR12/Tests/Operators/OperatorSpacingUnitTest.1.inc

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,97 @@ function setDefault(#[ImportValue(
7777
}
7878

7979
declare(strict_types=1);
80+
81+
// Valid.
82+
try {
83+
// nothing
84+
} catch (Exception | RuntimeException $e) {
85+
}
86+
87+
// Valid because multiline formatting is undefined.
88+
try {
89+
// nothing
90+
} catch (
91+
Exception
92+
| RuntimeException
93+
| KlausiException
94+
| AnotherException
95+
| ItNeverEndsException $e
96+
) {
97+
}
98+
99+
// Valid because multiline formatting is undefined.
100+
try {
101+
// nothing
102+
} catch (
103+
Exception |
104+
RuntimeException |
105+
KlausiException |
106+
AnotherException |
107+
ItNeverEndsException $e
108+
) {
109+
}
110+
111+
// Valid because PSR 12 allows more than one space around operators.
112+
try {
113+
// nothing
114+
} catch (Exception | RuntimeException $e) {
115+
}
116+
117+
// Invalid because of no space.
118+
try {
119+
// nothing
120+
} catch (Exception|RuntimeException $e) {
121+
}
122+
123+
// phpcs:set PSR12.Operators.OperatorSpacing perCompatible 3.0
124+
125+
// Valid.
126+
try {
127+
// nothing
128+
} catch (Exception|RuntimeException $e) {
129+
}
130+
131+
// Valid because multiline formatting is undefined.
132+
try {
133+
// nothing
134+
} catch (
135+
Exception
136+
|RuntimeException
137+
|KlausiException
138+
|AnotherException
139+
|ItNeverEndsException $e
140+
) {
141+
}
142+
143+
// Valid because multiline formatting is undefined.
144+
try {
145+
// nothing
146+
} catch (
147+
Exception|
148+
RuntimeException|
149+
KlausiException|
150+
AnotherException|
151+
ItNeverEndsException $e
152+
) {
153+
}
154+
155+
// Invalid becasue of one space.
156+
try {
157+
// nothing
158+
} catch (Exception | RuntimeException $e) {
159+
}
160+
161+
// Invalid because of multiple spaces.
162+
try {
163+
// nothing
164+
} catch (Exception | RuntimeException $e) {
165+
}
166+
167+
// Testing that it works with future versions as well.
168+
// phpcs:set PSR12.Operators.OperatorSpacing perCompatible 4.0
169+
170+
try {
171+
// nothing
172+
} catch (Exception | RuntimeException $e) {
173+
}

src/Standards/PSR12/Tests/Operators/OperatorSpacingUnitTest.1.inc.fixed

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,97 @@ function setDefault(#[ImportValue(
7777
}
7878

7979
declare(strict_types=1);
80+
81+
// Valid.
82+
try {
83+
// nothing
84+
} catch (Exception | RuntimeException $e) {
85+
}
86+
87+
// Valid because multiline formatting is undefined.
88+
try {
89+
// nothing
90+
} catch (
91+
Exception
92+
| RuntimeException
93+
| KlausiException
94+
| AnotherException
95+
| ItNeverEndsException $e
96+
) {
97+
}
98+
99+
// Valid because multiline formatting is undefined.
100+
try {
101+
// nothing
102+
} catch (
103+
Exception |
104+
RuntimeException |
105+
KlausiException |
106+
AnotherException |
107+
ItNeverEndsException $e
108+
) {
109+
}
110+
111+
// Valid because PSR 12 allows more than one space around operators.
112+
try {
113+
// nothing
114+
} catch (Exception | RuntimeException $e) {
115+
}
116+
117+
// Invalid because of no space.
118+
try {
119+
// nothing
120+
} catch (Exception | RuntimeException $e) {
121+
}
122+
123+
// phpcs:set PSR12.Operators.OperatorSpacing perCompatible 3.0
124+
125+
// Valid.
126+
try {
127+
// nothing
128+
} catch (Exception|RuntimeException $e) {
129+
}
130+
131+
// Valid because multiline formatting is undefined.
132+
try {
133+
// nothing
134+
} catch (
135+
Exception
136+
|RuntimeException
137+
|KlausiException
138+
|AnotherException
139+
|ItNeverEndsException $e
140+
) {
141+
}
142+
143+
// Valid because multiline formatting is undefined.
144+
try {
145+
// nothing
146+
} catch (
147+
Exception|
148+
RuntimeException|
149+
KlausiException|
150+
AnotherException|
151+
ItNeverEndsException $e
152+
) {
153+
}
154+
155+
// Invalid becasue of one space.
156+
try {
157+
// nothing
158+
} catch (Exception|RuntimeException $e) {
159+
}
160+
161+
// Invalid because of multiple spaces.
162+
try {
163+
// nothing
164+
} catch (Exception|RuntimeException $e) {
165+
}
166+
167+
// Testing that it works with future versions as well.
168+
// phpcs:set PSR12.Operators.OperatorSpacing perCompatible 4.0
169+
170+
try {
171+
// nothing
172+
} catch (Exception|RuntimeException $e) {
173+
}

src/Standards/PSR12/Tests/Operators/OperatorSpacingUnitTest.4.inc

Lines changed: 0 additions & 97 deletions
This file was deleted.

src/Standards/PSR12/Tests/Operators/OperatorSpacingUnitTest.4.inc.fixed

Lines changed: 0 additions & 97 deletions
This file was deleted.

0 commit comments

Comments
 (0)