Skip to content

Commit

Permalink
Merge e2abe1c into bdf1e50
Browse files Browse the repository at this point in the history
  • Loading branch information
sirbrillig committed Mar 31, 2023
2 parents bdf1e50 + e2abe1c commit edd6cb7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
15 changes: 15 additions & 0 deletions Tests/VariableAnalysisSniff/fixtures/ArrowFunctionFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,18 @@ function arrowFunctionWithReturnType() {
$type = do_something(fn(string $func): string => $func ? $func : '');
echo $type;
}

function arrowFunctionWithNewlines( $items ): array {
return $items
->map(
fn ( array $item ) => apply_overrides(
[
'a' => ! empty( $item['b'] ),
],
$item, // throws an undefined variable error
)
)
->filter( fn ( array $item ) => ! empty( $item['post'] ) )
->values()
->all();
}
5 changes: 0 additions & 5 deletions VariableAnalysis/Lib/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -665,11 +665,6 @@ public static function getArrowFunctionOpenClose(File $phpcsFile, $stackPtr)
break;
}

// A line break is always a closer.
if ($token['line'] !== $tokens[$stackPtr]['line']) {
$scopeCloserIndex = $index;
break;
}
$code = $token['code'];

// A semicolon is always a closer.
Expand Down

0 comments on commit edd6cb7

Please sign in to comment.