Version: Intellij SonarLint v3.4.2.2586
Error: php:S1481 does not understand compact’s use of variable
Example: In this example, it will mark $label as an unused variable.
function get_choices(array $items): array
{
$choices = [];
foreach ($items as $label => $value) {
$choices[] = \compact('label', 'value');
}
return $choices;
}
Another Example: In this example it will mark $var as unused;
function example():array
{
$var = true;
return \compact('var');
}
To Resolve: Check for compact variable use.