Skip to content

Commit 4efd0ad

Browse files
committed
Merge branch 'php-8.0/zend-validvariablename-support-nullsafe-operator' of https://github.com/jrfnl/PHP_CodeSniffer
2 parents 82efb1e + 49a8d01 commit 4efd0ad

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

src/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ protected function processVariable(File $phpcsFile, $stackPtr)
3838
}
3939

4040
$objOperator = $phpcsFile->findNext([T_WHITESPACE], ($stackPtr + 1), null, true);
41-
if ($tokens[$objOperator]['code'] === T_OBJECT_OPERATOR) {
41+
if ($tokens[$objOperator]['code'] === T_OBJECT_OPERATOR
42+
|| $tokens[$objOperator]['code'] === T_NULLSAFE_OBJECT_OPERATOR
43+
) {
4244
// Check to see if we are using a variable from an object.
4345
$var = $phpcsFile->findNext([T_WHITESPACE], ($objOperator + 1), null, true);
4446
if ($tokens[$var]['code'] === T_STRING) {

src/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,7 @@ $anonClass = new class() {
116116
$bar_foo = 3;
117117
}
118118
};
119+
120+
echo $obj?->varName;
121+
echo $obj?->var_name;
122+
echo $obj?->varName;

src/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public function getErrorList()
5353
99 => 1,
5454
113 => 1,
5555
116 => 1,
56+
121 => 1,
5657
];
5758

5859
}//end getErrorList()

0 commit comments

Comments
 (0)