Search code examples
phpphpstormhttpexception

PhpStorm autocompletes with classes that do not actually exist


I use PhpStorm 9.0.1. When I write to throw a new Exception PhpStorm is showing for Exceptions the HttpException class. So I can autocomplete my code and have the following line:

throw new HttpException($message);

But when I execute the code it shows an error message that HttpException class is not found. Does anyone know why the HttpException class is not found or how can I set the PhpStorm to show on autocomplete only the classes that do exist?

By the way if I ctrl+click above the HttpException PhpStorms opens a file with path

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

Solution

  • Does anyone know why the HttpException class is not found

    That exception is part of HTTP extension which is not part of default PHP installation -- you will have to download/install it separately.

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

    Well .. that extension does exist if PHP's HTTP extension is enabled.

    In code completion IDE will offer all classes that it knows about (especially if such classes are part of bundled stubs). ATM you cannot say "I do not want to see stuff from that stub file" for bundled stuff. You will have to filter out such entries yourself.