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
Union of optional keyed arrays doesn't mean both keys exists at same time #7143
I'm investigating #4809 #6508 #7000
and splitting them into smaller related issues.
If I union two optional keyed constant arrays array{foo?: string, bar: string}|array{foo: string, bar?: string} PHPStan generalize it as array{foo?: string, bar?: string}&non-empty-array (which I think is a correct and smart behavior) but this make it not report an error on offset access on both optional keys.
Activity
phpstan-bot commentedon Oct 13, 2024
@rajyan After the latest push in 2.0.x, PHPStan now reports different result with your code snippet:
Full report
Expected type array{foo?: string, bar?: string}&non-empty-array, actual: non-empty-array{foo?: string, bar?: string}phpstan-bot commentedon Feb 26, 2026
Closed via merging phpstan/phpstan-src#4399
github-actions commentedon Mar 30, 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.