From 6fc0d84b7a92ce586c310e07dfdfbf2bd4a1da48 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 5 Dec 2014 14:02:47 +0100 Subject: [PATCH 1/4] DDC-3427 - s/EntityManager/EntityManagerInterface in type-hints --- lib/Doctrine/ORM/AbstractQuery.php | 6 +-- lib/Doctrine/ORM/Event/ListenersInvoker.php | 8 ++-- lib/Doctrine/ORM/Event/OnClearEventArgs.php | 10 ++--- lib/Doctrine/ORM/Event/OnFlushEventArgs.php | 8 ++-- lib/Doctrine/ORM/Event/PostFlushEventArgs.php | 6 +-- lib/Doctrine/ORM/Event/PreFlushEventArgs.php | 6 +-- lib/Doctrine/ORM/Id/AbstractIdGenerator.php | 6 +-- lib/Doctrine/ORM/Id/AssignedGenerator.php | 11 ++--- .../ORM/Id/BigIntegerIdentityGenerator.php | 10 ++--- lib/Doctrine/ORM/Id/IdentityGenerator.php | 6 +-- lib/Doctrine/ORM/Id/SequenceGenerator.php | 13 ++---- lib/Doctrine/ORM/Id/TableGenerator.php | 6 +-- lib/Doctrine/ORM/Id/UuidGenerator.php | 13 ++---- .../Internal/Hydration/AbstractHydrator.php | 10 ++--- lib/Doctrine/ORM/PersistentCollection.php | 10 ++--- .../Entity/BasicEntityPersister.php | 40 +++++++++---------- lib/Doctrine/ORM/Proxy/ProxyFactory.php | 20 +++++----- lib/Doctrine/ORM/Query/Filter/SQLFilter.php | 8 ++-- lib/Doctrine/ORM/Query/FilterCollection.php | 6 +-- .../ORM/Query/ResultSetMappingBuilder.php | 10 ++--- lib/Doctrine/ORM/QueryBuilder.php | 6 +-- .../ORM/Tools/DebugUnitOfWorkListener.php | 6 +-- lib/Doctrine/ORM/UnitOfWork.php | 6 +-- 23 files changed, 105 insertions(+), 126 deletions(-) diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index 522788e72..8108d558b 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -87,7 +87,7 @@ abstract class AbstractQuery /** * The entity manager used by this query object. * - * @var \Doctrine\ORM\EntityManager + * @var EntityManagerInterface */ protected $_em; @@ -161,9 +161,9 @@ abstract class AbstractQuery /** * Initializes a new instance of a class derived from AbstractQuery. * - * @param \Doctrine\ORM\EntityManager $em + * @param \Doctrine\ORM\EntityManagerInterface $em */ - public function __construct(EntityManager $em) + public function __construct(EntityManagerInterface $em) { $this->_em = $em; $this->parameters = new ArrayCollection(); diff --git a/lib/Doctrine/ORM/Event/ListenersInvoker.php b/lib/Doctrine/ORM/Event/ListenersInvoker.php index 125855bef..bbcbd4118 100644 --- a/lib/Doctrine/ORM/Event/ListenersInvoker.php +++ b/lib/Doctrine/ORM/Event/ListenersInvoker.php @@ -19,9 +19,9 @@ namespace Doctrine\ORM\Event; -use Doctrine\ORM\Mapping\ClassMetadata; -use Doctrine\ORM\EntityManager; use Doctrine\Common\EventArgs; +use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Mapping\ClassMetadata; /** * A method invoker based on entity lifecycle. @@ -51,9 +51,9 @@ class ListenersInvoker /** * Initializes a new ListenersInvoker instance. * - * @param \Doctrine\ORM\EntityManager $em + * @param EntityManagerInterface $em */ - public function __construct(EntityManager $em) + public function __construct(EntityManagerInterface $em) { $this->eventManager = $em->getEventManager(); $this->resolver = $em->getConfiguration()->getEntityListenerResolver(); diff --git a/lib/Doctrine/ORM/Event/OnClearEventArgs.php b/lib/Doctrine/ORM/Event/OnClearEventArgs.php index f37120573..dd827c725 100644 --- a/lib/Doctrine/ORM/Event/OnClearEventArgs.php +++ b/lib/Doctrine/ORM/Event/OnClearEventArgs.php @@ -19,7 +19,7 @@ namespace Doctrine\ORM\Event; -use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManagerInterface; /** * Provides event arguments for the onClear event. @@ -33,7 +33,7 @@ use Doctrine\ORM\EntityManager; class OnClearEventArgs extends \Doctrine\Common\EventArgs { /** - * @var \Doctrine\ORM\EntityManager + * @var EntityManagerInterface */ private $em; @@ -45,10 +45,10 @@ class OnClearEventArgs extends \Doctrine\Common\EventArgs /** * Constructor. * - * @param \Doctrine\ORM\EntityManager $em - * @param string|null $entityClass Optional entity class. + * @param EntityManagerInterface $em + * @param string|null $entityClass Optional entity class. */ - public function __construct(EntityManager $em, $entityClass = null) + public function __construct(EntityManagerInterface $em, $entityClass = null) { $this->em = $em; $this->entityClass = $entityClass; diff --git a/lib/Doctrine/ORM/Event/OnFlushEventArgs.php b/lib/Doctrine/ORM/Event/OnFlushEventArgs.php index c4f82a971..6a9c7c7f4 100644 --- a/lib/Doctrine/ORM/Event/OnFlushEventArgs.php +++ b/lib/Doctrine/ORM/Event/OnFlushEventArgs.php @@ -20,7 +20,7 @@ namespace Doctrine\ORM\Event; use Doctrine\Common\EventArgs; -use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManagerInterface; /** * Provides event arguments for the preFlush event. @@ -34,16 +34,16 @@ use Doctrine\ORM\EntityManager; class OnFlushEventArgs extends EventArgs { /** - * @var \Doctrine\ORM\EntityManager + * @var EntityManagerInterface */ private $em; /** * Constructor. * - * @param \Doctrine\ORM\EntityManager $em + * @param EntityManagerInterface $em */ - public function __construct(EntityManager $em) + public function __construct(EntityManagerInterface $em) { $this->em = $em; } diff --git a/lib/Doctrine/ORM/Event/PostFlushEventArgs.php b/lib/Doctrine/ORM/Event/PostFlushEventArgs.php index f860b7fa9..860f2d33b 100644 --- a/lib/Doctrine/ORM/Event/PostFlushEventArgs.php +++ b/lib/Doctrine/ORM/Event/PostFlushEventArgs.php @@ -18,8 +18,8 @@ */ namespace Doctrine\ORM\Event; -use Doctrine\ORM\EntityManager; use Doctrine\Common\EventArgs; +use Doctrine\ORM\EntityManagerInterface; /** * Provides event arguments for the postFlush event. @@ -39,9 +39,9 @@ class PostFlushEventArgs extends EventArgs /** * Constructor. * - * @param \Doctrine\ORM\EntityManager $em + * @param EntityManagerInterface $em */ - public function __construct(EntityManager $em) + public function __construct(EntityManagerInterface $em) { $this->em = $em; } diff --git a/lib/Doctrine/ORM/Event/PreFlushEventArgs.php b/lib/Doctrine/ORM/Event/PreFlushEventArgs.php index 4f49162b8..d01a92639 100644 --- a/lib/Doctrine/ORM/Event/PreFlushEventArgs.php +++ b/lib/Doctrine/ORM/Event/PreFlushEventArgs.php @@ -20,7 +20,7 @@ namespace Doctrine\ORM\Event; use Doctrine\Common\EventArgs; -use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManagerInterface; /** * Provides event arguments for the preFlush event. @@ -41,9 +41,9 @@ class PreFlushEventArgs extends EventArgs /** * Constructor. * - * @param \Doctrine\ORM\EntityManager $em + * @param EntityManagerInterface $em */ - public function __construct(EntityManager $em) + public function __construct(EntityManagerInterface $em) { $this->em = $em; } diff --git a/lib/Doctrine/ORM/Id/AbstractIdGenerator.php b/lib/Doctrine/ORM/Id/AbstractIdGenerator.php index b4161b29e..1077e9c3b 100644 --- a/lib/Doctrine/ORM/Id/AbstractIdGenerator.php +++ b/lib/Doctrine/ORM/Id/AbstractIdGenerator.php @@ -19,19 +19,19 @@ namespace Doctrine\ORM\Id; -use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManagerInterface; abstract class AbstractIdGenerator { /** * Generates an identifier for an entity. * - * @param \Doctrine\ORM\EntityManager $em + * @param EntityManagerInterface $em * @param \Doctrine\ORM\Mapping\Entity $entity * * @return mixed */ - abstract public function generate(EntityManager $em, $entity); + abstract public function generate(EntityManagerInterface $em, $entity); /** * Gets whether this generator is a post-insert generator which means that diff --git a/lib/Doctrine/ORM/Id/AssignedGenerator.php b/lib/Doctrine/ORM/Id/AssignedGenerator.php index 4e3321593..b2c2333e1 100644 --- a/lib/Doctrine/ORM/Id/AssignedGenerator.php +++ b/lib/Doctrine/ORM/Id/AssignedGenerator.php @@ -19,7 +19,7 @@ namespace Doctrine\ORM\Id; -use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\ORMException; /** @@ -36,16 +36,11 @@ class AssignedGenerator extends AbstractIdGenerator /** * Returns the identifier assigned to the given entity. * - * @param EntityManager $em - * @param object $entity - * - * @return mixed + * {@inheritDoc} * * @throws \Doctrine\ORM\ORMException - * - * @override */ - public function generate(EntityManager $em, $entity) + public function generate(EntityManagerInterface $em, $entity) { $class = $em->getClassMetadata(get_class($entity)); $idFields = $class->getIdentifierFieldNames(); diff --git a/lib/Doctrine/ORM/Id/BigIntegerIdentityGenerator.php b/lib/Doctrine/ORM/Id/BigIntegerIdentityGenerator.php index 1b4ed9a06..0a5c0273d 100644 --- a/lib/Doctrine/ORM/Id/BigIntegerIdentityGenerator.php +++ b/lib/Doctrine/ORM/Id/BigIntegerIdentityGenerator.php @@ -19,7 +19,7 @@ namespace Doctrine\ORM\Id; -use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManagerInterface; /** * Id generator that obtains IDs from special "identity" columns. These are columns @@ -48,15 +48,15 @@ class BigIntegerIdentityGenerator extends AbstractIdGenerator } /** - * {@inheritdoc} + * {@inheritDoc} */ - public function generate(EntityManager $em, $entity) + public function generate(EntityManagerInterface $em, $entity) { - return (string)$em->getConnection()->lastInsertId($this->sequenceName); + return (string) $em->getConnection()->lastInsertId($this->sequenceName); } /** - * {@inheritdoc} + * {@inheritDoc} */ public function isPostInsertGenerator() { diff --git a/lib/Doctrine/ORM/Id/IdentityGenerator.php b/lib/Doctrine/ORM/Id/IdentityGenerator.php index 7945c6936..a026f4a02 100644 --- a/lib/Doctrine/ORM/Id/IdentityGenerator.php +++ b/lib/Doctrine/ORM/Id/IdentityGenerator.php @@ -19,7 +19,7 @@ namespace Doctrine\ORM\Id; -use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManagerInterface; /** * Id generator that obtains IDs from special "identity" columns. These are columns @@ -48,9 +48,9 @@ class IdentityGenerator extends AbstractIdGenerator } /** - * {@inheritdoc} + * {@inheritDoc} */ - public function generate(EntityManager $em, $entity) + public function generate(EntityManagerInterface $em, $entity) { return (int)$em->getConnection()->lastInsertId($this->sequenceName); } diff --git a/lib/Doctrine/ORM/Id/SequenceGenerator.php b/lib/Doctrine/ORM/Id/SequenceGenerator.php index 545152254..b71a3409f 100644 --- a/lib/Doctrine/ORM/Id/SequenceGenerator.php +++ b/lib/Doctrine/ORM/Id/SequenceGenerator.php @@ -19,8 +19,8 @@ namespace Doctrine\ORM\Id; +use Doctrine\ORM\EntityManagerInterface; use Serializable; -use Doctrine\ORM\EntityManager; /** * Represents an ID generator that uses a database sequence. @@ -67,16 +67,9 @@ class SequenceGenerator extends AbstractIdGenerator implements Serializable } /** - * Generates an ID for the given entity. - * - * @param EntityManager $em - * @param object $entity - * - * @return integer The generated value. - * - * @override + * {@inheritDoc} */ - public function generate(EntityManager $em, $entity) + public function generate(EntityManagerInterface $em, $entity) { if ($this->_maxValue === null || $this->_nextValue == $this->_maxValue) { // Allocate new values diff --git a/lib/Doctrine/ORM/Id/TableGenerator.php b/lib/Doctrine/ORM/Id/TableGenerator.php index 34606fb22..809423285 100644 --- a/lib/Doctrine/ORM/Id/TableGenerator.php +++ b/lib/Doctrine/ORM/Id/TableGenerator.php @@ -19,7 +19,7 @@ namespace Doctrine\ORM\Id; -use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManagerInterface; /** * Id generator that uses a single-row database table and a hi/lo algorithm. @@ -70,9 +70,9 @@ class TableGenerator extends AbstractIdGenerator } /** - * {@inheritdoc} + * {@inheritDoc} */ - public function generate(EntityManager $em, $entity) + public function generate(EntityManagerInterface $em, $entity) { if ($this->_maxValue === null || $this->_nextValue == $this->_maxValue) { // Allocate new values diff --git a/lib/Doctrine/ORM/Id/UuidGenerator.php b/lib/Doctrine/ORM/Id/UuidGenerator.php index 901af806a..4287f2b1f 100644 --- a/lib/Doctrine/ORM/Id/UuidGenerator.php +++ b/lib/Doctrine/ORM/Id/UuidGenerator.php @@ -19,7 +19,7 @@ namespace Doctrine\ORM\Id; -use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManagerInterface; /** * Represents an ID generator that uses the database UUID expression @@ -30,16 +30,9 @@ use Doctrine\ORM\EntityManager; class UuidGenerator extends AbstractIdGenerator { /** - * Generates an ID for the given entity. - * - * @param EntityManager $em The EntityManager to use. - * @param object $entity - * - * @return string The generated value. - * - * @override + * {@inheritDoc} */ - public function generate(EntityManager $em, $entity) + public function generate(EntityManagerInterface $em, $entity) { $conn = $em->getConnection(); $sql = 'SELECT ' . $conn->getDatabasePlatform()->getGuidExpression(); diff --git a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php index d7554b903..af232d1ff 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php @@ -19,11 +19,11 @@ namespace Doctrine\ORM\Internal\Hydration; -use PDO; use Doctrine\DBAL\Types\Type; -use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Events; use Doctrine\ORM\Mapping\ClassMetadata; +use PDO; /** * Base class for all hydrators. A hydrator is a class that provides some form @@ -46,7 +46,7 @@ abstract class AbstractHydrator /** * The EntityManager instance. * - * @var EntityManager + * @var EntityManagerInterface */ protected $_em; @@ -95,9 +95,9 @@ abstract class AbstractHydrator /** * Initializes a new instance of a class derived from AbstractHydrator. * - * @param \Doctrine\ORM\EntityManager $em The EntityManager to use. + * @param EntityManagerInterface $em The EntityManager to use. */ - public function __construct(EntityManager $em) + public function __construct(EntityManagerInterface $em) { $this->_em = $em; $this->_platform = $em->getConnection()->getDatabasePlatform(); diff --git a/lib/Doctrine/ORM/PersistentCollection.php b/lib/Doctrine/ORM/PersistentCollection.php index d0a6d2c6c..c79130c65 100644 --- a/lib/Doctrine/ORM/PersistentCollection.php +++ b/lib/Doctrine/ORM/PersistentCollection.php @@ -71,7 +71,7 @@ final class PersistentCollection implements Collection, Selectable /** * The EntityManager that manages the persistence of the collection. * - * @var \Doctrine\ORM\EntityManager + * @var \Doctrine\ORM\EntityManagerInterface */ private $em; @@ -115,11 +115,11 @@ final class PersistentCollection implements Collection, Selectable /** * Creates a new persistent collection. * - * @param EntityManager $em The EntityManager the collection will be associated with. - * @param ClassMetadata $class The class descriptor of the entity type of this collection. - * @param Collection $coll The collection elements. + * @param EntityManagerInterface $em The EntityManager the collection will be associated with. + * @param ClassMetadata $class The class descriptor of the entity type of this collection. + * @param Collection $coll The collection elements. */ - public function __construct(EntityManager $em, $class, $coll) + public function __construct(EntityManagerInterface $em, $class, $coll) { $this->coll = $coll; $this->em = $em; diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index e6d79696c..537961420 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -19,25 +19,23 @@ namespace Doctrine\ORM\Persisters\Entity; -use Doctrine\DBAL\LockMode; -use Doctrine\DBAL\Types\Type; -use Doctrine\DBAL\Connection; - -use Doctrine\ORM\ORMException; -use Doctrine\ORM\OptimisticLockException; -use Doctrine\ORM\EntityManager; -use Doctrine\ORM\UnitOfWork; -use Doctrine\ORM\Query; -use Doctrine\ORM\PersistentCollection; -use Doctrine\ORM\Mapping\MappingException; -use Doctrine\ORM\Mapping\ClassMetadata; -use Doctrine\ORM\Persisters\SqlExpressionVisitor; -use Doctrine\ORM\Persisters\SqlValueVisitor; -use Doctrine\ORM\Utility\IdentifierFlattener; - -use Doctrine\Common\Util\ClassUtils; use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Expr\Comparison; +use Doctrine\Common\Util\ClassUtils; +use Doctrine\DBAL\Connection; +use Doctrine\DBAL\LockMode; +use Doctrine\DBAL\Types\Type; +use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Mapping\MappingException; +use Doctrine\ORM\OptimisticLockException; +use Doctrine\ORM\ORMException; +use Doctrine\ORM\PersistentCollection; +use Doctrine\ORM\Persisters\SqlExpressionVisitor; +use Doctrine\ORM\Persisters\SqlValueVisitor; +use Doctrine\ORM\Query; +use Doctrine\ORM\UnitOfWork; +use Doctrine\ORM\Utility\IdentifierFlattener; /** * A BasicEntityPersister maps an entity to a single table in a relational database. @@ -124,7 +122,7 @@ class BasicEntityPersister implements EntityPersister /** * The EntityManager instance. * - * @var \Doctrine\ORM\EntityManager + * @var EntityManagerInterface */ protected $em; @@ -221,10 +219,10 @@ class BasicEntityPersister implements EntityPersister * Initializes a new BasicEntityPersister that uses the given EntityManager * and persists instances of the class described by the given ClassMetadata descriptor. * - * @param \Doctrine\ORM\EntityManager $em - * @param \Doctrine\ORM\Mapping\ClassMetadata $class + * @param EntityManagerInterface $em + * @param ClassMetadata $class */ - public function __construct(EntityManager $em, ClassMetadata $class) + public function __construct(EntityManagerInterface $em, ClassMetadata $class) { $this->em = $em; $this->class = $class; diff --git a/lib/Doctrine/ORM/Proxy/ProxyFactory.php b/lib/Doctrine/ORM/Proxy/ProxyFactory.php index 94e29e22b..c6f1cbd3d 100644 --- a/lib/Doctrine/ORM/Proxy/ProxyFactory.php +++ b/lib/Doctrine/ORM/Proxy/ProxyFactory.php @@ -21,12 +21,12 @@ namespace Doctrine\ORM\Proxy; use Doctrine\Common\Persistence\Mapping\ClassMetadata; use Doctrine\Common\Proxy\AbstractProxyFactory; -use Doctrine\Common\Proxy\ProxyDefinition; -use Doctrine\Common\Util\ClassUtils; use Doctrine\Common\Proxy\Proxy as BaseProxy; +use Doctrine\Common\Proxy\ProxyDefinition; use Doctrine\Common\Proxy\ProxyGenerator; +use Doctrine\Common\Util\ClassUtils; +use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Persisters\Entity\EntityPersister; -use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityNotFoundException; use Doctrine\ORM\Utility\IdentifierFlattener; @@ -41,7 +41,7 @@ use Doctrine\ORM\Utility\IdentifierFlattener; class ProxyFactory extends AbstractProxyFactory { /** - * @var \Doctrine\ORM\EntityManager The EntityManager this factory is bound to. + * @var EntityManagerInterface The EntityManager this factory is bound to. */ private $em; @@ -66,13 +66,13 @@ class ProxyFactory extends AbstractProxyFactory * Initializes a new instance of the ProxyFactory class that is * connected to the given EntityManager. * - * @param \Doctrine\ORM\EntityManager $em The EntityManager the new factory works for. - * @param string $proxyDir The directory to use for the proxy classes. It must exist. - * @param string $proxyNs The namespace to use for the proxy classes. - * @param boolean|int $autoGenerate The strategy for automatically generating proxy classes. Possible - * values are constants of Doctrine\Common\Proxy\AbstractProxyFactory. + * @param EntityManagerInterface $em The EntityManager the new factory works for. + * @param string $proxyDir The directory to use for the proxy classes. It must exist. + * @param string $proxyNs The namespace to use for the proxy classes. + * @param boolean|int $autoGenerate The strategy for automatically generating proxy classes. Possible + * values are constants of Doctrine\Common\Proxy\AbstractProxyFactory. */ - public function __construct(EntityManager $em, $proxyDir, $proxyNs, $autoGenerate = AbstractProxyFactory::AUTOGENERATE_NEVER) + public function __construct(EntityManagerInterface $em, $proxyDir, $proxyNs, $autoGenerate = AbstractProxyFactory::AUTOGENERATE_NEVER) { $proxyGenerator = new ProxyGenerator($proxyDir, $proxyNs); diff --git a/lib/Doctrine/ORM/Query/Filter/SQLFilter.php b/lib/Doctrine/ORM/Query/Filter/SQLFilter.php index 80015a0a6..3c6daaaad 100644 --- a/lib/Doctrine/ORM/Query/Filter/SQLFilter.php +++ b/lib/Doctrine/ORM/Query/Filter/SQLFilter.php @@ -19,7 +19,7 @@ namespace Doctrine\ORM\Query\Filter; -use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Query\ParameterTypeInferer; @@ -37,7 +37,7 @@ abstract class SQLFilter /** * The entity manager. * - * @var EntityManager + * @var EntityManagerInterface */ private $em; @@ -51,9 +51,9 @@ abstract class SQLFilter /** * Constructs the SQLFilter object. * - * @param EntityManager $em The entity manager. + * @param EntityManagerInterface $em The entity manager. */ - final public function __construct(EntityManager $em) + final public function __construct(EntityManagerInterface $em) { $this->em = $em; } diff --git a/lib/Doctrine/ORM/Query/FilterCollection.php b/lib/Doctrine/ORM/Query/FilterCollection.php index 3eb6b1a48..ffbaeaf12 100644 --- a/lib/Doctrine/ORM/Query/FilterCollection.php +++ b/lib/Doctrine/ORM/Query/FilterCollection.php @@ -19,7 +19,7 @@ namespace Doctrine\ORM\Query; -use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManagerInterface; /** * Collection class for all the query filters. @@ -74,9 +74,9 @@ class FilterCollection /** * Constructor. * - * @param EntityManager $em + * @param EntityManagerInterface $em */ - public function __construct(EntityManager $em) + public function __construct(EntityManagerInterface $em) { $this->em = $em; $this->config = $em->getConfiguration(); diff --git a/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php b/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php index 03fa9620f..413ac60bb 100644 --- a/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php +++ b/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php @@ -19,7 +19,7 @@ namespace Doctrine\ORM\Query; -use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadataInfo; /** @@ -64,7 +64,7 @@ class ResultSetMappingBuilder extends ResultSetMapping private $sqlCounter = 0; /** - * @var EntityManager + * @var EntityManagerInterface */ private $em; @@ -76,10 +76,10 @@ class ResultSetMappingBuilder extends ResultSetMapping private $defaultRenameMode; /** - * @param EntityManager $em - * @param integer $defaultRenameMode + * @param EntityManagerInterface $em + * @param integer $defaultRenameMode */ - public function __construct(EntityManager $em, $defaultRenameMode = self::COLUMN_RENAMING_NONE) + public function __construct(EntityManagerInterface $em, $defaultRenameMode = self::COLUMN_RENAMING_NONE) { $this->em = $em; $this->defaultRenameMode = $defaultRenameMode; diff --git a/lib/Doctrine/ORM/QueryBuilder.php b/lib/Doctrine/ORM/QueryBuilder.php index 36dc2d7fe..0dda54c7a 100644 --- a/lib/Doctrine/ORM/QueryBuilder.php +++ b/lib/Doctrine/ORM/QueryBuilder.php @@ -48,7 +48,7 @@ class QueryBuilder /** * The EntityManager used by this QueryBuilder. * - * @var EntityManager + * @var EntityManagerInterface */ private $_em; @@ -147,9 +147,9 @@ class QueryBuilder /** * Initializes a new QueryBuilder that uses the given EntityManager. * - * @param EntityManager $em The EntityManager to use. + * @param EntityManagerInterface $em The EntityManager to use. */ - public function __construct(EntityManager $em) + public function __construct(EntityManagerInterface $em) { $this->_em = $em; $this->parameters = new ArrayCollection(); diff --git a/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php b/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php index 2b6478be5..5196dc339 100644 --- a/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php +++ b/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php @@ -20,11 +20,11 @@ namespace Doctrine\ORM\Tools; use Doctrine\Common\Persistence\Proxy; +use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Event\OnFlushEventArgs; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\UnitOfWork; -use Doctrine\ORM\EntityManager; /** * Use this logger to dump the identity map during the onFlush event. This is useful for debugging @@ -69,11 +69,11 @@ class DebugUnitOfWorkListener /** * Dumps the contents of the identity map into a stream. * - * @param EntityManager $em + * @param EntityManagerInterface $em * * @return void */ - public function dumpIdentityMap(EntityManager $em) + public function dumpIdentityMap(EntityManagerInterface $em) { $uow = $em->getUnitOfWork(); $identityMap = $uow->getIdentityMap(); diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 5749273dc..bd64684a3 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -204,7 +204,7 @@ class UnitOfWork implements PropertyChangedListener /** * The EntityManager that "owns" this UnitOfWork instance. * - * @var \Doctrine\ORM\EntityManager + * @var EntityManagerInterface */ private $em; @@ -287,9 +287,9 @@ class UnitOfWork implements PropertyChangedListener /** * Initializes a new UnitOfWork instance, bound to the given EntityManager. * - * @param \Doctrine\ORM\EntityManager $em + * @param EntityManagerInterface $em */ - public function __construct(EntityManager $em) + public function __construct(EntityManagerInterface $em) { $this->em = $em; $this->evm = $em->getEventManager(); From dd8db1acd2022820a8b2fc177d83b05ea0df9adc Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 5 Dec 2014 15:50:21 +0100 Subject: [PATCH 2/4] DDC-3427 - s/EntityManager/EntityManagerInterface in relevant tests about identifier generation --- tests/Doctrine/Tests/Mocks/SequenceMock.php | 4 ++-- tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php | 4 ++-- .../Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php | 6 ++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/Doctrine/Tests/Mocks/SequenceMock.php b/tests/Doctrine/Tests/Mocks/SequenceMock.php index 4f5123004..db73051d2 100644 --- a/tests/Doctrine/Tests/Mocks/SequenceMock.php +++ b/tests/Doctrine/Tests/Mocks/SequenceMock.php @@ -2,7 +2,7 @@ namespace Doctrine\Tests\Mocks; -use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManagerInterface; /** * Mock class for SequenceGenerator. @@ -17,7 +17,7 @@ class SequenceMock extends \Doctrine\ORM\Id\SequenceGenerator /** * {@inheritdoc} */ - public function generate(EntityManager $em, $entity) + public function generate(EntityManagerInterface $em, $entity) { return $this->_sequenceNumber++; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php index 0283e6457..a55eba14e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php @@ -2,7 +2,7 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Id\AbstractIdGenerator; use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\ORM\Mapping\Driver\StaticPHPDriver; @@ -97,7 +97,7 @@ class DDC2415ChildEntity extends DDC2415ParentEntity class DDC2415Generator extends AbstractIdGenerator { - public function generate(EntityManager $em, $entity) + public function generate(EntityManagerInterface $em, $entity) { return md5($entity->getName()); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php index 54d2c9eac..394b737a5 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php @@ -10,6 +10,8 @@ use Doctrine\Tests\Mocks\ConnectionMock; use Doctrine\Tests\Mocks\DriverMock; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\Common\EventManager; +use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Id\AbstractIdGenerator; use Doctrine\ORM\Mapping\ClassMetadataFactory; class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase @@ -410,9 +412,9 @@ class TestEntity1 private $association; } -class CustomIdGenerator extends \Doctrine\ORM\Id\AbstractIdGenerator +class CustomIdGenerator extends AbstractIdGenerator { - public function generate(\Doctrine\ORM\EntityManager $em, $entity) + public function generate(EntityManagerInterface $em, $entity) { } } From 339bd23ac890f795d5cf0cb9519ef10ae2e838a5 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 16 Jan 2015 14:44:31 +0100 Subject: [PATCH 3/4] #1209 DDC-3427 - removing leftover `EntityManager` hints (using interface instead) --- .../ORM/Event/OnClassMetadataNotFoundEventArgs.php | 3 --- lib/Doctrine/ORM/Event/PreUpdateEventArgs.php | 10 +++++----- .../Collection/AbstractCollectionPersister.php | 10 +++++----- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/lib/Doctrine/ORM/Event/OnClassMetadataNotFoundEventArgs.php b/lib/Doctrine/ORM/Event/OnClassMetadataNotFoundEventArgs.php index 155b1baf6..a044a7e32 100644 --- a/lib/Doctrine/ORM/Event/OnClassMetadataNotFoundEventArgs.php +++ b/lib/Doctrine/ORM/Event/OnClassMetadataNotFoundEventArgs.php @@ -19,12 +19,9 @@ namespace Doctrine\ORM\Event; -use Doctrine\Common\EventArgs; use Doctrine\Common\Persistence\Event\ManagerEventArgs; use Doctrine\Common\Persistence\Mapping\ClassMetadata; use Doctrine\Common\Persistence\ObjectManager; -use Doctrine\ORM\EntityManager; -use Doctrine\ORM\EntityManagerInterface; /** * Class that holds event arguments for a `onClassMetadataNotFound` event. diff --git a/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php b/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php index 9624e94da..d9a9f9db2 100644 --- a/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php +++ b/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php @@ -19,7 +19,7 @@ namespace Doctrine\ORM\Event; -use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManagerInterface; /** * Class that holds event arguments for a preInsert/preUpdate event. @@ -39,11 +39,11 @@ class PreUpdateEventArgs extends LifecycleEventArgs /** * Constructor. * - * @param object $entity - * @param EntityManager $em - * @param array $changeSet + * @param object $entity + * @param EntityManagerInterface $em + * @param array $changeSet */ - public function __construct($entity, EntityManager $em, array &$changeSet) + public function __construct($entity, EntityManagerInterface $em, array &$changeSet) { parent::__construct($entity, $em); diff --git a/lib/Doctrine/ORM/Persisters/Collection/AbstractCollectionPersister.php b/lib/Doctrine/ORM/Persisters/Collection/AbstractCollectionPersister.php index b73744ee4..094895671 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/AbstractCollectionPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/AbstractCollectionPersister.php @@ -19,7 +19,7 @@ namespace Doctrine\ORM\Persisters\Collection; -use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\UnitOfWork; /** @@ -31,7 +31,7 @@ use Doctrine\ORM\UnitOfWork; abstract class AbstractCollectionPersister implements CollectionPersister { /** - * @var EntityManager + * @var EntityManagerInterface */ protected $em; @@ -41,7 +41,7 @@ abstract class AbstractCollectionPersister implements CollectionPersister protected $conn; /** - * @var \Doctrine\ORM\UnitOfWork + * @var UnitOfWork */ protected $uow; @@ -62,9 +62,9 @@ abstract class AbstractCollectionPersister implements CollectionPersister /** * Initializes a new instance of a class derived from AbstractCollectionPersister. * - * @param \Doctrine\ORM\EntityManager $em + * @param EntityManagerInterface $em */ - public function __construct(EntityManager $em) + public function __construct(EntityManagerInterface $em) { $this->em = $em; $this->uow = $em->getUnitOfWork(); From efe9e3ab28fada89751ae0a6013c6d06e4645b7c Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 16 Jan 2015 14:55:16 +0100 Subject: [PATCH 4/4] #1209 DDC-3427 - documenting s/`EntityManager`/`EntityManagerInterface` signature BC breaks --- UPGRADE.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index 3bc4d2b12..f78883421 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,16 @@ # Upgrade to 2.5 +## Minor BC BREAK: ``EntityManagerInterface`` instead of ``EntityManager`` in type-hints + +As of 2.5, classes requiring the ``EntityManager`` in any method signature will now require +an ``EntityManagerInterface`` instead. +If you are extending any of the following classes, then you need to check following +signatures: + +- ``Doctrine\ORM\Id\AbstractIdGenerator#generate(EntityManagerInterface $em, $entity)`` +- ``Doctrine\ORM\Tools\DebugUnitOfWorkListener#dumpIdentityMap(EntityManagerInterface $em)`` +- ``Doctrine\ORM\Mapping\ClassMetadataFactory#setEntityManager(EntityManagerInterface $em)`` + ## Minor BC BREAK: Custom Hydrators API change As of 2.5, `AbstractHydrator` does not enforce the usage of cache as part of