Skip to content

Commit

Permalink
Fixed issue with arrow function type inference and TooWideArrowFuncti…
Browse files Browse the repository at this point in the history
…onReturnTypehintRule
  • Loading branch information
ondrejmirtes committed Mar 17, 2020
1 parent 1d0d3ad commit 5581928
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ public function processNode(Node $node, Scope $scope): array
return [];
}

$expr = $node->getOriginalNode()->expr;
$arrowFunction = $node->getOriginalNode();
if ($arrowFunction->returnType === null) {
return [];
}
$expr = $arrowFunction->expr;
if ($expr instanceof Node\Expr\YieldFrom || $expr instanceof Node\Expr\Yield_) {
return [];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,11 @@ public function doFoo(?string $nullableString)
fn (): ?string => $nullableString;
}

public function doBar()
{
/** @var string[][] $data */
$data = doFoo();
array_reduce($data, static fn (int $carry, array $item) => $carry + $item['total_count'], 0);
}

}

0 comments on commit 5581928

Please sign in to comment.