You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Incorrect type inferred from array destructuring #7155
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 ($eventinstanceof \Closure) {
[$event, $callback] = ['event-name', $event];
}
// $callback should be Closure|null, but is reported as 'event-name'|null
Activity
ondrejmirtes commentedon Apr 29, 2022
Root cause: https://phpstan.org/r/d12b75ee-fa29-4c38-8177-b7159d2665e2
Array destructuring is confused when overwriting an existing variable.
Add regression tests for evaluation-point array item types
Add regression tests for evaluation-point array item types
Add regression tests for evaluation-point array item types
Add regression tests for evaluation-point array item types
Add regression tests for evaluation-point array item types
Add regression tests for evaluation-point array item types
Add regression tests for evaluation-point array item types
Add regression tests for evaluation-point array item types
Add regression tests for evaluation-point array item types
Add regression tests for evaluation-point array item types
Add regression tests for evaluation-point array item types
Add regression tests for evaluation-point array item types
13 remaining items
Add regression tests for evaluation-point array item types
Add regression tests for evaluation-point array item types
Add regression tests for evaluation-point array item types
Add regression tests for evaluation-point array item types
Add regression tests for evaluation-point array item types
Add regression tests for evaluation-point array item types
Add regression tests for evaluation-point array item types
Add regression tests for evaluation-point array item types
Add regression tests for evaluation-point array item types
Add regression tests for evaluation-point array item types
Add regression tests for evaluation-point array item types
Add regression tests for evaluation-point array item types
github-actions commentedon Oct 4, 2026
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.