Skip to content

Commit

Permalink
Arrow functions are not considered scope openers (ref #2523)
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Nov 7, 2019
1 parent ae3ffc7 commit 24b898c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@ public function process(File $phpcsFile, $stackPtr)
if ($this->debug === true) {
$type = str_replace('_', ' ', strtolower(substr($tokens[$i]['type'], 2)));
$line = $tokens[$i]['line'];
echo "* ignoring single-line $type on line $line".PHP_EOL;
echo "* ignoring single-line $type on line $line *".PHP_EOL;
}

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

$i = $closer;
continue;
}

$condition = $tokens[$tokens[$i]['scope_condition']]['code'];
if ($condition === T_FN) {
if ($this->debug === true) {
$line = $tokens[$tokens[$i]['scope_condition']]['line'];
echo "* ignoring arrow function on line $line *".PHP_EOL;
}

$i = $closer;
continue;
}

if (isset(Tokens::$scopeOpeners[$condition]) === true
&& in_array($condition, $this->nonIndentingScopes, true) === false
) {
Expand Down Expand Up @@ -1239,7 +1249,7 @@ public function process(File $phpcsFile, $stackPtr)
if ($tokens[$i]['line'] === $tokens[$closer]['line']) {
if ($this->debug === true) {
$line = $tokens[$i]['line'];
echo "* ignoring single-line JS object on line $line".PHP_EOL;
echo "* ignoring single-line JS object on line $line *".PHP_EOL;
}

$i = $closer;
Expand Down

0 comments on commit 24b898c

Please sign in to comment.