Skip to content

Commit 87beff1

Browse files
authored
Merge pull request #1117 from PHPCSStandards/php-8.4/feature/generic-lowercasekeyword-support-asym-visibility
Generic/LowerCaseKeyword: add support for asym visibility keywords
2 parents f34a543 + 83ac393 commit 87beff1

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ public function register()
3333
T_MATCH_DEFAULT => T_MATCH_DEFAULT,
3434
T_PARENT => T_PARENT,
3535
T_SELF => T_SELF,
36+
T_PUBLIC_SET => T_PUBLIC_SET,
37+
T_PROTECTED_SET => T_PROTECTED_SET,
38+
T_PRIVATE_SET => T_PRIVATE_SET,
3639
];
3740

3841
return $targets;

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,17 @@ $c = function() {
6060
FROM fun();
6161
}
6262

63+
class AsymmetricVisibility {
64+
public(set) int $correctPublicSet;
65+
protected(set) int $correctProtectedSet;
66+
private(set) int $correctPrivateSet;
67+
68+
PubliC(SeT) int $wrongCasePublic;
69+
PROTECTED(set) array $wrongCaseProtected;
70+
protected(sEt) int $wrongCaseProtectedSet;
71+
Private(set) int $wrongCasePrivate;
72+
private(SET) readonly ?string $wrongCasePrivateSet;
73+
}
74+
6375
__HALT_COMPILER(); // An exception due to phar support.
6476
function

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,17 @@ $c = function() {
6060
from fun();
6161
}
6262

63+
class AsymmetricVisibility {
64+
public(set) int $correctPublicSet;
65+
protected(set) int $correctProtectedSet;
66+
private(set) int $correctPrivateSet;
67+
68+
public(set) int $wrongCasePublic;
69+
protected(set) array $wrongCaseProtected;
70+
protected(set) int $wrongCaseProtectedSet;
71+
private(set) int $wrongCasePrivate;
72+
private(set) readonly ?string $wrongCasePrivateSet;
73+
}
74+
6375
__HALT_COMPILER(); // An exception due to phar support.
6476
function

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ public function getErrorList()
5555
57 => 2,
5656
58 => 1,
5757
60 => 1,
58+
68 => 1,
59+
69 => 1,
60+
70 => 1,
61+
71 => 1,
62+
72 => 1,
5863
];
5964

6065
}//end getErrorList()

0 commit comments

Comments
 (0)