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

Report impossible @var #11188

Open
kkmuffme opened this issue Dec 21, 2024 · 2 comments
Open

Report impossible @var #11188

kkmuffme opened this issue Dec 21, 2024 · 2 comments

Comments

@kkmuffme
Copy link
Contributor

https://psalm.dev/r/eb9afcdaf4

I've inherited a code base where people sometimes used impossibly @var annotations.

I guess if the @var and the actual type do not have any overlap, psalm could report an error.
Input welcome which cases would make sense/are possible without causing false positives

Copy link

I found these snippets:

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

/**
 * @var int[]
 */
$x = explode(',', '1,2');
/** @psalm-trace $x */;
Psalm output (using commit 765dcbf):

INFO: Trace - 7:23 - $x: array<array-key, int>

INFO: UnusedVariable - 6:1 - $x is never referenced or the value is not used

@ondrejmirtes
Copy link

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

2 participants