-
Notifications
You must be signed in to change notification settings - Fork 653
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
Cannot inline suppress UnusedVariable #5537
Comments
I found these snippets: https://psalm.dev/r/25a700869d<?php
/**
* @psalm-suppress UnusedVariable
*/
$a = 1;
|
This comes up often enough, could we just support it? Or offer a clear rationale as to why it's not supported in the documentation? |
Oops. I know I searched for this before posting here, I guess I accidentally only searched open issues. In the code I work on, I actually did go through and change all truly unused variables that we needed to keep around to |
I am seriously asking you to support psalm-suppress for this. Expecting us to change our variable names is poor form. Often, coding standards prevent that. In addition I have open issues right now where it's a false positive. Being able to suppress it until the issues are fixed would make my life a LOT easier. |
Sometimes a variable is actually used, but a bug in Psalm (e.g. #5700) causes an |
<?php
$viewName = 'logs';
require __DIR__ . '/view.php'; My example code. I can't suppress the problem. It would be correct to ignore unused variables when including external scripts. And it would be even better to tell psalm which variables we plan to transfer to the internal code of the included script. |
I have a similar problem. |
I found these snippets: https://psalm.dev/r/869a33ad17<?php
/** @param array<int> $values */
function f(array $values): void {
$mysqli = new mysqli();
$stmt = $mysqli->prepare('SELECT ?');
$stmt->bind_param('i', $value);
/** @psalm-suppress UnusedForeachValue */
foreach ($values as $value) {
$stmt->execute();
}
}
|
https://psalm.dev/r/25a700869d
The text was updated successfully, but these errors were encountered: