"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.


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



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


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


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 :)


Please sign in to leave a comment.