Skip to content

Commit a222ec6

Browse files
committed
PHP 8.0 | Squiz/LowercasePHPFunctions: allow for nullsafe object operator
Includes unit test.
1 parent 85f3521 commit a222ec6

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

src/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,9 @@ public function process(File $phpcsFile, $stackPtr)
133133
return;
134134
}
135135

136-
if ($tokens[$prev]['code'] === T_OBJECT_OPERATOR) {
136+
if ($tokens[$prev]['code'] === T_OBJECT_OPERATOR
137+
|| $tokens[$prev]['code'] === T_NULLSAFE_OBJECT_OPERATOR
138+
) {
137139
// Not an inbuilt function.
138140
return;
139141
}

src/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,5 @@ $callToNamespacedFunction = MyNamespace /* phpcs:ignore Standard */ \STR_REPEAT(
3939
$callToNamespacedFunction = namespace\STR_REPEAT($a, 2); // Could potentially be false negative.
4040

4141
$filePath = new \File($path);
42+
43+
$count = $object?->Count();

src/Standards/Squiz/Tests/PHP/LowercasePHPFunctionsUnitTest.inc.fixed

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,5 @@ $callToNamespacedFunction = MyNamespace /* phpcs:ignore Standard */ \STR_REPEAT(
3939
$callToNamespacedFunction = namespace\STR_REPEAT($a, 2); // Could potentially be false negative.
4040

4141
$filePath = new \File($path);
42+
43+
$count = $object?->Count();

0 commit comments

Comments
 (0)