"Unhandled Exception" on new \DateTime() ?

Inspection in version 2018.3 now warns about unhandled exceptions on the default DateTime constructor with no arguments.

Is this really necessary?

What would be the best way to make PhpStorm happy? Add an empty try-catch? I don't really want to add @throws tags to my functions when I know they won't throw anything 😕

Edit: found the right noinspection tag, but it still asks for a throw tag.

3 comments

In fact, there is a similar thread on YouTrack exists already:

https://youtrack.jetbrains.com/issue/WI-40739

 

Please feel free to vote for it and join the discussion.

0

Oh, thank you! Guess I didn't search in the right place.

0

Toulousevictor you can circumvent the issue by cloning default PhpStorm stubs, changing their DateTime declaration to not throw Exception and providing a default stub location for your project.

This way you can maintain other Exceptions and keep your sanity :)

1

Please sign in to leave a comment.