Bug report
I'm sorry for the lack of a more specific title. I don't know how else to describe this issue.
PHPStan is unable to correctly infer the type from the following array destructure:
/** @var \Closure|string $event */
$event = '';
$callback = null;
if ($event instanceof \Closure) {
[$event, $callback] = ['event-name', $event];
}
// $callback should be Closure|null, but is reported as 'event-name'|null
This example is based on this real-world code.
Code snippet that reproduces the problem
https://phpstan.org/r/f75d63a2-9a54-46ee-8f89-ecf6de70c5a9
Expected output
PHPStan should infer $callback as \Closure|null.
Bug report
I'm sorry for the lack of a more specific title. I don't know how else to describe this issue.
PHPStan is unable to correctly infer the type from the following array destructure:
This example is based on this real-world code.
Code snippet that reproduces the problem
https://phpstan.org/r/f75d63a2-9a54-46ee-8f89-ecf6de70c5a9
Expected output
PHPStan should infer
$callbackas\Closure|null.