Skip to content

Commit fbf67ef

Browse files
committed
Fixed bug #2849 : Generic.WhiteSpace.ScopeIndent false positive with arrow function inside array
1 parent 1cfba97 commit fbf67ef

File tree

7 files changed

+42
-4
lines changed

7 files changed

+42
-4
lines changed

package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
2727
<license uri="https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt">BSD 3-Clause License</license>
2828
<notes>
2929
- Fixed bug #2848 : PSR12.Files.FileHeader false positive for file with mixed PHP and HTML and no file header
30+
- Fixed bug #2849 : Generic.WhiteSpace.ScopeIndent false positive with arrow function inside array
3031
</notes>
3132
<contents>
3233
<dir name="/">

src/Files/File.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2277,6 +2277,7 @@ public function findStartOfStatement($start, $ignore=null)
22772277

22782278
if (isset($this->tokens[$i]['scope_opener']) === true
22792279
&& $i === $this->tokens[$i]['scope_closer']
2280+
&& $this->tokens[$i]['code'] !== T_CLOSE_PARENTHESIS
22802281
) {
22812282
// Found the end of the previous scope block.
22822283
return $lastNotEmpty;

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,6 +1445,15 @@ $a = $a === true ? [
14451445
'a' => 100,
14461446
];
14471447

1448+
return [
1449+
Url::make('View Song', fn($song) => $song->url())
1450+
->onlyOnDetail(),
1451+
1452+
new Panel('Information', [
1453+
Text::make('Title')
1454+
]),
1455+
];
1456+
14481457
?>
14491458

14501459
<?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
@@ -1445,6 +1445,15 @@ $a = $a === true ? [
14451445
'a' => 100,
14461446
];
14471447

1448+
return [
1449+
Url::make('View Song', fn($song) => $song->url())
1450+
->onlyOnDetail(),
1451+
1452+
new Panel('Information', [
1453+
Text::make('Title')
1454+
]),
1455+
];
1456+
14481457
?>
14491458

14501459
<?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
@@ -1445,6 +1445,15 @@ $a = $a === true ? [
14451445
'a' => 100,
14461446
];
14471447

1448+
return [
1449+
Url::make('View Song', fn($song) => $song->url())
1450+
->onlyOnDetail(),
1451+
1452+
new Panel('Information', [
1453+
Text::make('Title')
1454+
]),
1455+
];
1456+
14481457
?>
14491458

14501459
<?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
@@ -1445,6 +1445,15 @@ $a = $a === true ? [
14451445
'a' => 100,
14461446
];
14471447

1448+
return [
1449+
Url::make('View Song', fn($song) => $song->url())
1450+
->onlyOnDetail(),
1451+
1452+
new Panel('Information', [
1453+
Text::make('Title')
1454+
]),
1455+
];
1456+
14481457
?>
14491458

14501459
<?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-
1455 => 1,
182-
1456 => 1,
183-
1457 => 1,
184-
1458 => 1,
181+
1464 => 1,
182+
1465 => 1,
183+
1466 => 1,
184+
1467 => 1,
185185
];
186186

187187
}//end getErrorList()

0 commit comments

Comments
 (0)