PhpStorm 自动完成 类 实际上并不存在

PhpStorm autocompletes with classes that do not actually exist

我使用 PhpStorm 9.0.1。当我写信抛出一个新的异常时,PhpStorm 显示 HttpException class 异常。所以我可以自动完成我的代码并有以下行:

throw new HttpException($message);

但是当我执行代码时,它显示一条错误消息,指出 HttpException class 未找到。有谁知道为什么找不到 HttpException class 或者我如何设置 PhpStorm 以仅在自动完成时显示确实存在的 classes?

顺便说一句,如果我 ctrl+clickHttpException PhpStorms 上面打开一个路径为

的文件
PhpStorm/plugins/php/lib/php.jar!/com/jetbrains/php/lang/psi/stubs/data/http.php

Does anyone know why the HttpException class is not found

该异常是 HTTP extension 的一部分,它不是默认 PHP 安装的一部分——您必须单独 download/install 它。

...how can I set the PhpStorm to show on autocomplete only the classes that do exist?

嗯 .. 如果启用 PHP 的 HTTP 扩展,那么该扩展确实存在。

在代码完成中 IDE 将提供它知道的 all 类(特别是如果 类 是捆绑存根的一部分) . ATM 你不能说 "I do not want to see stuff from that stub file" 捆绑的东西。您必须自己过滤掉此类条目。