Skip to content

Commit

Permalink
Merge pull request #6599 from Majkl578/dev/typehint-EntityManagerInte…
Browse files Browse the repository at this point in the history
…rface

Typehint EntityManagerInterface only
  • Loading branch information
Ocramius authored Aug 5, 2017
2 parents 6434b2a + dcb5bdb commit 082d666
Show file tree
Hide file tree
Showing 55 changed files with 104 additions and 100 deletions.
4 changes: 4 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Upgrade to 3.0

## BC Break: ``EntityManagerInterface`` is now used instead of ``EntityManager`` in typehints

`Sequencing\Generator#generate()` now takes ``EntityManagerInterface`` as its first argument instead of ``EntityManager``. If you have any custom generators, please update your code accordingly.

## BC Break: Removed `EntityManager#flush($entity)` and `EntityManager#flush($entities)`

If your code relies on single entity flushing optimisations via
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/AbstractQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ abstract public function getSQL();
/**
* Retrieves the associated EntityManager of this Query instance.
*
* @return \Doctrine\ORM\EntityManager
* @return \Doctrine\ORM\EntityManagerInterface
*/
public function getEntityManager()
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
class DefaultEntityHydrator implements EntityHydrator
{
/**
* @var \Doctrine\ORM\EntityManager
* @var \Doctrine\ORM\EntityManagerInterface
*/
private $em;

Expand Down
8 changes: 4 additions & 4 deletions lib/Doctrine/ORM/EntityRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class EntityRepository implements ObjectRepository, Selectable
protected $entityName;

/**
* @var EntityManager
* @var EntityManagerInterface
*/
protected $em;

Expand All @@ -43,8 +43,8 @@ class EntityRepository implements ObjectRepository, Selectable
/**
* Initializes a new <tt>EntityRepository</tt>.
*
* @param EntityManager $em The EntityManager to use.
* @param Mapping\ClassMetadata $class The class descriptor.
* @param EntityManagerInterface $em The EntityManager to use.
* @param Mapping\ClassMetadata $class The class descriptor.
*/
public function __construct(EntityManagerInterface $em, Mapping\ClassMetadata $class)
{
Expand Down Expand Up @@ -249,7 +249,7 @@ public function getClassName()
}

/**
* @return EntityManager
* @return EntityManagerInterface
*/
protected function getEntityManager()
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Event/LifecycleEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function getEntity()
/**
* Retrieves associated EntityManager.
*
* @return \Doctrine\ORM\EntityManager
* @return \Doctrine\ORM\EntityManagerInterface
*/
public function getEntityManager()
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Event/OnClearEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(EntityManagerInterface $em)
/**
* Retrieves associated EntityManager.
*
* @return \Doctrine\ORM\EntityManager
* @return \Doctrine\ORM\EntityManagerInterface
*/
public function getEntityManager()
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Event/OnFlushEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct(EntityManagerInterface $em)
/**
* Retrieve associated EntityManager.
*
* @return \Doctrine\ORM\EntityManager
* @return \Doctrine\ORM\EntityManagerInterface
*/
public function getEntityManager()
{
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Event/PostFlushEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class PostFlushEventArgs extends EventArgs
{
/**
* @var \Doctrine\ORM\EntityManager
* @var \Doctrine\ORM\EntityManagerInterface
*/
private $em;

Expand All @@ -34,7 +34,7 @@ public function __construct(EntityManagerInterface $em)
/**
* Retrieves associated EntityManager.
*
* @return \Doctrine\ORM\EntityManager
* @return \Doctrine\ORM\EntityManagerInterface
*/
public function getEntityManager()
{
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Event/PreFlushEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class PreFlushEventArgs extends EventArgs
{
/**
* @var \Doctrine\ORM\EntityManager
* @var \Doctrine\ORM\EntityManagerInterface
*/
private $em;

Expand All @@ -34,7 +34,7 @@ public function __construct(EntityManagerInterface $em)
}

/**
* @return \Doctrine\ORM\EntityManager
* @return \Doctrine\ORM\EntityManagerInterface
*/
public function getEntityManager()
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Query/FilterCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class FilterCollection
/**
* The EntityManager that "owns" this FilterCollection instance.
*
* @var \Doctrine\ORM\EntityManager
* @var \Doctrine\ORM\EntityManagerInterface
*/
private $em;

Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Query/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class Parser
/**
* The EntityManager.
*
* @var \Doctrine\ORM\EntityManager
* @var \Doctrine\ORM\EntityManagerInterface
*/
private $em;

Expand Down Expand Up @@ -227,7 +227,7 @@ public function getParserResult()
/**
* Gets the EntityManager used by the parser.
*
* @return \Doctrine\ORM\EntityManager
* @return \Doctrine\ORM\EntityManagerInterface
*/
public function getEntityManager()
{
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Query/SqlWalker.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class SqlWalker implements TreeWalker
private $parserResult;

/**
* @var \Doctrine\ORM\EntityManager
* @var \Doctrine\ORM\EntityManagerInterface
*/
private $em;

Expand Down Expand Up @@ -196,7 +196,7 @@ public function getConnection()
/**
* Gets the EntityManager used by the walker.
*
* @return \Doctrine\ORM\EntityManager
* @return \Doctrine\ORM\EntityManagerInterface
*/
public function getEntityManager()
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public function getType()
/**
* Gets the associated EntityManager for this query builder.
*
* @return EntityManager
* @return EntityManagerInterface
*/
public function getEntityManager()
{
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Sequencing/BigIntegerIdentityGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Doctrine\ORM\Sequencing;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;

/**
* Id generator that obtains IDs from special "identity" columns. These are columns
Expand Down Expand Up @@ -35,7 +35,7 @@ public function __construct($sequenceName = null)
/**
* {@inheritdoc}
*/
public function generate(EntityManager $em, $entity)
public function generate(EntityManagerInterface $em, $entity)
{
return (string) $em->getConnection()->lastInsertId($this->sequenceName);
}
Expand Down
8 changes: 4 additions & 4 deletions lib/Doctrine/ORM/Sequencing/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@

namespace Doctrine\ORM\Sequencing;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;

interface Generator
{
/**
* Generates an identifier for an entity.
*
* @param EntityManager $em
* @param object $entity
* @param EntityManagerInterface $em
* @param object $entity
*
* @return \Generator
*/
public function generate(EntityManager $em, $entity);
public function generate(EntityManagerInterface $em, $entity);

/**
* Gets whether this generator is a post-insert generator which means that
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Sequencing/IdentityGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Doctrine\ORM\Sequencing;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;

/**
* Id generator that obtains IDs from special "identity" columns. These are columns
Expand Down Expand Up @@ -35,7 +35,7 @@ public function __construct($sequenceName = null)
/**
* {@inheritDoc}
*/
public function generate(EntityManager $em, $entity)
public function generate(EntityManagerInterface $em, $entity)
{
return (int) $em->getConnection()->lastInsertId($this->sequenceName);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Sequencing/SequenceGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Doctrine\ORM\Sequencing;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Serializable;

/**
Expand Down Expand Up @@ -54,7 +54,7 @@ public function __construct($sequenceName, $allocationSize)
/**
* {@inheritdoc}
*/
public function generate(EntityManager $em, $entity)
public function generate(EntityManagerInterface $em, $entity)
{
if ($this->maxValue === null || $this->nextValue == $this->maxValue) {
// Allocate new values
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Sequencing/TableGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Doctrine\ORM\Sequencing;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;

/**
* Id generator that uses a single-row database table and a hi/lo algorithm.
Expand Down Expand Up @@ -57,7 +57,7 @@ public function __construct($tableName, $sequenceName = 'default', $allocationSi
/**
* {@inheritdoc}
*/
public function generate(EntityManager $em, $entity)
public function generate(EntityManagerInterface $em, $entity)
{
if ($this->maxValue === null || $this->nextValue === $this->maxValue) {
// Allocate new values
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Sequencing/UuidGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Doctrine\ORM\Sequencing;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;

/**
* Represents an ID generator that uses the database UUID expression
Expand All @@ -17,7 +17,7 @@ class UuidGenerator implements Generator
/**
* {@inheritdoc}
*/
public function generate(EntityManager $em, $entity)
public function generate(EntityManagerInterface $em, $entity)
{
$conn = $em->getConnection();
$sql = 'SELECT ' . $conn->getDatabasePlatform()->getGuidExpression();
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Tools/Console/Command/InfoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
/* @var $entityManager \Doctrine\ORM\EntityManager */
/* @var $entityManager \Doctrine\ORM\EntityManagerInterface */
$entityManager = $this->getHelper('em')->getEntityManager();

$entityClassNames = $entityManager->getConfiguration()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
$emHelper = $this->getHelper('em');

/* @var $em \Doctrine\ORM\EntityManager */
/* @var $em \Doctrine\ORM\EntityManagerInterface */
$em = $emHelper->getEntityManager();

$metadatas = $em->getMetadataFactory()->getAllMetadata();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class LimitSubqueryOutputWalker extends SqlWalker
private $maxResults;

/**
* @var \Doctrine\ORM\EntityManager
* @var \Doctrine\ORM\EntityManagerInterface
*/
private $em;

Expand Down
8 changes: 4 additions & 4 deletions tests/Doctrine/Tests/EventListener/CacheMetadataListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Doctrine\Tests\EventListener;

use Doctrine\Common\Persistence\Event\LoadClassMetadataEventArgs;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\CacheMetadata;
use Doctrine\ORM\Mapping\CacheUsage;
use Doctrine\ORM\Mapping\ClassMetadata;
Expand Down Expand Up @@ -57,10 +57,10 @@ private function recordVisit(ClassMetadata $metadata)
}

/**
* @param ClassMetadata $metadata
* @param EntityManager $em
* @param ClassMetadata $metadata
* @param EntityManagerInterface $em
*/
protected function enableCaching(ClassMetadata $metadata, EntityManager $em)
protected function enableCaching(ClassMetadata $metadata, EntityManagerInterface $em)
{
if ($this->isVisited($metadata)) {
return; // Already handled in the past
Expand Down
4 changes: 2 additions & 2 deletions tests/Doctrine/Tests/Mocks/SequenceMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Doctrine\Tests\Mocks;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Sequencing\SequenceGenerator;

/**
Expand All @@ -20,7 +20,7 @@ class SequenceMock extends SequenceGenerator
/**
* {@inheritdoc}
*/
public function generate(EntityManager $em, $entity)
public function generate(EntityManagerInterface $em, $entity)
{
return $this->sequenceNumber++;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class DefaultCacheFactoryTest extends OrmTestCase
private $factory;

/**
* @var \Doctrine\ORM\EntityManager
* @var \Doctrine\ORM\EntityManagerInterface
*/
private $em;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class DefaultEntityHydratorTest extends OrmTestCase
private $structure;

/**
* @var \Doctrine\ORM\EntityManager
* @var \Doctrine\ORM\EntityManagerInterface
*/
private $em;

Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class DefaultQueryCacheTest extends OrmTestCase
private $queryCache;

/**
* @var \Doctrine\ORM\EntityManager
* @var \Doctrine\ORM\EntityManagerInterface
*/
private $em;

Expand Down
Loading

0 comments on commit 082d666

Please sign in to comment.