-
-
Notifications
You must be signed in to change notification settings - Fork 74
Description
When looking at the ObjectManager interface
https://github.com/doctrine/persistence/blob/3.2.x/src/Persistence/ObjectManager.php
there si none @throws annotation for each methods.
When looking at the ORM implementation
https://github.com/doctrine/orm/blob/2.16.x/lib/Doctrine/ORM/EntityManager.php
or the ODM implementation
https://github.com/doctrine/mongodb-odm/blob/2.6.x/lib/Doctrine/ODM/MongoDB/DocumentManager.php
a lot of exception are thrown in those methods.
The interface contract should be about the @param, @return but also @throws.
If I write
public function foo(ObjectManager $om) {
$om->flush();
}
I have no help from PHPStorm or PHPStan that an exception can be thrown and that I should try/catch the call sometimes.
When I write
public function foo(EntityManager $om) {
$om->flush();
}
PHPStan analysis help me to handle correctly exceptions (see https://phpstan.org/blog/bring-your-exceptions-under-control).
What could be great would be to
- have some
Doctrine\Persistence\Exceptionclass or interface - add
@throws Doctrine\Persistence\Exceptionto methods which can throws exception - extends/implements this exception in the ORM/ODM repository for exception thrown in the ObjectManager methods