diff --git a/.github/workflows/coding-standard.yml b/.github/workflows/coding-standard.yml index d0f9251732c..20e55b12fcc 100644 --- a/.github/workflows/coding-standard.yml +++ b/.github/workflows/coding-standard.yml @@ -12,4 +12,4 @@ jobs: coding-standards: uses: "doctrine/.github/.github/workflows/coding-standards.yml@1.4.1" with: - php-version: "8.0" + php-version: "8.1" diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 5d3f988c43c..cecb27d0026 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -18,7 +18,7 @@ jobs: fail-fast: false matrix: php-version: - - "8.0" + - "8.1" dbal-version: - "default" @@ -53,7 +53,7 @@ jobs: fail-fast: false matrix: php-version: - - "8.0" + - "8.1" dbal-version: - "default" diff --git a/composer.json b/composer.json index 43f7a70467e..2b27555ac1b 100644 --- a/composer.json +++ b/composer.json @@ -45,7 +45,7 @@ "phpunit/phpunit": "^9.5", "squizlabs/php_codesniffer": "3.6.2", "symfony/cache": "^4.4 || ^5.4 || ^6.0", - "vimeo/psalm": "4.16.1" + "vimeo/psalm": "4.17.0" }, "conflict": { "doctrine/annotations": "<1.13 || >= 2.0" diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index b297165f405..b13ea28393b 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -374,6 +374,7 @@ public function flush($entity = null) * @param int|null $lockVersion The version of the entity to find when using * optimistic locking. * @psalm-param class-string $className + * @psalm-param LockMode::*|null $lockMode * * @return object|null The entity instance or NULL if the entity can not be found. * @psalm-return ?T @@ -946,6 +947,8 @@ public function hasFilters() } /** + * @psalm-param LockMode::* $lockMode + * * @throws OptimisticLockException * @throws TransactionRequiredException */ diff --git a/lib/Doctrine/ORM/EntityManagerInterface.php b/lib/Doctrine/ORM/EntityManagerInterface.php index efe88e53362..bedef5e8a78 100644 --- a/lib/Doctrine/ORM/EntityManagerInterface.php +++ b/lib/Doctrine/ORM/EntityManagerInterface.php @@ -7,6 +7,7 @@ use DateTimeInterface; use Doctrine\Common\EventManager; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\LockMode; use Doctrine\ORM\Exception\ORMException; use Doctrine\ORM\Internal\Hydration\AbstractHydrator; use Doctrine\ORM\Proxy\ProxyFactory; @@ -204,6 +205,7 @@ public function close(); * @param object $entity * @param int $lockMode * @param int|DateTimeInterface|null $lockVersion + * @psalm-param LockMode::* $lockMode * * @return void * diff --git a/lib/Doctrine/ORM/EntityRepository.php b/lib/Doctrine/ORM/EntityRepository.php index 03b1dfb1127..0235cacf6e6 100644 --- a/lib/Doctrine/ORM/EntityRepository.php +++ b/lib/Doctrine/ORM/EntityRepository.php @@ -8,6 +8,7 @@ use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Selectable; +use Doctrine\DBAL\LockMode; use Doctrine\Deprecations\Deprecation; use Doctrine\Inflector\Inflector; use Doctrine\Inflector\InflectorFactory; @@ -164,6 +165,7 @@ public function clear() * or NULL if no specific lock mode should be used * during the search. * @param int|null $lockVersion The lock version. + * @psalm-param LockMode::*|null $lockMode * * @return object|null The entity instance or NULL if the entity can not be found. * @psalm-return ?T diff --git a/lib/Doctrine/ORM/LazyCriteriaCollection.php b/lib/Doctrine/ORM/LazyCriteriaCollection.php index 7fb866c48d2..2e298f77f70 100644 --- a/lib/Doctrine/ORM/LazyCriteriaCollection.php +++ b/lib/Doctrine/ORM/LazyCriteriaCollection.php @@ -9,6 +9,7 @@ use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Selectable; use Doctrine\ORM\Persisters\Entity\EntityPersister; +use ReturnTypeWillChange; /** * A lazy collection that allows a fast count when using criteria object @@ -38,6 +39,7 @@ public function __construct(EntityPersister $entityPersister, Criteria $criteria * * @return int */ + #[ReturnTypeWillChange] public function count() { if ($this->isInitialized()) { diff --git a/lib/Doctrine/ORM/PersistentCollection.php b/lib/Doctrine/ORM/PersistentCollection.php index 5ac43b0b7cd..89f6710b6eb 100644 --- a/lib/Doctrine/ORM/PersistentCollection.php +++ b/lib/Doctrine/ORM/PersistentCollection.php @@ -10,6 +10,7 @@ use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Selectable; use Doctrine\ORM\Mapping\ClassMetadata; +use ReturnTypeWillChange; use RuntimeException; use function array_combine; @@ -504,6 +505,7 @@ public function offsetSet($offset, $value): void * * @return object|null */ + #[ReturnTypeWillChange] public function offsetUnset($offset) { return $this->remove($offset); diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index a60911d80da..4a32448fbc8 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -1537,6 +1537,7 @@ public function lock(array $criteria, $lockMode) * Gets the FROM and optionally JOIN conditions to lock the entity managed by this persister. * * @param int|null $lockMode One of the Doctrine\DBAL\LockMode::* constants. + * @psalm-param LockMode::*|null $lockMode * * @return string */ diff --git a/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php index b36c9040534..c3a736b1a12 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php @@ -5,6 +5,7 @@ namespace Doctrine\ORM\Persisters\Entity; use Doctrine\Common\Collections\Criteria; +use Doctrine\DBAL\LockMode; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\MappingException; use Doctrine\ORM\PersistentCollection; @@ -54,6 +55,7 @@ public function getInsertSQL(); * @param int|null $limit * @param int|null $offset * @param mixed[]|null $orderBy + * @psalm-param LockMode::*|null $lockMode * * @return string */ @@ -185,6 +187,7 @@ public function getOwningTable($fieldName); * @psalm-param array $criteria * @psalm-param array|null $assoc * @psalm-param array $hints + * @psalm-param LockMode::*|null $lockMode * @psalm-param array|null $orderBy * * @return object|null The loaded and managed entity instance or NULL if the entity can not be found. @@ -239,6 +242,7 @@ public function loadOneToOneEntity(array $assoc, $sourceEntity, array $identifie * @psalm-param array $id The identifier of the entity as an * associative array from column or * field names to values. + * @psalm-param LockMode::*|null $lockMode * * @return void */ @@ -300,6 +304,7 @@ public function loadOneToManyCollection(array $assoc, $sourceEntity, PersistentC * * @param int $lockMode One of the Doctrine\DBAL\LockMode::* constants. * @psalm-param array $criteria + * @psalm-param LockMode::* $lockMode * * @return void */ diff --git a/lib/Doctrine/ORM/Query.php b/lib/Doctrine/ORM/Query.php index 69f1581774d..387a31ea754 100644 --- a/lib/Doctrine/ORM/Query.php +++ b/lib/Doctrine/ORM/Query.php @@ -732,6 +732,7 @@ public function setHydrationMode($hydrationMode): self * @see \Doctrine\DBAL\LockMode * * @param int $lockMode + * @psalm-param LockMode::* $lockMode * * @throws TransactionRequiredException */ diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 6593d05e6ac..f059f3bde21 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -2458,6 +2458,7 @@ static function ($assoc) { * * @param object $entity * @param int|DateTimeInterface|null $lockVersion + * @psalm-param LockMode::* $lockMode * * @throws ORMInvalidArgumentException * @throws TransactionRequiredException diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 1a1d9b15177..fcbe53514ff 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -255,16 +255,6 @@ parameters: count: 2 path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - message: "#^Call to an undefined method ReflectionProperty\\:\\:getType\\(\\)\\.$#" - count: 3 - path: lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php - - - - message: "#^Call to an undefined method ReflectionProperty\\:\\:hasType\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php - - message: "#^Method Doctrine\\\\ORM\\\\Mapping\\\\NamingStrategy\\:\\:joinColumnName\\(\\) invoked with 2 parameters, 1 required\\.$#" count: 2 @@ -821,18 +811,17 @@ parameters: path: lib/Doctrine/ORM/Query/Parser.php - - message: - """ - #^PHPDoc tag @return has invalid value \\(AST\\\\BetweenExpression\\| - AST\\\\CollectionMemberExpression\\| - AST\\\\ComparisonExpression\\| - AST\\\\EmptyCollectionComparisonExpression\\| - AST\\\\ExistsExpression\\| - AST\\\\InExpression\\| - AST\\\\InstanceOfExpression\\| - AST\\\\LikeExpression\\| - AST\\\\NullComparisonExpression\\)\\: Unexpected token "\\\\n \\* ", expected type at offset 344$# - """ + message: """ + #^PHPDoc tag @return has invalid value \\(AST\\\\BetweenExpression\\| + AST\\\\CollectionMemberExpression\\| + AST\\\\ComparisonExpression\\| + AST\\\\EmptyCollectionComparisonExpression\\| + AST\\\\ExistsExpression\\| + AST\\\\InExpression\\| + AST\\\\InstanceOfExpression\\| + AST\\\\LikeExpression\\| + AST\\\\NullComparisonExpression\\)\\: Unexpected token "\\\\n \\* ", expected type at offset 344$# + """ count: 1 path: lib/Doctrine/ORM/Query/Parser.php diff --git a/phpstan-params.neon b/phpstan-params.neon index 1a5e688fa43..784f63e2d2b 100644 --- a/phpstan-params.neon +++ b/phpstan-params.neon @@ -8,4 +8,4 @@ parameters: earlyTerminatingMethodCalls: Doctrine\ORM\Query\Parser: - syntaxError - phpVersion: 70100 + phpVersion: 80100 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 85c24c1edc1..abdeb61b299 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + getResultCacheDriver diff --git a/psalm.xml b/psalm.xml index eba8107cc7e..f81572f3045 100644 --- a/psalm.xml +++ b/psalm.xml @@ -1,6 +1,7 @@ - - - - - - - - - - - - - diff --git a/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php b/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php index 3ee350e15a0..00c3e754ef9 100644 --- a/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php @@ -21,7 +21,7 @@ class CacheLoggerChainTest extends DoctrineTestCase /** @var CacheLoggerChain */ private $logger; - /** @var MockObject|CacheLogger */ + /** @var CacheLogger&MockObject */ private $mock; protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php index accad3ce3f3..88f3fa10205 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php @@ -31,6 +31,7 @@ use Doctrine\Tests\OrmTestCase; use InvalidArgumentException; use LogicException; +use PHPUnit\Framework\MockObject\MockObject; use function assert; @@ -39,7 +40,7 @@ */ class DefaultCacheFactoryTest extends OrmTestCase { - /** @var CacheFactory */ + /** @var CacheFactory&MockObject */ private $factory; /** @var EntityManager */ diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/AbstractCollectionPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/AbstractCollectionPersisterTest.php index 59d8178cd06..75bded05593 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/AbstractCollectionPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/AbstractCollectionPersisterTest.php @@ -14,13 +14,14 @@ use Doctrine\ORM\Persisters\Collection\CollectionPersister; use Doctrine\Tests\Models\Cache\State; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\MockObject\MockObject; /** * @group DDC-2183 */ abstract class AbstractCollectionPersisterTest extends OrmTestCase { - /** @var Region */ + /** @var Region&MockObject */ protected $region; /** @var CollectionPersister */ @@ -70,6 +71,9 @@ protected function setUp(): void ->getMock(); } + /** + * @return Region&MockObject + */ protected function createRegion(): Region { return $this->getMockBuilder(Region::class) diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/AbstractEntityPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/AbstractEntityPersisterTest.php index 44c20d30489..b387e46826e 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/AbstractEntityPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/AbstractEntityPersisterTest.php @@ -17,16 +17,17 @@ use Doctrine\ORM\Query\ResultSetMappingBuilder; use Doctrine\Tests\Models\Cache\Country; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\MockObject\MockObject; /** * @group DDC-2183 */ abstract class AbstractEntityPersisterTest extends OrmTestCase { - /** @var Region */ + /** @var Region&MockObject */ protected $region; - /** @var EntityPersister */ + /** @var EntityPersister&MockObject */ protected $entityPersister; /** @var EntityManager */ @@ -45,6 +46,9 @@ protected function setUp(): void $this->entityPersister = $this->createMock(EntityPersister::class); } + /** + * @return Region&MockObject + */ protected function createRegion(): Region { return $this->createMock(Region::class); diff --git a/tests/Doctrine/Tests/ORM/Decorator/EntityManagerDecoratorTest.php b/tests/Doctrine/Tests/ORM/Decorator/EntityManagerDecoratorTest.php index 400dbfe42fb..4600871065d 100644 --- a/tests/Doctrine/Tests/ORM/Decorator/EntityManagerDecoratorTest.php +++ b/tests/Doctrine/Tests/ORM/Decorator/EntityManagerDecoratorTest.php @@ -32,7 +32,7 @@ class EntityManagerDecoratorTest extends TestCase 'lock', ]; - /** @var EntityManagerInterface|MockObject */ + /** @var EntityManagerInterface&MockObject */ private $wrapped; protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php index 9106f8e29a4..84c3a16bcbc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php @@ -7,7 +7,6 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Configuration; -use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadataInfo; @@ -28,6 +27,7 @@ use Doctrine\Tests\Models\Company\CompanyPerson; use Doctrine\Tests\OrmFunctionalTestCase; use InvalidArgumentException; +use PHPUnit\Framework\MockObject\MockObject; use ReflectionMethod; use Symfony\Component\Cache\Adapter\ArrayAdapter; @@ -221,7 +221,7 @@ public function testEntityManagerIsFilterEnabled(): void self::assertFalse($em->getFilters()->isEnabled('foo_filter')); } - protected function configureFilters($em): void + private function configureFilters(EntityManagerInterface $em): void { // Add filters to the configuration of the EM $config = $em->getConfiguration(); @@ -229,23 +229,30 @@ protected function configureFilters($em): void $config->addFilter('soft_delete', '\Doctrine\Tests\ORM\Functional\MySoftDeleteFilter'); } - protected function getMockConnection(): Connection + /** + * @return Connection&MockObject + */ + private function getMockConnection(): Connection { - // Setup connection mock return $this->createMock(Connection::class); } - protected function getMockEntityManager(): EntityManagerInterface + /** + * @return EntityManagerInterface&MockObject + */ + private function getMockEntityManager(): EntityManagerInterface { - // Setup entity manager mock - return $this->createMock(EntityManager::class); + return $this->createMock(EntityManagerInterface::class); } - protected function addMockFilterCollection(EntityManagerInterface $em): FilterCollection + /** + * @psalm-param EntityManagerInterface&MockObject $em + * + * @return FilterCollection&MockObject + */ + private function addMockFilterCollection(EntityManagerInterface $em): FilterCollection { - $filterCollection = $this->getMockBuilder(FilterCollection::class) - ->disableOriginalConstructor() - ->getMock(); + $filterCollection = $this->createMock(FilterCollection::class); $em->expects(self::any()) ->method('getFilters') diff --git a/tests/Doctrine/Tests/ORM/Hydration/AbstractHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/AbstractHydratorTest.php index 79fc2dd4170..786bda81f39 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/AbstractHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/AbstractHydratorTest.php @@ -22,16 +22,16 @@ */ class AbstractHydratorTest extends OrmFunctionalTestCase { - /** @var EventManager|MockObject */ + /** @var EventManager&MockObject */ private $mockEventManager; - /** @var Result|MockObject */ + /** @var Result&MockObject */ private $mockResult; - /** @var ResultSetMapping|MockObject */ + /** @var ResultSetMapping&MockObject */ private $mockResultMapping; - /** @var AbstractHydrator */ + /** @var AbstractHydrator&MockObject */ private $hydrator; protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php b/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php index e59122e422e..e3b0b2e1aca 100644 --- a/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php +++ b/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php @@ -24,10 +24,10 @@ */ class HydrationCompleteHandlerTest extends TestCase { - /** @var ListenersInvoker|MockObject */ + /** @var ListenersInvoker&MockObject */ private $listenersInvoker; - /** @var EntityManagerInterface|MockObject */ + /** @var EntityManagerInterface&MockObject */ private $entityManager; /** @var HydrationCompleteHandler */ diff --git a/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php b/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php index 7369b5165c8..3aff55b38b1 100644 --- a/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php @@ -17,7 +17,7 @@ */ class LazyCriteriaCollectionTest extends TestCase { - /** @var EntityPersister|MockObject */ + /** @var EntityPersister&MockObject */ private $persister; /** @var Criteria */ diff --git a/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php b/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php index 649433e129e..052d9b8511c 100644 --- a/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Repository; +use Closure; use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadata; @@ -13,8 +14,6 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use function assert; - /** * Tests for {@see \Doctrine\ORM\Repository\DefaultRepositoryFactory} * @@ -22,10 +21,10 @@ */ class DefaultRepositoryFactoryTest extends TestCase { - /** @var EntityManagerInterface|MockObject */ + /** @var EntityManagerInterface&MockObject */ private $entityManager; - /** @var Configuration|MockObject */ + /** @var Configuration&MockObject */ private $configuration; /** @var DefaultRepositoryFactory */ @@ -48,7 +47,7 @@ public function testCreatesRepositoryFromDefaultRepositoryClass(): void $this->entityManager ->expects(self::any()) ->method('getClassMetadata') - ->will(self::returnCallback([$this, 'buildClassMetadata'])); + ->will(self::returnCallback(Closure::fromCallable([$this, 'buildClassMetadata']))); self::assertInstanceOf( DDC869PaymentRepository::class, @@ -61,7 +60,7 @@ public function testCreatedRepositoriesAreCached(): void $this->entityManager ->expects(self::any()) ->method('getClassMetadata') - ->will(self::returnCallback([$this, 'buildClassMetadata'])); + ->will(self::returnCallback(Closure::fromCallable([$this, 'buildClassMetadata']))); self::assertSame( $this->repositoryFactory->getRepository($this->entityManager, self::class), @@ -92,11 +91,11 @@ public function testCachesDistinctRepositoriesPerDistinctEntityManager(): void $em1->expects(self::any()) ->method('getClassMetadata') - ->will(self::returnCallback([$this, 'buildClassMetadata'])); + ->will(self::returnCallback(Closure::fromCallable([$this, 'buildClassMetadata']))); $em2->expects(self::any()) ->method('getClassMetadata') - ->will(self::returnCallback([$this, 'buildClassMetadata'])); + ->will(self::returnCallback(Closure::fromCallable([$this, 'buildClassMetadata']))); $repo1 = $this->repositoryFactory->getRepository($em1, self::class); $repo2 = $this->repositoryFactory->getRepository($em2, self::class); @@ -108,15 +107,11 @@ public function testCachesDistinctRepositoriesPerDistinctEntityManager(): void } /** - * @return MockObject|ClassMetadata - * - * @private + * @return ClassMetadata&MockObject */ - public function buildClassMetadata(string $className) + private function buildClassMetadata(string $className): ClassMetadata { $metadata = $this->createMock(ClassMetadata::class); - assert($metadata instanceof ClassMetadata || $metadata instanceof MockObject); - $metadata->expects(self::any())->method('getName')->will(self::returnValue($className)); $metadata->customRepositoryClassName = null; @@ -125,7 +120,7 @@ public function buildClassMetadata(string $className) } /** - * @return EntityManagerInterface|MockObject + * @return EntityManagerInterface&MockObject */ private function createEntityManager(): EntityManagerInterface { diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php index 2ce23abdd02..db82f25c945 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php @@ -13,14 +13,15 @@ use Doctrine\Tests\Mocks\ConnectionMock; use Doctrine\Tests\Mocks\DriverMock; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\MockObject\MockObject; class PaginatorTest extends OrmTestCase { - /** @var Connection */ + /** @var Connection&MockObject */ private $connection; - /** @var EntityManagerInterface */ + /** @var EntityManagerInterface&MockObject */ private $em; - /** @var AbstractHydrator */ + /** @var AbstractHydrator&MockObject */ private $hydrator; protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index 058e393fa21..446bd79c3d8 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -60,7 +60,7 @@ class UnitOfWorkTest extends OrmTestCase /** * Provides a sequence mock to the UnitOfWork * - * @var ConnectionMock + * @var ConnectionMock&MockObject */ private $_connectionMock; @@ -71,7 +71,7 @@ class UnitOfWorkTest extends OrmTestCase */ private $_emMock; - /** @var EventManager|MockObject */ + /** @var EventManager&MockObject */ private $eventManager; protected function setUp(): void