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

Doc-block suppress for UnusedForeachValue #6234

Closed
michalbundyra opened this issue Aug 3, 2021 · 2 comments · Fixed by #6238
Closed

Doc-block suppress for UnusedForeachValue #6234

michalbundyra opened this issue Aug 3, 2021 · 2 comments · Fixed by #6238
Labels

Comments

@michalbundyra
Copy link

https://psalm.dev/r/ce2467c803

<?php

/** @var array<string, int> */
$data = [];

/** @psalm-suppress UnusedForeachValue */
foreach ($data as $k => $v) {
    echo $k;
}

I would expect that error on unused foreach value is suppressed, but getting the following:

Psalm output (using commit 9d68e2e): 

INFO: UnusedForeachValue - 7:25 - $v is never referenced or the value is not used
 
Psalm detected 1 fixable issue(s)

also it's marked as fixable, but fixing is not working as well.

@psalm-github-bot
Copy link

I found these snippets:

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

/** @var array<string, int> */
$data = [];

/** @psalm-suppress UnusedForeachValue */
foreach ($data as $k => $v) {
    echo $k;
}
Psalm output (using commit 9d68e2e):

INFO: UnusedForeachValue - 7:25 - $v is never referenced or the value is not used

@orklah
Copy link
Collaborator

orklah commented Aug 3, 2021

The fixable flag should be fixed by #6238. The fact that UnusedVariable issues can't be suppressed is by design. It was already suggested as a change in #5537 so this issue can be closed when #6238 is merged

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

Successfully merging a pull request may close this issue.

3 participants