$container->set('Doctrine\ORM\EntityManager', $entityManager);
This will cause a problem because when the container will "getDefinition", there will be 2 incompatible definitions:
Doctrine\ORM\EntityManager class using Reflection -> ClassDefinition
$entityManager instance -> ValueDefinition
The solution would be that when a ValueDefinition exists, all other definitions are ignored.