Skip to content

Commit 2b63770

Browse files
authored
Merge pull request #948 from PHPCSStandards/feature/generic-lower-uppercaseconstants-support-php84-final-props
PHP 8.4 | Generic/[Lower|Upper]CaseConstant: add support for final properties
2 parents 1d3d27f + ba94062 commit 2b63770

5 files changed

+22
-0
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public function register()
7777
$targets[] = T_VAR;
7878
$targets[] = T_STATIC;
7979
$targets[] = T_READONLY;
80+
$targets[] = T_FINAL;
8081

8182
// Register function keywords to filter out param/return type declarations.
8283
$targets[] = T_FUNCTION;
@@ -137,6 +138,7 @@ public function process(File $phpcsFile, $stackPtr)
137138
|| $tokens[$stackPtr]['code'] === T_VAR
138139
|| $tokens[$stackPtr]['code'] === T_STATIC
139140
|| $tokens[$stackPtr]['code'] === T_READONLY
141+
|| $tokens[$stackPtr]['code'] === T_FINAL
140142
) {
141143
$skipOver = (Tokens::$emptyTokens + $this->propertyTypeTokens);
142144
$skipTo = $phpcsFile->findNext($skipOver, ($stackPtr + 1), null, true);

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

+5
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,8 @@ const MYCONST = TRUE;
155155
class SkipOverPHP82DNFTypes {
156156
protected (\FullyQualified&Partially\Qualified)|TRUE $propertyC;
157157
}
158+
159+
class SkipOverPHP84FinalProperties {
160+
final MyType|FALSE $propA;
161+
private static final NULL|MyClass $propB;
162+
}

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

+5
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,8 @@ const MYCONST = true;
155155
class SkipOverPHP82DNFTypes {
156156
protected (\FullyQualified&Partially\Qualified)|TRUE $propertyC;
157157
}
158+
159+
class SkipOverPHP84FinalProperties {
160+
final MyType|FALSE $propA;
161+
private static final NULL|MyClass $propB;
162+
}

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

+5
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,8 @@ $cl = function (int|false $param = null, Type|null $obj = new MyObj(false)) : st
100100
class SkipOverPHP82DNFTypes {
101101
protected (\FullyQualified&Partially\Qualified)|false $propertyC;
102102
}
103+
104+
class SkipOverPHP84FinalProperties {
105+
final MyType|false $propA;
106+
private static final null|MyClass $propB;
107+
}

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

+5
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,8 @@ $cl = function (int|false $param = NULL, Type|null $obj = new MyObj(FALSE)) : st
100100
class SkipOverPHP82DNFTypes {
101101
protected (\FullyQualified&Partially\Qualified)|false $propertyC;
102102
}
103+
104+
class SkipOverPHP84FinalProperties {
105+
final MyType|false $propA;
106+
private static final null|MyClass $propB;
107+
}

0 commit comments

Comments
 (0)