-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Labels
Milestone
Description
Bug report
Arrow functions brings a few advantages beside implicit returns, one of them is to share scope so there is no need to use ($a, $b).
Code snippet that reproduces the problem
https://phpstan.org/r/44c31a2f-c40e-4b88-a295-08c593d44c62
class SideApiThingNotImportantToTheMainLogic
{
private HttpClient $client;
public function makeAmericaGreatAgain(): void
{
$this->safeCall(
fn() => $this->client->call('make-america-great-again'),
);
}
public function yesWeCan(): void
{
$this->safeCall(
fn() => $this->client->call('yes-we-can'),
);
}
private function safeCall(callable $fn): void
{
try {
$fn();
} catch (Exception $e) {
// do nothing because we do not want to interrupt our main logic thing
}
}
}Expected output
function with return type void can return void
Reactions are currently unavailable