Skip to content

Commit 3cad95b

Browse files
committed
Generic/UpperCaseConstant: add tests for properties with asymmetric visibility
Sniff already behaves as intended as the parent sniff `LowerCaseConstant` inherits support via the `Tokens::$scopeModifiers` array since PR 871. This commit just adds some extra tests to safeguard this for the future.
1 parent dfd8da3 commit 3cad95b

File tree

3 files changed

+40
-21
lines changed

3 files changed

+40
-21
lines changed

src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.inc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,11 @@ class SkipOverPHP84FinalProperties {
105105
final MyType|false $propA;
106106
private static final null|MyClass $propB;
107107
}
108+
109+
// PHP 8.4 asymmetric visibility
110+
class WithAsym {
111+
private(set) null|true $asym1 = TRUE;
112+
public private(set) ?bool $asym2 = false;
113+
protected(set) false|string|null $asym3 = null;
114+
public protected(set) Type|null|bool $asym4 = true;
115+
}

src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.inc.fixed

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,11 @@ class SkipOverPHP84FinalProperties {
105105
final MyType|false $propA;
106106
private static final null|MyClass $propB;
107107
}
108+
109+
// PHP 8.4 asymmetric visibility
110+
class WithAsym {
111+
private(set) null|true $asym1 = TRUE;
112+
public private(set) ?bool $asym2 = FALSE;
113+
protected(set) false|string|null $asym3 = NULL;
114+
public protected(set) Type|null|bool $asym4 = TRUE;
115+
}

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

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,30 @@ final class UpperCaseConstantUnitTest extends AbstractSniffUnitTest
3131
public function getErrorList()
3232
{
3333
return [
34-
7 => 1,
35-
10 => 1,
36-
15 => 1,
37-
16 => 1,
38-
23 => 1,
39-
26 => 1,
40-
31 => 1,
41-
32 => 1,
42-
39 => 1,
43-
42 => 1,
44-
47 => 1,
45-
48 => 1,
46-
70 => 1,
47-
71 => 1,
48-
85 => 1,
49-
87 => 1,
50-
88 => 1,
51-
90 => 2,
52-
92 => 2,
53-
93 => 1,
54-
98 => 2,
34+
7 => 1,
35+
10 => 1,
36+
15 => 1,
37+
16 => 1,
38+
23 => 1,
39+
26 => 1,
40+
31 => 1,
41+
32 => 1,
42+
39 => 1,
43+
42 => 1,
44+
47 => 1,
45+
48 => 1,
46+
70 => 1,
47+
71 => 1,
48+
85 => 1,
49+
87 => 1,
50+
88 => 1,
51+
90 => 2,
52+
92 => 2,
53+
93 => 1,
54+
98 => 2,
55+
112 => 1,
56+
113 => 1,
57+
114 => 1,
5558
];
5659

5760
}//end getErrorList()

0 commit comments

Comments
 (0)