Skip to content

Commit 3c90cda

Browse files
authored
Merge pull request #934 from PHPCSStandards/feature/generic-lower-uppercaseconstants-support-dnf-types
PHP 8.2 | Generic/[Lower|Upper]CaseConstant: bug fix - ignore DNF property types
2 parents dc1a497 + eac6cde commit 3c90cda

5 files changed

+33
-15
lines changed

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

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,23 @@ class LowerCaseConstantSniff implements Sniff
4343
* @var array<int|string, int|string>
4444
*/
4545
private $propertyTypeTokens = [
46-
T_CALLABLE => T_CALLABLE,
47-
T_SELF => T_SELF,
48-
T_PARENT => T_PARENT,
49-
T_FALSE => T_FALSE,
50-
T_TRUE => T_TRUE,
51-
T_NULL => T_NULL,
52-
T_STRING => T_STRING,
53-
T_NAME_QUALIFIED => T_NAME_QUALIFIED,
54-
T_NAME_FULLY_QUALIFIED => T_NAME_FULLY_QUALIFIED,
55-
T_NAME_RELATIVE => T_NAME_RELATIVE,
56-
T_NS_SEPARATOR => T_NS_SEPARATOR,
57-
T_NAMESPACE => T_NAMESPACE,
58-
T_TYPE_UNION => T_TYPE_UNION,
59-
T_TYPE_INTERSECTION => T_TYPE_INTERSECTION,
60-
T_NULLABLE => T_NULLABLE,
46+
T_CALLABLE => T_CALLABLE,
47+
T_SELF => T_SELF,
48+
T_PARENT => T_PARENT,
49+
T_FALSE => T_FALSE,
50+
T_TRUE => T_TRUE,
51+
T_NULL => T_NULL,
52+
T_STRING => T_STRING,
53+
T_NAME_QUALIFIED => T_NAME_QUALIFIED,
54+
T_NAME_FULLY_QUALIFIED => T_NAME_FULLY_QUALIFIED,
55+
T_NAME_RELATIVE => T_NAME_RELATIVE,
56+
T_NS_SEPARATOR => T_NS_SEPARATOR,
57+
T_NAMESPACE => T_NAMESPACE,
58+
T_TYPE_UNION => T_TYPE_UNION,
59+
T_TYPE_INTERSECTION => T_TYPE_INTERSECTION,
60+
T_TYPE_OPEN_PARENTHESIS => T_TYPE_OPEN_PARENTHESIS,
61+
T_TYPE_CLOSE_PARENTHESIS => T_TYPE_CLOSE_PARENTHESIS,
62+
T_NULLABLE => T_NULLABLE,
6163
];
6264

6365

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,7 @@ class TypedConstants {
151151

152152
// Global constants can not be typed.
153153
const MYCONST = TRUE;
154+
155+
class SkipOverPHP82DNFTypes {
156+
protected (\FullyQualified&Partially\Qualified)|TRUE $propertyC;
157+
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,7 @@ class TypedConstants {
151151

152152
// Global constants can not be typed.
153153
const MYCONST = true;
154+
155+
class SkipOverPHP82DNFTypes {
156+
protected (\FullyQualified&Partially\Qualified)|TRUE $propertyC;
157+
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,7 @@ class TypedThings {
9696
}
9797

9898
$cl = function (int|false $param = null, Type|null $obj = new MyObj(false)) : string|false|null {};
99+
100+
class SkipOverPHP82DNFTypes {
101+
protected (\FullyQualified&Partially\Qualified)|false $propertyC;
102+
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,7 @@ class TypedThings {
9696
}
9797

9898
$cl = function (int|false $param = NULL, Type|null $obj = new MyObj(FALSE)) : string|false|null {};
99+
100+
class SkipOverPHP82DNFTypes {
101+
protected (\FullyQualified&Partially\Qualified)|false $propertyC;
102+
}

0 commit comments

Comments
 (0)