Skip to content

Commit dc90f75

Browse files
Add tests for existing sniffs
1 parent b6b518f commit dc90f75

7 files changed

+98
-25
lines changed

src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.1.inc

+12
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,15 @@ class TypedConstants {
151151

152152
// Global constants can not be typed.
153153
const MYCONST = TRUE;
154+
155+
// PHP 8.4 asymmetric visibility
156+
class WithAsym {
157+
158+
private(set) NULL|TRUE $asym1 = TRUE;
159+
160+
public private(set) ?bool $asym2 = FALSE;
161+
162+
protected(set) FALSE|string|null $asym3 = NULL;
163+
164+
public protected(set) Type|NULL|bool $asym4 = TRUE;
165+
}

src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.1.inc.fixed

+12
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,15 @@ class TypedConstants {
151151

152152
// Global constants can not be typed.
153153
const MYCONST = true;
154+
155+
// PHP 8.4 asymmetric visibility
156+
class WithAsym {
157+
158+
private(set) NULL|TRUE $asym1 = true;
159+
160+
public private(set) ?bool $asym2 = false;
161+
162+
protected(set) FALSE|string|null $asym3 = null;
163+
164+
public protected(set) Type|NULL|bool $asym4 = true;
165+
}

src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php

+4
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ public function getErrorList($testFile='')
6666
129 => 1,
6767
149 => 1,
6868
153 => 1,
69+
158 => 1,
70+
160 => 1,
71+
162 => 1,
72+
164 => 1,
6973
];
7074

7175
case 'LowerCaseConstantUnitTest.js':

src/Standards/PSR12/Tests/Properties/ConstantVisibilityUnitTest.inc

+12
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,15 @@ enum SomeEnum {
2020
public const BAR = 'bar';
2121
const BAZ = 'baz';
2222
}
23+
24+
// Don't break on asymmetric visibility
25+
class WithAsym {
26+
27+
private(set) string $asym1;
28+
29+
public private(set) string $asym2;
30+
31+
protected(set) string $asym3;
32+
33+
public protected(set) string $asym4;
34+
}

src/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.inc

+14
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,17 @@ class ReadOnlyProp {
8585

8686
readonly protected ?string $wrongOrder2;
8787
}
88+
89+
class AsymmetricVisibility {
90+
private(set) int $foo,
91+
$bar,
92+
$var = 5;
93+
94+
public private(set) readonly ?string $spaces;
95+
96+
protected(set) array $unfixed;
97+
98+
protected(set) public int $wrongOrder1;
99+
100+
private(set) protected ?string $wrongOrder2;
101+
}

src/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.inc.fixed

+14
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,17 @@ class ReadOnlyProp {
8282

8383
protected readonly ?string $wrongOrder2;
8484
}
85+
86+
class AsymmetricVisibility {
87+
private(set) int $foo,
88+
$bar,
89+
$var = 5;
90+
91+
public private(set) readonly ?string $spaces;
92+
93+
protected(set) array $unfixed;
94+
95+
public protected(set) int $wrongOrder1;
96+
97+
protected private(set) ?string $wrongOrder2;
98+
}

src/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.php

+30-25
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,36 @@ final class PropertyDeclarationUnitTest extends AbstractSniffUnitTest
3131
public function getErrorList()
3232
{
3333
return [
34-
7 => 1,
35-
9 => 2,
36-
10 => 1,
37-
11 => 1,
38-
17 => 1,
39-
18 => 1,
40-
23 => 1,
41-
38 => 1,
42-
41 => 1,
43-
42 => 1,
44-
50 => 2,
45-
51 => 1,
46-
55 => 1,
47-
56 => 1,
48-
61 => 1,
49-
62 => 1,
50-
68 => 1,
51-
69 => 1,
52-
71 => 1,
53-
72 => 1,
54-
76 => 1,
55-
80 => 1,
56-
82 => 1,
57-
84 => 1,
58-
86 => 1,
34+
7 => 1,
35+
9 => 2,
36+
10 => 1,
37+
11 => 1,
38+
17 => 1,
39+
18 => 1,
40+
23 => 1,
41+
38 => 1,
42+
41 => 1,
43+
42 => 1,
44+
50 => 2,
45+
51 => 1,
46+
55 => 1,
47+
56 => 1,
48+
61 => 1,
49+
62 => 1,
50+
68 => 1,
51+
69 => 1,
52+
71 => 1,
53+
72 => 1,
54+
76 => 1,
55+
80 => 1,
56+
82 => 1,
57+
84 => 1,
58+
86 => 1,
59+
90 => 1,
60+
94 => 1,
61+
96 => 1,
62+
98 => 1,
63+
100 => 1,
5964
];
6065

6166
}//end getErrorList()

0 commit comments

Comments
 (0)