有时,当我更改 PHP 项目中的代码时,Intellisense 无法检测到该更改。因此,如果我更改函数的参数计数。对该函数的引用代码不会出错,当我更改引用代码参数计数时,它会给出代码错误。因此 Intellisense 认为应该使用之前的参数计数。我重新启动了 VSCode,但这没有什么区别。
似乎 Intellisense 缓存了它的数据,并且更新得不太好。
示例:
$instance= new SomeClass();
$result = $instance->some_function($variable1, $variable2);
class SomeClass {
public function some_function($variable1, $variable2)
{
...
}
然后我将其更改为:
$instance= new SomeClass();
$result = $instance->some_function($variable1);
class SomeClass {
public function some_function($variable1)
{
...
}
保存两个文件后,Intellisense 给出错误:
{
...
"message": "Expected 2 arguments. Found 1.",
"source": "intelephense",
...
}
最佳答案
似乎不再是问题。启用扩展 Intelephense
并在编辑器中打开 PHP
文件后,您可以运行命令 Intelephense:索引工作区
,该命令将重建索引。
关于php - VSCode PHP 智能感知数据缓存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58006335/