Closed
Description
DrupalPractice.CodeAnalysis.VariableAnalysis.UnusedVariable gives a false positive for the $uri variable in the following example:
\Drupal::httpClient()->get($input, [
'on_stats' => function (TransferStats $stats) use (&$uri) {
$uri = $stats->getEffectiveUri();
},
]);
Another false positive occurs for the following code snippet which modifies an array by reference:
80 | WARNING | Unused variable $entry.
| | (DrupalPractice.CodeAnalysis.VariableAnalysis.UnusedVariable)
foreach ($derivatives as &$entry) {
$entry += $base_plugin_definition;
}
The sniff doesn't detect that the $uri variable is actually in use since it is passed by reference to the anonymous function.
Originally posted in https://www.drupal.org/project/coder/issues/3065679.
Metadata
Metadata
Assignees
Labels
No labels