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

False negative PossiblyUndefined[Global]Variable #7704

Open
AndrolGenhald opened this issue Feb 20, 2022 · 1 comment
Open

False negative PossiblyUndefined[Global]Variable #7704

AndrolGenhald opened this issue Feb 20, 2022 · 1 comment

Comments

@AndrolGenhald
Copy link
Collaborator

AndrolGenhald commented Feb 20, 2022

This correctly shows PossiblyUndefinedGlobalVariable, but this does not.

@psalm-github-bot
Copy link

psalm-github-bot bot commented Feb 20, 2022

I found these snippets:

https://psalm.dev/r/41e5e0ceb3
<?php

if (random_int(0, 1)) {
    $foo = 1;
}

$bar = $foo;
Psalm output (using commit d7d846e):

INFO: PossiblyUndefinedGlobalVariable - 7:8 - Possibly undefined global variable $foo, first seen on line 4

INFO: MixedAssignment - 7:1 - Unable to determine the type that $bar is being assigned to
https://psalm.dev/r/592bb868ac
<?php

if (random_int(0, 1)) {
    $foo = 1;
}

if (!isset($foo)) {
}

$bar = $foo;
Psalm output (using commit d7d846e):

INFO: MixedAssignment - 10:1 - Unable to determine the type that $bar is being assigned to

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

No branches or pull requests

3 participants