Question

I'm using phpStorm. And I have the following piece of code written by Kohana framework:

throw HTTP_Exception::factory(404,
    'The requested URL :uri was not found on this server.',
    array(':uri' => $this->request->uri())
)->request($this->request);

The problem is that phpStorm considers this piece of code invalid and displays the following message: the thrown object must be an instance of the exception. I don't like it because it shows the entire project up to first directory invalid.

Is there any way I can work around it without changing the code?

Was it helpful?

Solution 3

You cannot -- this error is produced by Annotator and not individual Inspection (individual inspection can be suppressed).

Accordingly to http://youtrack.jetbrains.com/issue/WI-14734 this is marked as "Won't fix". You can add your comments there or even submit new ticket if so desired.

OTHER TIPS

i meet the same error

your Exception class must extend from \Exception ; instead of extend from Exception ;

Seems like PhpStorm gets "stuck" thinking the project is a PHP7 project, even if you change the PHP version in Settings. I solved this by removing the .idea directory altogether, and reopening the directory as a fresh project.

I faced the same issue when having worked on a PHP 7 project and then switched back to a PHP 5.6 project. In "project settings -> Languages & Frameworks -> PHP -> PHP language level" I switched from PHP 5.6 to PHP 5.5 and the error message disappeared. I then switched back to PHP 5.6 and it didn't popup again.

In my case (i'm development on laravel framework) you should add slash before extends class Exception or Throwable. It is works for me. See code bellow

class ProcessIncomplete extends \Exception {}

By the way, I'm also using PHPStorm ide

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top