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

Bug: function into eval() is not used #8406

Closed
vjik opened this issue Aug 12, 2022 · 3 comments · Fixed by #9519
Closed

Bug: function into eval() is not used #8406

vjik opened this issue Aug 12, 2022 · 3 comments · Fixed by #9519

Comments

@vjik
Copy link
Contributor

vjik commented Aug 12, 2022

Example: https://psalm.dev/r/8e58844e60

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/8e58844e60
<?php

function go(string $code): void
{
  eval(str_replace('<?php', '', $code));
}
Psalm output (using commit f315647):

ERROR: UnusedFunctionCall - 5:8 - The call to str_replace is not used

@edsrzf
Copy link
Contributor

edsrzf commented Mar 15, 2023

I came across a similar-looking UnusedVariable false positive: https://psalm.dev/r/d1a6dffdd6

Note that the if statement is required. If the variable assignment and eval are placed at the top level or directly inside a function body, there is no UnusedVariable error.

@psalm-github-bot
Copy link

I found these snippets:

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

if (rand()) {
    $v = '';
    eval($v);
}
Psalm output (using commit 293b728):

INFO: UnusedVariable - 4:5 - $v is never referenced or the value is not used

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

Successfully merging a pull request may close this issue.

3 participants