在 vscode 中突出显示未使用的变量

GHo*_*per 9 php visual-studio-code

有什么方法可以突出显示 vscode 中未使用的 php 变量吗?

<?php
$foo = 'a';
$bar = 'b'; // I want the IDE mark this somehow

$foo = 'c';
?>
Run Code Online (Sandbox Code Playgroud)

"editor.showUnused": true在配置文件里有。另外,我尝试了几个intellisense扩展,但没有帮助。

Kir*_*hxh 7

至少有两种可能性:

  • 使用 PHP 混乱检测器 (phpmd),VsCode 有一个扩展:ecodes.vscode-phpmd。
    它将输出有关未使用变量的警告,在滚动条中添加指示器并用蓝色下划线/变量。您可以删除配置中的所有规则并仅保留unusedcode

  • 使用 Intelephense 扩展:bmewburn.vscode-intelephense-client。
    未使用的变量将以灰色显示