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 positive for UnusedVariable #2541

Closed
kubawerlos opened this issue Jan 2, 2020 · 2 comments
Closed

False positive for UnusedVariable #2541

kubawerlos opened this issue Jan 2, 2020 · 2 comments
Labels

Comments

@kubawerlos
Copy link
Contributor

kubawerlos commented Jan 2, 2020

For this snippet of code:

        foreach ($variables as $name => $value) {
            ${$name} = $value;
        }

https://psalm.dev/r/9343894642
I'm getting the error:

UnusedVariable - Variable $name is never referenced foreach ($variables as $name => $value) {

Through I'm not sure this is worth the effort for fixing - the assignment is clearly violating all good practices - I'm fine with this getting "won't fix" status - I simply wanted to report this to have clear conscience 😉

@psalm-github-bot
Copy link

psalm-github-bot bot commented Jan 2, 2020

I found these snippets:

https://psalm.dev/r/9343894642
<?php

$variables = ['a' => 'b', 'c' => 'b'];
  
foreach ($variables as $name => $value) {
    ${$name} = $value;
}
Psalm output (using commit 25e7039):

INFO: UnusedVariable - 5:24 - Variable $name is never referenced

@muglug muglug added the bug label Jan 2, 2020
@muglug muglug closed this as completed in de0fad2 Jan 2, 2020
@kubawerlos
Copy link
Contributor Author

Thank you @muglug.

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

No branches or pull requests

2 participants