1
0
mirror of synced 2024-12-04 18:56:06 +03:00

DDC-3427 - s/EntityManager/EntityManagerInterface in type-hints

This commit is contained in:
Marco Pivetta 2014-12-05 14:02:47 +01:00
parent 0e7646cf4b
commit 6fc0d84b7a
23 changed files with 105 additions and 126 deletions

View File

@ -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 <tt>AbstractQuery</tt>.
*
* @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();

View File

@ -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();

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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

View File

@ -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();

View File

@ -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()
{

View File

@ -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);
}

View File

@ -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

View File

@ -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

View File

@ -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();

View File

@ -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 <tt>AbstractHydrator</tt>.
*
* @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();

View File

@ -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;

View File

@ -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 <tt>BasicEntityPersister</tt> 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;

View File

@ -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 <tt>ProxyFactory</tt> class that is
* connected to the given <tt>EntityManager</tt>.
*
* @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);

View File

@ -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;
}

View File

@ -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();

View File

@ -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;

View File

@ -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 <tt>QueryBuilder</tt> that uses the given <tt>EntityManager</tt>.
*
* @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();

View File

@ -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();

View File

@ -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();