Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Isset check is breaking the array-shape definition #9500

Open
VincentLanglet opened this issue Mar 12, 2023 · 1 comment
Open

Isset check is breaking the array-shape definition #9500

VincentLanglet opened this issue Mar 12, 2023 · 1 comment

Comments

@VincentLanglet
Copy link
Contributor

https://psalm.dev/r/18d1dfabd5

After the isset check, every values are considered as mixed by psalm.

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/18d1dfabd5
<?php

/**
 * @param array{
 *     label?: string|false|null,
 *     type?: string,
 * }&array<string, mixed> $i
 */
function foo(array $i) {
    /** @psalm-trace $a */
    $a = $i;
    
    if (isset($i['type'])) {
    }
        
    /** @psalm-trace $a */
    $a = $i;
}
Psalm output (using commit 902a019):

INFO: Trace - 11:5 - $a: array{label?: false|null|string, type?: string, ...<string, mixed>}

INFO: Trace - 17:5 - $a: array{label?: false|mixed|null|string, type?: mixed|string, ...<string, mixed>}

INFO: UnusedVariable - 11:5 - $a is never referenced or the value is not used

INFO: UnusedVariable - 17:5 - $a is never referenced or the value is not used

INFO: MissingReturnType - 9:10 - Method foo does not have a return type, expecting void

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant