diff --git a/lib/Doctrine/ORM/Cache.php b/lib/Doctrine/ORM/Cache.php index cee9cbcf56..52c3903a0b 100644 --- a/lib/Doctrine/ORM/Cache.php +++ b/lib/Doctrine/ORM/Cache.php @@ -141,6 +141,8 @@ public function containsQuery($regionName); * Evicts all cached query results under the given name, or default query cache if the region name is NULL. * * @param string|null $regionName The cache name associated to the queries being cached. + * + * @return void */ public function evictQueryRegion($regionName = null); diff --git a/lib/Doctrine/ORM/Cache/AssociationCacheEntry.php b/lib/Doctrine/ORM/Cache/AssociationCacheEntry.php index 24c63152e7..f10618fb2b 100644 --- a/lib/Doctrine/ORM/Cache/AssociationCacheEntry.php +++ b/lib/Doctrine/ORM/Cache/AssociationCacheEntry.php @@ -10,20 +10,26 @@ class AssociationCacheEntry implements CacheEntry { /** + * The entity identifier + * * @readonly Public only for performance reasons, it should be considered immutable. - * @var array The entity identifier + * @var array */ public $identifier; /** + * The entity class name + * * @readonly Public only for performance reasons, it should be considered immutable. - * @var string The entity class name + * @var string + * @psalm-var class-string */ public $class; /** * @param string $class The entity class. * @param array $identifier The entity identifier. + * @psalm-param class-string $class */ public function __construct($class, array $identifier) { diff --git a/lib/Doctrine/ORM/Cache/CacheException.php b/lib/Doctrine/ORM/Cache/CacheException.php index 619f266239..0c3403609a 100644 --- a/lib/Doctrine/ORM/Cache/CacheException.php +++ b/lib/Doctrine/ORM/Cache/CacheException.php @@ -25,6 +25,8 @@ public static function updateReadOnlyCollection($sourceEntity, $fieldName) } /** + * @deprecated This method is not used anymore. + * * @param string $entityName * * @return CacheException @@ -45,6 +47,8 @@ public static function nonCacheableEntity($entityName) } /** + * @deprecated This method is not used anymore. + * * @param string $entityName * @param string $field * diff --git a/lib/Doctrine/ORM/Cache/CacheFactory.php b/lib/Doctrine/ORM/Cache/CacheFactory.php index 79bb2e65c3..60bd582c1d 100644 --- a/lib/Doctrine/ORM/Cache/CacheFactory.php +++ b/lib/Doctrine/ORM/Cache/CacheFactory.php @@ -31,9 +31,7 @@ public function buildCachedEntityPersister(EntityManagerInterface $em, EntityPer /** * Build a collection persister for the given relation mapping. * - * @param EntityManagerInterface $em The entity manager. - * @param CollectionPersister $persister The collection persister that will be cached. - * @param mixed[] $mapping The association mapping. + * @param mixed[] $mapping The association mapping. * * @return CachedCollectionPersister */ @@ -42,8 +40,7 @@ public function buildCachedCollectionPersister(EntityManagerInterface $em, Colle /** * Build a query cache based on the given region name * - * @param EntityManagerInterface $em The Entity manager. - * @param string $regionName The region name. + * @param string|null $regionName The region name. * * @return QueryCache The built query cache. */ @@ -52,9 +49,6 @@ public function buildQueryCache(EntityManagerInterface $em, $regionName = null); /** * Build an entity hydrator * - * @param EntityManagerInterface $em The Entity manager. - * @param ClassMetadata $metadata The entity metadata. - * * @return EntityHydrator The built entity hydrator. */ public function buildEntityHydrator(EntityManagerInterface $em, ClassMetadata $metadata); @@ -62,8 +56,7 @@ public function buildEntityHydrator(EntityManagerInterface $em, ClassMetadata $m /** * Build a collection hydrator * - * @param EntityManagerInterface $em The Entity manager. - * @param mixed[] $mapping The association mapping. + * @param mixed[] $mapping The association mapping. * * @return CollectionHydrator The built collection hydrator. */ diff --git a/lib/Doctrine/ORM/Cache/CacheKey.php b/lib/Doctrine/ORM/Cache/CacheKey.php index e548fd5b0f..5f4305d686 100644 --- a/lib/Doctrine/ORM/Cache/CacheKey.php +++ b/lib/Doctrine/ORM/Cache/CacheKey.php @@ -11,8 +11,10 @@ abstract class CacheKey { /** + * Unique identifier + * * @readonly Public only for performance reasons, it should be considered immutable. - * @var string Unique identifier + * @var string */ public $hash; } diff --git a/lib/Doctrine/ORM/Cache/CollectionCacheEntry.php b/lib/Doctrine/ORM/Cache/CollectionCacheEntry.php index 7531e83998..fe3eb3d5ae 100644 --- a/lib/Doctrine/ORM/Cache/CollectionCacheEntry.php +++ b/lib/Doctrine/ORM/Cache/CollectionCacheEntry.php @@ -10,8 +10,10 @@ class CollectionCacheEntry implements CacheEntry { /** + * The list of entity identifiers hold by the collection + * * @readonly Public only for performance reasons, it should be considered immutable. - * @var CacheKey[] The list of entity identifiers hold by the collection + * @var CacheKey[] */ public $identifiers; diff --git a/lib/Doctrine/ORM/Cache/CollectionCacheKey.php b/lib/Doctrine/ORM/Cache/CollectionCacheKey.php index e2e8de94ce..ec2c35db99 100644 --- a/lib/Doctrine/ORM/Cache/CollectionCacheKey.php +++ b/lib/Doctrine/ORM/Cache/CollectionCacheKey.php @@ -15,20 +15,27 @@ class CollectionCacheKey extends CacheKey { /** + * The owner entity identifier + * * @readonly Public only for performance reasons, it should be considered immutable. - * @var array The owner entity identifier + * @var array */ public $ownerIdentifier; /** + * The owner entity class + * * @readonly Public only for performance reasons, it should be considered immutable. - * @var string The owner entity class + * @var string + * @psalm-var class-string */ public $entityClass; /** + * The association name + * * @readonly Public only for performance reasons, it should be considered immutable. - * @var string The association name + * @var string */ public $association; @@ -36,6 +43,7 @@ class CollectionCacheKey extends CacheKey * @param string $entityClass The entity class. * @param string $association The field name that represents the association. * @param array $ownerIdentifier The identifier of the owning entity. + * @psalm-param class-string $entityClass */ public function __construct($entityClass, $association, array $ownerIdentifier) { diff --git a/lib/Doctrine/ORM/Cache/CollectionHydrator.php b/lib/Doctrine/ORM/Cache/CollectionHydrator.php index d0842f3c5b..5d327a3198 100644 --- a/lib/Doctrine/ORM/Cache/CollectionHydrator.php +++ b/lib/Doctrine/ORM/Cache/CollectionHydrator.php @@ -14,8 +14,6 @@ interface CollectionHydrator { /** - * @param ClassMetadata $metadata The entity metadata. - * @param CollectionCacheKey $key The cached collection key. * @param array|mixed[]|Collection $collection The collection. * * @return CollectionCacheEntry @@ -23,11 +21,6 @@ interface CollectionHydrator public function buildCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key, $collection); /** - * @param ClassMetadata $metadata The owning entity metadata. - * @param CollectionCacheKey $key The cached collection key. - * @param CollectionCacheEntry $entry The cached collection entry. - * @param PersistentCollection $collection The collection to load the cache into. - * * @return mixed[]|null */ public function loadCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key, CollectionCacheEntry $entry, PersistentCollection $collection); diff --git a/lib/Doctrine/ORM/Cache/DefaultCache.php b/lib/Doctrine/ORM/Cache/DefaultCache.php index 3a754f08fe..5ca9eab822 100644 --- a/lib/Doctrine/ORM/Cache/DefaultCache.php +++ b/lib/Doctrine/ORM/Cache/DefaultCache.php @@ -29,7 +29,10 @@ class DefaultCache implements Cache /** @var CacheFactory */ private $cacheFactory; - /** @var QueryCache[] */ + /** + * @var QueryCache[] + * @psalm-var array + */ private $queryCaches = []; /** @var QueryCache|null */ @@ -260,8 +263,7 @@ public function getQueryCache($regionName = null) } /** - * @param ClassMetadata $metadata The entity metadata. - * @param mixed $identifier The entity identifier. + * @param mixed $identifier The entity identifier. */ private function buildEntityCacheKey(ClassMetadata $metadata, $identifier): EntityCacheKey { @@ -273,9 +275,7 @@ private function buildEntityCacheKey(ClassMetadata $metadata, $identifier): Enti } /** - * @param ClassMetadata $metadata The entity metadata. - * @param string $association The field name that represents the association. - * @param mixed $ownerIdentifier The identifier of the owning entity. + * @param mixed $ownerIdentifier The identifier of the owning entity. */ private function buildCollectionCacheKey( ClassMetadata $metadata, @@ -290,8 +290,7 @@ private function buildCollectionCacheKey( } /** - * @param ClassMetadata $metadata The entity metadata. - * @param mixed $identifier The entity identifier. + * @param mixed $identifier The entity identifier. * * @return array */ diff --git a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php index 357004cd12..2ca00cfe10 100644 --- a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php +++ b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php @@ -384,7 +384,8 @@ private function storeAssociationCache(QueryCacheKey $key, array $assoc, $assocV /** * @param object $entity * - * @return array|object + * @return mixed[]|object|null + * @psalm-return list|object|null */ private function getAssociationValue( ResultSetMapping $rsm, @@ -411,10 +412,11 @@ private function getAssociationValue( } /** - * @param mixed $value - * @param array $path + * @param mixed $value + * @psalm-param array $path * - * @return mixed + * @return mixed[]|object|null + * @psalm-return list|object|null */ private function getAssociationPathValue($value, array $path) { diff --git a/lib/Doctrine/ORM/Cache/EntityCacheEntry.php b/lib/Doctrine/ORM/Cache/EntityCacheEntry.php index 74bf95f34b..6a769111c4 100644 --- a/lib/Doctrine/ORM/Cache/EntityCacheEntry.php +++ b/lib/Doctrine/ORM/Cache/EntityCacheEntry.php @@ -14,14 +14,18 @@ class EntityCacheEntry implements CacheEntry { /** + * The entity map data + * * @readonly Public only for performance reasons, it should be considered immutable. - * @var array The entity map data + * @var array */ public $data; /** + * The entity class name + * * @readonly Public only for performance reasons, it should be considered immutable. - * @var string The entity class name + * @var string * @psalm-var class-string */ public $class; diff --git a/lib/Doctrine/ORM/Cache/EntityCacheKey.php b/lib/Doctrine/ORM/Cache/EntityCacheKey.php index ad7c43b7fc..730914d697 100644 --- a/lib/Doctrine/ORM/Cache/EntityCacheKey.php +++ b/lib/Doctrine/ORM/Cache/EntityCacheKey.php @@ -15,20 +15,26 @@ class EntityCacheKey extends CacheKey { /** + * The entity identifier + * * @readonly Public only for performance reasons, it should be considered immutable. - * @var array The entity identifier + * @var array */ public $identifier; /** + * The entity class name + * * @readonly Public only for performance reasons, it should be considered immutable. - * @var string The entity class name + * @var string + * @psalm-var class-string */ public $entityClass; /** * @param string $entityClass The entity class name. In a inheritance hierarchy it should always be the root entity class. * @param array $identifier The entity identifier + * @psalm-param class-string $entityClass */ public function __construct($entityClass, array $identifier) { diff --git a/lib/Doctrine/ORM/Cache/Logging/CacheLogger.php b/lib/Doctrine/ORM/Cache/Logging/CacheLogger.php index 9284092a2c..60db34a998 100644 --- a/lib/Doctrine/ORM/Cache/Logging/CacheLogger.php +++ b/lib/Doctrine/ORM/Cache/Logging/CacheLogger.php @@ -18,6 +18,8 @@ interface CacheLogger * * @param string $regionName The name of the cache region. * @param EntityCacheKey $key The cache key of the entity. + * + * @return void */ public function entityCachePut($regionName, EntityCacheKey $key); @@ -26,6 +28,8 @@ public function entityCachePut($regionName, EntityCacheKey $key); * * @param string $regionName The name of the cache region. * @param EntityCacheKey $key The cache key of the entity. + * + * @return void */ public function entityCacheHit($regionName, EntityCacheKey $key); @@ -34,6 +38,8 @@ public function entityCacheHit($regionName, EntityCacheKey $key); * * @param string $regionName The name of the cache region. * @param EntityCacheKey $key The cache key of the entity. + * + * @return void */ public function entityCacheMiss($regionName, EntityCacheKey $key); @@ -42,6 +48,8 @@ public function entityCacheMiss($regionName, EntityCacheKey $key); * * @param string $regionName The name of the cache region. * @param CollectionCacheKey $key The cache key of the collection. + * + * @return void */ public function collectionCachePut($regionName, CollectionCacheKey $key); @@ -50,6 +58,8 @@ public function collectionCachePut($regionName, CollectionCacheKey $key); * * @param string $regionName The name of the cache region. * @param CollectionCacheKey $key The cache key of the collection. + * + * @return void */ public function collectionCacheHit($regionName, CollectionCacheKey $key); @@ -58,6 +68,8 @@ public function collectionCacheHit($regionName, CollectionCacheKey $key); * * @param string $regionName The name of the cache region. * @param CollectionCacheKey $key The cache key of the collection. + * + * @return void */ public function collectionCacheMiss($regionName, CollectionCacheKey $key); @@ -66,6 +78,8 @@ public function collectionCacheMiss($regionName, CollectionCacheKey $key); * * @param string $regionName The name of the cache region. * @param QueryCacheKey $key The cache key of the query. + * + * @return void */ public function queryCachePut($regionName, QueryCacheKey $key); @@ -74,6 +88,8 @@ public function queryCachePut($regionName, QueryCacheKey $key); * * @param string $regionName The name of the cache region. * @param QueryCacheKey $key The cache key of the query. + * + * @return void */ public function queryCacheHit($regionName, QueryCacheKey $key); @@ -82,6 +98,8 @@ public function queryCacheHit($regionName, QueryCacheKey $key); * * @param string $regionName The name of the cache region. * @param QueryCacheKey $key The cache key of the query. + * + * @return void */ public function queryCacheMiss($regionName, QueryCacheKey $key); } diff --git a/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php b/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php index e51deec7d4..67b7bf9e3b 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php @@ -224,6 +224,8 @@ public function loadCriteria(PersistentCollection $collection, Criteria $criteri /** * Clears cache entries related to the current collection * + * @deprecated This method is not used anymore. + * * @return void */ protected function evictCollectionCache(PersistentCollection $collection) @@ -242,8 +244,11 @@ protected function evictCollectionCache(PersistentCollection $collection) } /** + * @deprecated This method is not used anymore. + * * @param string $targetEntity * @param object $element + * @psalm-param class-string $targetEntity * * @return void */ diff --git a/lib/Doctrine/ORM/Cache/QueryCacheEntry.php b/lib/Doctrine/ORM/Cache/QueryCacheEntry.php index a5436ec0e2..0bd18afc7b 100644 --- a/lib/Doctrine/ORM/Cache/QueryCacheEntry.php +++ b/lib/Doctrine/ORM/Cache/QueryCacheEntry.php @@ -12,20 +12,24 @@ class QueryCacheEntry implements CacheEntry { /** + * List of entity identifiers + * * @readonly Public only for performance reasons, it should be considered immutable. - * @var array List of entity identifiers + * @var array */ public $result; /** + * Time creation of this cache entry + * * @readonly Public only for performance reasons, it should be considered immutable. - * @var float Time creation of this cache entry + * @var float */ public $time; /** * @param array $result - * @param float $time + * @param float|null $time */ public function __construct($result, $time = null) { diff --git a/lib/Doctrine/ORM/Cache/QueryCacheKey.php b/lib/Doctrine/ORM/Cache/QueryCacheKey.php index 4a510fd8a4..a378c39c1c 100644 --- a/lib/Doctrine/ORM/Cache/QueryCacheKey.php +++ b/lib/Doctrine/ORM/Cache/QueryCacheKey.php @@ -12,8 +12,10 @@ class QueryCacheKey extends CacheKey { /** + * Cache key lifetime + * * @readonly Public only for performance reasons, it should be considered immutable. - * @var int Cache key lifetime + * @var int */ public $lifetime; diff --git a/lib/Doctrine/ORM/Cache/TimestampCacheEntry.php b/lib/Doctrine/ORM/Cache/TimestampCacheEntry.php index d212f3f6b8..cf67dd8224 100644 --- a/lib/Doctrine/ORM/Cache/TimestampCacheEntry.php +++ b/lib/Doctrine/ORM/Cache/TimestampCacheEntry.php @@ -18,7 +18,7 @@ class TimestampCacheEntry implements CacheEntry public $time; /** - * @param float $time + * @param float|null $time */ public function __construct($time = null) { diff --git a/lib/Doctrine/ORM/Cache/TimestampRegion.php b/lib/Doctrine/ORM/Cache/TimestampRegion.php index cb7a17580e..4f72a159ee 100644 --- a/lib/Doctrine/ORM/Cache/TimestampRegion.php +++ b/lib/Doctrine/ORM/Cache/TimestampRegion.php @@ -10,9 +10,9 @@ interface TimestampRegion extends Region { /** - * Update an specific key into the cache region. + * Update a specific key into the cache region. * - * @param CacheKey $key The key of the item to update the timestamp. + * @return void * * @throws LockException Indicates a problem accessing the region. */ diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 682ad3f475..5114898ff0 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -35,11 +35,6 @@ parameters: count: 2 path: lib/Doctrine/ORM/Cache/DefaultQueryCache.php - - - message: "#^Strict comparison using \\=\\=\\= between array\\\\|object and null will always evaluate to false\\.$#" - count: 1 - path: lib/Doctrine/ORM/Cache/DefaultQueryCache.php - - message: "#^Access to an undefined property Doctrine\\\\ORM\\\\Cache\\\\CacheEntry\\:\\:\\$identifiers\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 40d88026dd..8a0b37a0ef 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -40,11 +40,6 @@ (string) $cacheRegion - - - evictQueryRegion - - getTimestampRegion @@ -60,9 +55,6 @@ ! $association['type'] - - evictQueryRegion - getCacheFactory @@ -88,16 +80,12 @@ - + $assocKeys->identifiers[$assocIndex] $assocKeys->identifiers[$assocIndex] $cacheKeys->identifiers[$index] $cacheKeys->identifiers[$index] - $unCachedAssociationData->class - - $assocValue === null - $id @@ -119,55 +107,10 @@ storeEntityCache - - - $value->class - - - - - collectionCacheHit - collectionCacheMiss - collectionCachePut - entityCacheHit - entityCacheMiss - entityCachePut - queryCacheHit - queryCacheMiss - queryCachePut - - - - - collectionCacheHit - collectionCacheMiss - collectionCachePut - entityCacheHit - entityCacheMiss - entityCachePut - queryCacheHit - queryCacheMiss - queryCachePut - - - - - collectionCacheHit - collectionCacheMiss - collectionCachePut - entityCacheHit - entityCacheMiss - entityCachePut - queryCacheHit - queryCacheMiss - queryCachePut - - - + $cache $entityKey - $targetEntity $entry->identifiers @@ -255,11 +198,6 @@ CacheProvider - - - update - - (int) $defaultLifetime @@ -285,11 +223,6 @@ $timestamp->time - - - update - - $className diff --git a/tests/Doctrine/Tests/ORM/Cache/AbstractRegionTest.php b/tests/Doctrine/Tests/ORM/Cache/AbstractRegionTest.php index c9858700c3..140a4910eb 100644 --- a/tests/Doctrine/Tests/ORM/Cache/AbstractRegionTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/AbstractRegionTest.php @@ -14,11 +14,15 @@ use Symfony\Component\Cache\Adapter\ArrayAdapter; /** + * @template TRegion of Region * @group DDC-2183 */ abstract class AbstractRegionTest extends OrmFunctionalTestCase { - /** @var Region */ + /** + * @var Region + * @psalm-var TRegion + */ protected $region; /** @var CacheItemPoolInterface */ @@ -32,6 +36,7 @@ protected function setUp(): void $this->region = $this->createRegion(); } + /** @psalm-return TRegion */ abstract protected function createRegion(): Region; /** @psalm-return list */ diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php index 9b4db8c92d..d918aeaecd 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php @@ -16,11 +16,11 @@ use Doctrine\ORM\Cache\Persister\Entity\ReadWriteCachedEntityPersister; use Doctrine\ORM\Cache\Region\DefaultRegion; use Doctrine\ORM\Cache\RegionsConfiguration; -use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Persisters\Collection\OneToManyPersister; use Doctrine\ORM\Persisters\Entity\BasicEntityPersister; use Doctrine\Tests\Mocks\ConcurrentRegionMock; +use Doctrine\Tests\Mocks\EntityManagerMock; use Doctrine\Tests\Models\Cache\AttractionContactInfo; use Doctrine\Tests\Models\Cache\AttractionLocationInfo; use Doctrine\Tests\Models\Cache\City; @@ -39,7 +39,7 @@ class DefaultCacheFactoryTest extends OrmTestCase /** @var CacheFactory&MockObject */ private $factory; - /** @var EntityManagerInterface */ + /** @var EntityManagerMock */ private $em; /** @var RegionsConfiguration */ diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php index 3fc8a2b242..2c0a7cc919 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php @@ -10,7 +10,7 @@ use Doctrine\ORM\Cache\DefaultCache; use Doctrine\ORM\Cache\EntityCacheEntry; use Doctrine\ORM\Cache\EntityCacheKey; -use Doctrine\ORM\EntityManagerInterface; +use Doctrine\Tests\Mocks\EntityManagerMock; use Doctrine\Tests\Models\Cache\Country; use Doctrine\Tests\Models\Cache\State; use Doctrine\Tests\Models\CMS\CmsUser; @@ -25,10 +25,10 @@ */ class DefaultCacheTest extends OrmTestCase { - /** @var Cache */ + /** @var DefaultCache */ private $cache; - /** @var EntityManagerInterface */ + /** @var EntityManagerMock */ private $em; protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCollectionHydratorTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultCollectionHydratorTest.php index 4c366f280b..ca188471a9 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultCollectionHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultCollectionHydratorTest.php @@ -7,7 +7,6 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Cache\CollectionCacheEntry; use Doctrine\ORM\Cache\CollectionCacheKey; -use Doctrine\ORM\Cache\CollectionHydrator; use Doctrine\ORM\Cache\DefaultCollectionHydrator; use Doctrine\ORM\Cache\EntityCacheEntry; use Doctrine\ORM\Cache\EntityCacheKey; @@ -22,7 +21,7 @@ */ class DefaultCollectionHydratorTest extends OrmFunctionalTestCase { - /** @var CollectionHydrator */ + /** @var DefaultCollectionHydrator */ private $structure; protected function setUp(): void @@ -30,8 +29,7 @@ protected function setUp(): void $this->enableSecondLevelCache(); parent::setUp(); - $targetPersister = $this->_em->getUnitOfWork()->getEntityPersister(City::class); - $this->structure = new DefaultCollectionHydrator($this->_em, $targetPersister); + $this->structure = new DefaultCollectionHydrator($this->_em); } public function testImplementsCollectionEntryStructure(): void diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php index cae81dc113..eddbfd114e 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php @@ -17,6 +17,7 @@ use Doctrine\ORM\Query\ResultSetMappingBuilder; use Doctrine\Tests\Mocks\CacheEntryMock; use Doctrine\Tests\Mocks\CacheRegionMock; +use Doctrine\Tests\Mocks\EntityManagerMock; use Doctrine\Tests\Mocks\TimestampRegionMock; use Doctrine\Tests\Models\Cache\City; use Doctrine\Tests\Models\Cache\Country; @@ -37,29 +38,26 @@ class DefaultQueryCacheTest extends OrmTestCase /** @var DefaultQueryCache */ private $queryCache; - /** @var EntityManagerInterface */ + /** @var EntityManagerMock */ private $em; /** @var CacheRegionMock */ private $region; - /** @var CacheFactoryDefaultQueryCacheTest */ - private $cacheFactory; - protected function setUp(): void { parent::setUp(); $this->enableSecondLevelCache(); - $this->em = $this->getTestEntityManager(); - $this->region = new CacheRegionMock(); - $this->queryCache = new DefaultQueryCache($this->em, $this->region); - $this->cacheFactory = new CacheFactoryDefaultQueryCacheTest($this->queryCache, $this->region); + $this->em = $this->getTestEntityManager(); + $this->region = new CacheRegionMock(); + $this->queryCache = new DefaultQueryCache($this->em, $this->region); + $cacheFactory = new CacheFactoryDefaultQueryCacheTest($this->queryCache, $this->region); $this->em->getConfiguration() ->getSecondLevelCacheConfiguration() - ->setCacheFactory($this->cacheFactory); + ->setCacheFactory($cacheFactory); } public function testImplementQueryCache(): void diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php index d54e4d92c8..7bd2d1e2af 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php @@ -15,6 +15,7 @@ use function array_map; /** + * @extends AbstractRegionTest * @group DDC-2183 */ class DefaultRegionTest extends AbstractRegionTest diff --git a/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php b/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php index 0685c46adf..944b03ff1d 100644 --- a/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php @@ -5,7 +5,6 @@ namespace Doctrine\Tests\ORM\Cache; use Doctrine\ORM\Cache\CacheKey; -use Doctrine\ORM\Cache\ConcurrentRegion; use Doctrine\ORM\Cache\Lock; use Doctrine\ORM\Cache\Region; use Doctrine\ORM\Cache\Region\DefaultRegion; @@ -30,13 +29,11 @@ use const E_WARNING; /** + * @extends AbstractRegionTest * @group DDC-2183 */ class FileLockRegionTest extends AbstractRegionTest { - /** @var ConcurrentRegion */ - protected $region; - /** @var string */ protected $directory; @@ -45,7 +42,7 @@ public function tearDown(): void $this->cleanTestDirectory($this->directory); } - private function getFileName(ConcurrentRegion $region, CacheKey $key): string + private function getFileName(FileLockRegion $region, CacheKey $key): string { $reflection = new ReflectionMethod($region, 'getLockFileName'); @@ -259,15 +256,16 @@ public function testHandlesScanErrorsGracefullyOnEvictAll(): void $reflectionDirectory->setAccessible(true); $reflectionDirectory->setValue($region, str_repeat('a', 10000)); - set_error_handler(static function (): void { + set_error_handler(static function (): bool { + return true; }, E_WARNING); - self::assertTrue($region->evictAll()); - restore_error_handler(); + try { + self::assertTrue($region->evictAll()); + } finally { + restore_error_handler(); + } } - /** - * @param string|null $path directory to clean - */ private function cleanTestDirectory(?string $path): void { $path = $path ?: $this->directory; diff --git a/tests/Doctrine/Tests/ORM/Cache/MultiGetRegionTest.php b/tests/Doctrine/Tests/ORM/Cache/MultiGetRegionTest.php index 4ade1ec9c3..53b426bdb0 100644 --- a/tests/Doctrine/Tests/ORM/Cache/MultiGetRegionTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/MultiGetRegionTest.php @@ -10,6 +10,9 @@ use Doctrine\Tests\Mocks\CacheEntryMock; use Doctrine\Tests\Mocks\CacheKeyMock; +/** + * @extends AbstractRegionTest + */ class MultiGetRegionTest extends AbstractRegionTest { protected function createRegion(): Region