Skip to content

Commit 24b898c

Browse files
committed
Arrow functions are not considered scope openers (ref #2523)
1 parent ae3ffc7 commit 24b898c

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,7 @@ public function process(File $phpcsFile, $stackPtr)
11221122
if ($this->debug === true) {
11231123
$type = str_replace('_', ' ', strtolower(substr($tokens[$i]['type'], 2)));
11241124
$line = $tokens[$i]['line'];
1125-
echo "* ignoring single-line $type on line $line".PHP_EOL;
1125+
echo "* ignoring single-line $type on line $line *".PHP_EOL;
11261126
}
11271127

11281128
$i = $closer;
@@ -1192,14 +1192,24 @@ public function process(File $phpcsFile, $stackPtr)
11921192
if ($this->debug === true) {
11931193
$line = $tokens[$i]['line'];
11941194
$type = $tokens[$i]['type'];
1195-
echo "* ignoring single-line $type on line $line".PHP_EOL;
1195+
echo "* ignoring single-line $type on line $line *".PHP_EOL;
11961196
}
11971197

11981198
$i = $closer;
11991199
continue;
12001200
}
12011201

12021202
$condition = $tokens[$tokens[$i]['scope_condition']]['code'];
1203+
if ($condition === T_FN) {
1204+
if ($this->debug === true) {
1205+
$line = $tokens[$tokens[$i]['scope_condition']]['line'];
1206+
echo "* ignoring arrow function on line $line *".PHP_EOL;
1207+
}
1208+
1209+
$i = $closer;
1210+
continue;
1211+
}
1212+
12031213
if (isset(Tokens::$scopeOpeners[$condition]) === true
12041214
&& in_array($condition, $this->nonIndentingScopes, true) === false
12051215
) {
@@ -1239,7 +1249,7 @@ public function process(File $phpcsFile, $stackPtr)
12391249
if ($tokens[$i]['line'] === $tokens[$closer]['line']) {
12401250
if ($this->debug === true) {
12411251
$line = $tokens[$i]['line'];
1242-
echo "* ignoring single-line JS object on line $line".PHP_EOL;
1252+
echo "* ignoring single-line JS object on line $line *".PHP_EOL;
12431253
}
12441254

12451255
$i = $closer;

0 commit comments

Comments
 (0)