| Conditions | 5 |
| Paths | 3 |
| Total Lines | 13 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 31 | public function create(PersistenceContext $context) |
||
| 32 | { |
||
| 33 | $objectManager = $this->managerRegistry->getManager((string) $context->getName()); |
||
| 34 | if (interface_exists('Doctrine\ORM\EntityManagerInterface') && is_a($objectManager, 'Doctrine\ORM\EntityManagerInterface')) { |
||
| 35 | return new Transaction\Doctrine\ORMTransaction($objectManager); |
||
|
|
|||
| 36 | } |
||
| 37 | |||
| 38 | if (class_exists('Doctrine\ODM\MongoDB\DocumentManager') && is_a($objectManager, 'Doctrine\ODM\MongoDB\DocumentManager')) { |
||
| 39 | return new Transaction\Doctrine\ODMTransaction($objectManager); |
||
| 40 | } |
||
| 41 | |||
| 42 | throw new UnsupportedManagerException(sprintf("Manager \"%s\" is not supported.", get_class($objectManager))); |
||
| 43 | } |
||
| 44 | } |
||
| 45 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.