Skip to content

Commit bf1d2b2

Browse files
committed
Merge branch 'php-8.0/generic-scopeindent-support-nullsafe-operator' of https://github.com/jrfnl/PHP_CodeSniffer
2 parents db9089d + 07df22e commit bf1d2b2

File tree

6 files changed

+42
-5
lines changed

6 files changed

+42
-5
lines changed

src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,8 @@ public function process(File $phpcsFile, $stackPtr)
913913
// Don't perform strict checking on chained method calls since they
914914
// are often covered by custom rules.
915915
if ($checkToken !== null
916-
&& $tokens[$checkToken]['code'] === T_OBJECT_OPERATOR
916+
&& ($tokens[$checkToken]['code'] === T_OBJECT_OPERATOR
917+
|| $tokens[$checkToken]['code'] === T_NULLSAFE_OBJECT_OPERATOR)
917918
&& $exact === true
918919
) {
919920
$exact = false;

src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,6 +1454,15 @@ return [
14541454
]),
14551455
];
14561456

1457+
echo $string?->append('foo')
1458+
?->outputUsing();
1459+
1460+
// phpcs:set Generic.WhiteSpace.ScopeIndent exact true
1461+
echo $string?->append('foo')
1462+
?->outputUsing();
1463+
// phpcs:set Generic.WhiteSpace.ScopeIndent exact false
1464+
1465+
/* ADD NEW TESTS ABOVE THIS LINE AND MAKE SURE THAT THE 1 (space-based) AND 2 (tab-based) FILES ARE IN SYNC! */
14571466
?>
14581467

14591468
<?php if (true) : ?>

src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc.fixed

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,6 +1454,15 @@ return [
14541454
]),
14551455
];
14561456

1457+
echo $string?->append('foo')
1458+
?->outputUsing();
1459+
1460+
// phpcs:set Generic.WhiteSpace.ScopeIndent exact true
1461+
echo $string?->append('foo')
1462+
?->outputUsing();
1463+
// phpcs:set Generic.WhiteSpace.ScopeIndent exact false
1464+
1465+
/* ADD NEW TESTS ABOVE THIS LINE AND MAKE SURE THAT THE 1 (space-based) AND 2 (tab-based) FILES ARE IN SYNC! */
14571466
?>
14581467

14591468
<?php if (true) : ?>

src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,6 +1454,15 @@ return [
14541454
]),
14551455
];
14561456

1457+
echo $string?->append('foo')
1458+
?->outputUsing();
1459+
1460+
// phpcs:set Generic.WhiteSpace.ScopeIndent exact true
1461+
echo $string?->append('foo')
1462+
?->outputUsing();
1463+
// phpcs:set Generic.WhiteSpace.ScopeIndent exact false
1464+
1465+
/* ADD NEW TESTS ABOVE THIS LINE AND MAKE SURE THAT THE 1 (space-based) AND 2 (tab-based) FILES ARE IN SYNC! */
14571466
?>
14581467

14591468
<?php if (true) : ?>

src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc.fixed

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,6 +1454,15 @@ return [
14541454
]),
14551455
];
14561456

1457+
echo $string?->append('foo')
1458+
?->outputUsing();
1459+
1460+
// phpcs:set Generic.WhiteSpace.ScopeIndent exact true
1461+
echo $string?->append('foo')
1462+
?->outputUsing();
1463+
// phpcs:set Generic.WhiteSpace.ScopeIndent exact false
1464+
1465+
/* ADD NEW TESTS ABOVE THIS LINE AND MAKE SURE THAT THE 1 (space-based) AND 2 (tab-based) FILES ARE IN SYNC! */
14571466
?>
14581467

14591468
<?php if (true) : ?>

src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,10 @@ public function getErrorList($testFile='ScopeIndentUnitTest.inc')
178178
1340 => 1,
179179
1342 => 1,
180180
1345 => 1,
181-
1464 => 1,
182-
1465 => 1,
183-
1466 => 1,
184-
1467 => 1,
181+
1473 => 1,
182+
1474 => 1,
183+
1475 => 1,
184+
1476 => 1,
185185
];
186186

187187
}//end getErrorList()

0 commit comments

Comments
 (0)