diff --git a/.github/workflows/coding-standard.yml b/.github/workflows/coding-standard.yml index 5ca4f70d055..05cf50375f5 100644 --- a/.github/workflows/coding-standard.yml +++ b/.github/workflows/coding-standard.yml @@ -29,14 +29,14 @@ jobs: - name: "Install dependencies with Composer" uses: "ramsey/composer-install@v1" - - name: "Install git-phpcs" - run: "wget https://github.com/diff-sniffer/git/releases/download/0.3.2/git-phpcs.phar" + - name: "Install diff-sniffer" + run: "wget https://github.com/diff-sniffer/diff-sniffer/releases/download/0.5.1/diff-sniffer.phar" - name: "Fetch head branch" run: "git remote set-branches --add origin $GITHUB_BASE_REF && git fetch origin $GITHUB_BASE_REF" - - name: "Run git-phpcs" - run: "php git-phpcs.phar origin/$GITHUB_BASE_REF...$GITHUB_SHA --report=checkstyle | cs2pr" + - name: "Run diff-sniffer" + run: "php diff-sniffer.phar origin/$GITHUB_BASE_REF...$GITHUB_SHA --report=checkstyle | cs2pr" - name: "Run phpcbf" run: "vendor/bin/phpcbf" diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index 2ba30bc4fa8..7e54820d01a 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -795,7 +795,7 @@ public function getResult($hydrationMode = self::HYDRATE_OBJECT) * * Alias for execute(null, HYDRATE_ARRAY). * - * @return array + * @return array */ public function getArrayResult() { @@ -807,7 +807,7 @@ public function getArrayResult() * * Alias for execute(null, HYDRATE_SCALAR). * - * @return array + * @return array */ public function getScalarResult() { @@ -937,7 +937,7 @@ public function hasHint($name) /** * Return the key value map of query hints that are currently set. * - * @return array + * @return array */ public function getHints() { @@ -950,8 +950,8 @@ public function getHints() * * @deprecated * - * @param ArrayCollection|array|null $parameters The query parameters. - * @param string|int|null $hydrationMode The hydration mode to use. + * @param ArrayCollection|mixed[]|null $parameters The query parameters. + * @param string|int|null $hydrationMode The hydration mode to use. * * @return IterableResult */ @@ -1024,8 +1024,8 @@ public function execute($parameters = null, $hydrationMode = null) /** * Execute query ignoring second level cache. * - * @param ArrayCollection|array|null $parameters - * @param string|int|null $hydrationMode + * @param ArrayCollection|mixed[]|null $parameters + * @param string|int|null $hydrationMode * * @return mixed */ @@ -1083,8 +1083,8 @@ private function executeIgnoreQueryCache($parameters = null, $hydrationMode = nu /** * Load from second level cache or executes the query and put into cache. * - * @param ArrayCollection|array|null $parameters - * @param string|int|null $hydrationMode + * @param ArrayCollection|mixed[]|null $parameters + * @param string|int|null $hydrationMode * * @return mixed */ @@ -1224,9 +1224,11 @@ protected function getHash() $query = $this->getSQL(); $hints = $this->getHints(); $params = array_map(function (Parameter $parameter) { + $value = $parameter->getValue(); + // Small optimization - // Does not invoke processParameterValue for scalar values - if (is_scalar($value = $parameter->getValue())) { + // Does not invoke processParameterValue for scalar value + if (is_scalar($value)) { return $value; } diff --git a/lib/Doctrine/ORM/Cache/AssociationCacheEntry.php b/lib/Doctrine/ORM/Cache/AssociationCacheEntry.php index e3db6e0af48..1703eee4c16 100644 --- a/lib/Doctrine/ORM/Cache/AssociationCacheEntry.php +++ b/lib/Doctrine/ORM/Cache/AssociationCacheEntry.php @@ -28,7 +28,7 @@ class AssociationCacheEntry implements CacheEntry /** * READ-ONLY: Public only for performance reasons, it should be considered immutable. * - * @var array The entity identifier + * @var array The entity identifier */ public $identifier; @@ -40,8 +40,8 @@ class AssociationCacheEntry implements CacheEntry public $class; /** - * @param string $class The entity class. - * @param array $identifier The entity identifier. + * @param string $class The entity class. + * @param array $identifier The entity identifier. */ public function __construct($class, array $identifier) { @@ -54,7 +54,7 @@ public function __construct($class, array $identifier) * * This method allow Doctrine\Common\Cache\PhpFileCache compatibility * - * @param array $values array containing property values + * @param array $values array containing property values * * @return AssociationCacheEntry */ diff --git a/lib/Doctrine/ORM/Cache/CacheFactory.php b/lib/Doctrine/ORM/Cache/CacheFactory.php index 6839b043d81..c880fca81d8 100644 --- a/lib/Doctrine/ORM/Cache/CacheFactory.php +++ b/lib/Doctrine/ORM/Cache/CacheFactory.php @@ -88,7 +88,7 @@ public function buildCollectionHydrator(EntityManagerInterface $em, array $mappi /** * Build a cache region * - * @param array $cache The cache configuration. + * @param array $cache The cache configuration. * * @return Region The cache region. */ diff --git a/lib/Doctrine/ORM/Cache/CollectionCacheEntry.php b/lib/Doctrine/ORM/Cache/CollectionCacheEntry.php index 38b49b897ec..9bcf5b5567c 100644 --- a/lib/Doctrine/ORM/Cache/CollectionCacheEntry.php +++ b/lib/Doctrine/ORM/Cache/CollectionCacheEntry.php @@ -45,7 +45,7 @@ public function __construct(array $identifiers) * * This method allows for Doctrine\Common\Cache\PhpFileCache compatibility * - * @param array $values array containing property values + * @param array $values array containing property values * * @return CollectionCacheEntry */ diff --git a/lib/Doctrine/ORM/Cache/CollectionCacheKey.php b/lib/Doctrine/ORM/Cache/CollectionCacheKey.php index bfeee8c31c1..91a2ae9e59f 100644 --- a/lib/Doctrine/ORM/Cache/CollectionCacheKey.php +++ b/lib/Doctrine/ORM/Cache/CollectionCacheKey.php @@ -33,7 +33,7 @@ class CollectionCacheKey extends CacheKey /** * READ-ONLY: Public only for performance reasons, it should be considered immutable. * - * @var array The owner entity identifier + * @var array The owner entity identifier */ public $ownerIdentifier; @@ -52,9 +52,9 @@ class CollectionCacheKey extends CacheKey public $association; /** - * @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. + * @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. */ public function __construct($entityClass, $association, array $ownerIdentifier) { diff --git a/lib/Doctrine/ORM/Cache/CollectionHydrator.php b/lib/Doctrine/ORM/Cache/CollectionHydrator.php index 87a042eff9b..0eb47e65d51 100644 --- a/lib/Doctrine/ORM/Cache/CollectionHydrator.php +++ b/lib/Doctrine/ORM/Cache/CollectionHydrator.php @@ -44,7 +44,7 @@ public function buildCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key * @param CollectionCacheEntry $entry The cached collection entry. * @param PersistentCollection $collection The collection to load the cache into. * - * @return array + * @return mixed[] */ 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 f8b7b46a001..54c933799cc 100644 --- a/lib/Doctrine/ORM/Cache/DefaultCache.php +++ b/lib/Doctrine/ORM/Cache/DefaultCache.php @@ -310,7 +310,7 @@ private function buildCollectionCacheKey(ClassMetadata $metadata, $association, * @param ClassMetadata $metadata The entity metadata. * @param mixed $identifier The entity identifier. * - * @return array + * @return array */ private function toIdentifierArray(ClassMetadata $metadata, $identifier) { diff --git a/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php b/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php index a4b16451ba6..99a2bd4e618 100644 --- a/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php +++ b/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php @@ -78,13 +78,13 @@ public function loadCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key, $targetRegion = $targetPersister->getCacheRegion(); $list = []; + /** @var EntityCacheEntry[]|null $entityEntries */ $entityEntries = $targetRegion->getMultiple($entry); if ($entityEntries === null) { return null; } - /** @var EntityCacheEntry[] $entityEntries */ foreach ($entityEntries as $index => $entityEntry) { $list[$index] = $this->uow->createEntity($entityEntry->class, $entityEntry->resolveAssociationEntries($this->em), self::$hints); } diff --git a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php index f2884b2f29a..8d31931dbac 100644 --- a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php +++ b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php @@ -151,7 +151,10 @@ public function get(QueryCacheKey $key, ResultSetMapping $rsm, array $hints = [] $assocMetadata = $this->em->getClassMetadata($assoc['targetEntity']); if ($assoc['type'] & ClassMetadata::TO_ONE) { - if (($assocEntry = $assocRegion->get($assocKey = new EntityCacheKey($assocMetadata->rootEntityName, $assoc['identifier']))) === null) { + $assocKey = new EntityCacheKey($assocMetadata->rootEntityName, $assoc['identifier']); + $assocEntry = $assocRegion->get($assocKey); + + if ($assocEntry === null) { if ($this->cacheLogger !== null) { $this->cacheLogger->entityCacheMiss($assocRegion->getName(), $assocKey); } @@ -398,7 +401,7 @@ private function storeAssociationCache(QueryCacheKey $key, array $assoc, $assocV * @param string $assocAlias * @param object $entity * - * @return array|object + * @return array|object */ private function getAssociationValue(ResultSetMapping $rsm, $assocAlias, $entity) { @@ -422,10 +425,10 @@ private function getAssociationValue(ResultSetMapping $rsm, $assocAlias, $entity } /** - * @param mixed $value - * @param array $path + * @param mixed $value + * @param array $path * - * @return array|object|null + * @return array|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 81b00ff72c2..ac95cb8df7b 100644 --- a/lib/Doctrine/ORM/Cache/EntityCacheEntry.php +++ b/lib/Doctrine/ORM/Cache/EntityCacheEntry.php @@ -32,7 +32,7 @@ class EntityCacheEntry implements CacheEntry /** * READ-ONLY: Public only for performance reasons, it should be considered immutable. * - * @var array The entity map data + * @var array The entity map data */ public $data; @@ -44,8 +44,8 @@ class EntityCacheEntry implements CacheEntry public $class; /** - * @param string $class The entity class. - * @param array $data The entity data. + * @param string $class The entity class. + * @param array $data The entity data. */ public function __construct($class, array $data) { @@ -58,7 +58,7 @@ public function __construct($class, array $data) * * This method allow Doctrine\Common\Cache\PhpFileCache compatibility * - * @param array $values array containing property values + * @param array $values array containing property values * * @return EntityCacheEntry */ @@ -70,7 +70,7 @@ public static function __set_state(array $values) /** * Retrieves the entity data resolving cache entries * - * @return array + * @return array */ public function resolveAssociationEntries(EntityManagerInterface $em) { diff --git a/lib/Doctrine/ORM/Cache/EntityCacheKey.php b/lib/Doctrine/ORM/Cache/EntityCacheKey.php index ee2d1471f67..e9aef0bfb09 100644 --- a/lib/Doctrine/ORM/Cache/EntityCacheKey.php +++ b/lib/Doctrine/ORM/Cache/EntityCacheKey.php @@ -33,7 +33,7 @@ class EntityCacheKey extends CacheKey /** * READ-ONLY: Public only for performance reasons, it should be considered immutable. * - * @var array The entity identifier + * @var array The entity identifier */ public $identifier; @@ -45,8 +45,8 @@ class EntityCacheKey extends CacheKey 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 + * @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 */ public function __construct($entityClass, array $identifier) { diff --git a/lib/Doctrine/ORM/Cache/Logging/StatisticsCacheLogger.php b/lib/Doctrine/ORM/Cache/Logging/StatisticsCacheLogger.php index 879c3eeb27f..6234063f164 100644 --- a/lib/Doctrine/ORM/Cache/Logging/StatisticsCacheLogger.php +++ b/lib/Doctrine/ORM/Cache/Logging/StatisticsCacheLogger.php @@ -167,7 +167,7 @@ public function getRegionPutCount($regionName) } /** - * @return array + * @return array */ public function getRegionsMiss() { @@ -175,7 +175,7 @@ public function getRegionsMiss() } /** - * @return array + * @return array */ public function getRegionsHit() { @@ -183,7 +183,7 @@ public function getRegionsHit() } /** - * @return array + * @return array */ public function getRegionsPut() { diff --git a/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php b/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php index 941a9b8a2e2..7c43a965470 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php @@ -128,15 +128,13 @@ public function getTargetEntityMetadata() */ public function loadCollectionCache(PersistentCollection $collection, CollectionCacheKey $key) { - if (($cache = $this->region->get($key)) === null) { - return null; - } + $cache = $this->region->get($key); - if (($cache = $this->hydrator->loadCacheEntry($this->sourceEntity, $key, $cache, $collection)) === null) { + if ($cache === null) { return null; } - return $cache; + return $this->hydrator->loadCacheEntry($this->sourceEntity, $key, $cache, $collection); } /** @@ -144,11 +142,11 @@ public function loadCollectionCache(PersistentCollection $collection, Collection */ public function storeCollectionCache(CollectionCacheKey $key, $elements) { - /** @var CachedEntityPersister $targetPersister */ $associationMapping = $this->sourceEntity->associationMappings[$key->association]; $targetPersister = $this->uow->getEntityPersister($this->targetEntity->rootEntityName); - $targetRegion = $targetPersister->getCacheRegion(); - $targetHydrator = $targetPersister->getEntityHydrator(); + assert($targetPersister instanceof CachedEntityPersister); + $targetRegion = $targetPersister->getCacheRegion(); + $targetHydrator = $targetPersister->getEntityHydrator(); // Only preserve ordering if association configured it if (! (isset($associationMapping['indexBy']) && $associationMapping['indexBy'])) { diff --git a/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php b/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php index 53d8c7614e9..5e96c309c63 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php @@ -84,7 +84,7 @@ abstract class AbstractEntityPersister implements CachedEntityPersister /** * Associations configured as FETCH_EAGER, as well as all inverse one-to-one associations. * - * @var array|null + * @var array|null */ protected $joinedAssociations; @@ -364,7 +364,9 @@ public function load(array $criteria, $entity = null, $assoc = null, array $hint return $result[0]; } - if (($result = $this->persister->load($criteria, $entity, $assoc, $hints, $lockMode, $limit, $orderBy)) === null) { + $result = $this->persister->load($criteria, $entity, $assoc, $hints, $lockMode, $limit, $orderBy); + + if ($result === null) { return null; } @@ -617,8 +619,8 @@ public function refresh(array $id, $entity, $lockMode = null) } /** - * @param array $association - * @param array $ownerId + * @param array $association + * @param array $ownerId * * @return CollectionCacheKey */ diff --git a/lib/Doctrine/ORM/Cache/QueryCache.php b/lib/Doctrine/ORM/Cache/QueryCache.php index 9a3c6e82701..24dba30f74e 100644 --- a/lib/Doctrine/ORM/Cache/QueryCache.php +++ b/lib/Doctrine/ORM/Cache/QueryCache.php @@ -44,7 +44,7 @@ public function put(QueryCacheKey $key, ResultSetMapping $rsm, $result, array $h /** * @param mixed[] $hints * - * @return array|null + * @return mixed[]|null */ public function get(QueryCacheKey $key, ResultSetMapping $rsm, array $hints = []); diff --git a/lib/Doctrine/ORM/Cache/QueryCacheEntry.php b/lib/Doctrine/ORM/Cache/QueryCacheEntry.php index cc4c964d6f0..6361cf1a929 100644 --- a/lib/Doctrine/ORM/Cache/QueryCacheEntry.php +++ b/lib/Doctrine/ORM/Cache/QueryCacheEntry.php @@ -30,7 +30,7 @@ class QueryCacheEntry implements CacheEntry /** * READ-ONLY: Public only for performance reasons, it should be considered immutable. * - * @var array List of entity identifiers + * @var array List of entity identifiers */ public $result; @@ -42,8 +42,8 @@ class QueryCacheEntry implements CacheEntry public $time; /** - * @param array $result - * @param float $time + * @param array $result + * @param float $time */ public function __construct($result, $time = null) { @@ -52,7 +52,7 @@ public function __construct($result, $time = null) } /** - * @param array $values + * @param array $values * * @return QueryCacheEntry */ diff --git a/lib/Doctrine/ORM/Cache/Region/DefaultMultiGetRegion.php b/lib/Doctrine/ORM/Cache/Region/DefaultMultiGetRegion.php index 61ae0de8733..1ce47f138fd 100644 --- a/lib/Doctrine/ORM/Cache/Region/DefaultMultiGetRegion.php +++ b/lib/Doctrine/ORM/Cache/Region/DefaultMultiGetRegion.php @@ -25,6 +25,7 @@ use Doctrine\ORM\Cache\CacheEntry; use Doctrine\ORM\Cache\CollectionCacheEntry; +use function assert; use function count; /** @@ -47,7 +48,7 @@ class DefaultMultiGetRegion extends DefaultRegion */ public function __construct($name, MultiGetCache $cache, $lifetime = 0) { - /** @var Cache $cache */ + assert($cache instanceof Cache); parent::__construct($name, $cache, $lifetime); } diff --git a/lib/Doctrine/ORM/Cache/TimestampCacheEntry.php b/lib/Doctrine/ORM/Cache/TimestampCacheEntry.php index f803429fe17..a399f248865 100644 --- a/lib/Doctrine/ORM/Cache/TimestampCacheEntry.php +++ b/lib/Doctrine/ORM/Cache/TimestampCacheEntry.php @@ -47,7 +47,7 @@ public function __construct($time = null) * * This method allow Doctrine\Common\Cache\PhpFileCache compatibility * - * @param array $values array containing property values + * @param array $values array containing property values * * @return TimestampCacheEntry */ diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index 81da7f6957b..70bbab82994 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -441,8 +441,10 @@ public function find($className, $id, $lockMode = null, $lockVersion = null) $unitOfWork = $this->getUnitOfWork(); + $entity = $unitOfWork->tryGetById($sortedId, $class->rootEntityName); + // Check identity map first - if (($entity = $unitOfWork->tryGetById($sortedId, $class->rootEntityName)) !== false) { + if ($entity !== false) { if (! ($entity instanceof $class->name)) { return null; } @@ -508,8 +510,10 @@ public function getReference($entityName, $id) throw ORMException::unrecognizedIdentifierFields($class->name, array_keys($id)); } + $entity = $this->unitOfWork->tryGetById($sortedId, $class->rootEntityName); + // Check identity map first, if its already in there just return it. - if (($entity = $this->unitOfWork->tryGetById($sortedId, $class->rootEntityName)) !== false) { + if ($entity !== false) { return $entity instanceof $class->name ? $entity : null; } @@ -531,8 +535,10 @@ public function getPartialReference($entityName, $identifier) { $class = $this->metadataFactory->getMetadataFor(ltrim($entityName, '\\')); + $entity = $this->unitOfWork->tryGetById($identifier, $class->rootEntityName); + // Check identity map first, if its already in there just return it. - if (($entity = $this->unitOfWork->tryGetById($identifier, $class->rootEntityName)) !== false) { + if ($entity !== false) { return $entity instanceof $class->name ? $entity : null; } @@ -842,7 +848,9 @@ public function newHydrator($hydrationMode) return new Internal\Hydration\SimpleObjectHydrator($this); default: - if (($class = $this->config->getCustomHydrationMode($hydrationMode)) !== null) { + $class = $this->config->getCustomHydrationMode($hydrationMode); + + if ($class !== null) { return new $class($this); } } @@ -869,9 +877,9 @@ public function initializeObject($obj) /** * Factory method to create EntityManager instances. * - * @param array|Connection $connection An array with the connection parameters or an existing Connection instance. - * @param Configuration $config The Configuration instance to use. - * @param EventManager $eventManager The EventManager instance to use. + * @param array|Connection $connection An array with the connection parameters or an existing Connection instance. + * @param Configuration $config The Configuration instance to use. + * @param EventManager $eventManager The EventManager instance to use. * * @return EntityManager The created EntityManager. * @@ -892,9 +900,9 @@ public static function create($connection, Configuration $config, ?EventManager /** * Factory method to create Connection instances. * - * @param array|Connection $connection An array with the connection parameters or an existing Connection instance. - * @param Configuration $config The Configuration instance to use. - * @param EventManager $eventManager The EventManager instance to use. + * @param array|Connection $connection An array with the connection parameters or an existing Connection instance. + * @param Configuration $config The Configuration instance to use. + * @param EventManager $eventManager The EventManager instance to use. * * @return Connection * diff --git a/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php b/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php index ca0a116e0f8..0f08dec473f 100644 --- a/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php +++ b/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php @@ -48,7 +48,7 @@ public function __construct($entity, EntityManagerInterface $em, array &$changeS /** * Retrieves entity changeset. * - * @return array + * @return array> */ public function getEntityChangeSet() { diff --git a/lib/Doctrine/ORM/Internal/CommitOrderCalculator.php b/lib/Doctrine/ORM/Internal/CommitOrderCalculator.php index db769f3a09f..589a3a08776 100644 --- a/lib/Doctrine/ORM/Internal/CommitOrderCalculator.php +++ b/lib/Doctrine/ORM/Internal/CommitOrderCalculator.php @@ -59,7 +59,7 @@ class CommitOrderCalculator /** * Volatile variable holding calculated nodes during sorting process. * - * @var array + * @psalm-var list */ private $sortedNodeList = []; @@ -122,7 +122,7 @@ public function addDependency($fromHash, $toHash, $weight) * * {@internal Highly performance-sensitive method.} * - * @return array + * @psalm-return list */ public function sort() { diff --git a/lib/Doctrine/ORM/NativeQuery.php b/lib/Doctrine/ORM/NativeQuery.php index 7ee571a57c7..d39f4a6890a 100644 --- a/lib/Doctrine/ORM/NativeQuery.php +++ b/lib/Doctrine/ORM/NativeQuery.php @@ -31,7 +31,7 @@ final class NativeQuery extends AbstractQuery { /** @var string */ - private $_sql; + private $sql; /** * Sets the SQL of the query. @@ -42,7 +42,7 @@ final class NativeQuery extends AbstractQuery */ public function setSQL($sql): self { - $this->_sql = $sql; + $this->sql = $sql; return $this; } @@ -56,7 +56,7 @@ public function setSQL($sql): self */ public function getSQL() { - return $this->_sql; + return $this->sql; } /** @@ -87,7 +87,7 @@ protected function _doExecute() } return $this->_em->getConnection()->executeQuery( - $this->_sql, + $this->sql, $parameters, $types, $this->_queryCacheProfile diff --git a/lib/Doctrine/ORM/Query.php b/lib/Doctrine/ORM/Query.php index 7f5ad59bc07..a26861da8b8 100644 --- a/lib/Doctrine/ORM/Query.php +++ b/lib/Doctrine/ORM/Query.php @@ -23,6 +23,7 @@ use Doctrine\Common\Cache\Cache; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\DBAL\LockMode; +use Doctrine\DBAL\Types\Type; use Doctrine\ORM\Internal\Hydration\IterableResult; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Query\AST\DeleteStatement; @@ -126,65 +127,65 @@ final class Query extends AbstractQuery /** * A snapshot of the parameter types the query was parsed with. * - * @var array + * @var array */ - private $_parsedTypes = []; + private $parsedTypes = []; /** * Cached DQL query. * * @var string|null */ - private $_dql = null; + private $dql = null; /** * The parser result that holds DQL => SQL information. * * @var ParserResult */ - private $_parserResult; + private $parserResult; /** * The first result to return (the "offset"). * * @var int|null */ - private $_firstResult = null; + private $firstResult = null; /** * The maximum number of results to return (the "limit"). * * @var int|null */ - private $_maxResults = null; + private $maxResults = null; /** * The cache driver used for caching queries. * * @var Cache|null */ - private $_queryCache; + private $queryCache; /** * Whether or not expire the query cache. * * @var bool */ - private $_expireQueryCache = false; + private $expireQueryCache = false; /** * The query cache lifetime. * * @var int */ - private $_queryCacheTTL; + private $queryCacheTTL; /** * Whether to use a query cache, if available. Defaults to TRUE. * * @var bool */ - private $_useQueryCache = true; + private $useQueryCache = true; /** * Gets the SQL query/queries that correspond to this DQL query. @@ -195,7 +196,7 @@ final class Query extends AbstractQuery */ public function getSQL() { - return $this->_parse()->getSqlExecutor()->getSqlStatements(); + return $this->parse()->getSqlExecutor()->getSqlStatements(); } /** @@ -217,7 +218,7 @@ protected function getResultSetMapping() { // parse query or load from cache if ($this->_resultSetMapping === null) { - $this->_resultSetMapping = $this->_parse()->getResultSetMapping(); + $this->_resultSetMapping = $this->parse()->getResultSetMapping(); } return $this->_resultSetMapping; @@ -230,7 +231,7 @@ protected function getResultSetMapping() * * @return ParserResult */ - private function _parse() + private function parse() { $types = []; @@ -240,41 +241,41 @@ private function _parse() } // Return previous parser result if the query and the filter collection are both clean - if ($this->_state === self::STATE_CLEAN && $this->_parsedTypes === $types && $this->_em->isFiltersStateClean()) { - return $this->_parserResult; + if ($this->_state === self::STATE_CLEAN && $this->parsedTypes === $types && $this->_em->isFiltersStateClean()) { + return $this->parserResult; } - $this->_state = self::STATE_CLEAN; - $this->_parsedTypes = $types; + $this->_state = self::STATE_CLEAN; + $this->parsedTypes = $types; $queryCache = $this->getQueryCacheDriver(); // Check query cache. - if (! ($this->_useQueryCache && $queryCache)) { + if (! ($this->useQueryCache && $queryCache)) { $parser = new Parser($this); - $this->_parserResult = $parser->parse(); + $this->parserResult = $parser->parse(); - return $this->_parserResult; + return $this->parserResult; } $hash = $this->_getQueryCacheId(); - $cached = $this->_expireQueryCache ? false : $queryCache->fetch($hash); + $cached = $this->expireQueryCache ? false : $queryCache->fetch($hash); if ($cached instanceof ParserResult) { // Cache hit. - $this->_parserResult = $cached; + $this->parserResult = $cached; - return $this->_parserResult; + return $this->parserResult; } // Cache miss. $parser = new Parser($this); - $this->_parserResult = $parser->parse(); + $this->parserResult = $parser->parse(); - $queryCache->save($hash, $this->_parserResult, $this->_queryCacheTTL); + $queryCache->save($hash, $this->parserResult, $this->queryCacheTTL); - return $this->_parserResult; + return $this->parserResult; } /** @@ -282,7 +283,7 @@ private function _parse() */ protected function _doExecute() { - $executor = $this->_parse()->getSqlExecutor(); + $executor = $this->parse()->getSqlExecutor(); if ($this->_queryCacheProfile) { $executor->setQueryCacheProfile($this->_queryCacheProfile); @@ -291,11 +292,11 @@ protected function _doExecute() } if ($this->_resultSetMapping === null) { - $this->_resultSetMapping = $this->_parserResult->getResultSetMapping(); + $this->_resultSetMapping = $this->parserResult->getResultSetMapping(); } // Prepare parameters - $paramMappings = $this->_parserResult->getParameterMappings(); + $paramMappings = $this->parserResult->getParameterMappings(); $paramCount = count($this->parameters); $mappingCount = count($paramMappings); @@ -324,6 +325,11 @@ protected function _doExecute() return $executor->execute($this->_em->getConnection(), $sqlParams, $types); } + /** + * @param array $sqlParams + * @param array $types + * @param array $connectionParams + */ private function evictResultSetCache( AbstractSqlExecutor $executor, array $sqlParams, @@ -365,7 +371,7 @@ private function evictEntityCacheRegion() /** * Processes query parameter mappings. * - * @param array $paramMappings + * @param Parameter[] $paramMappings * * @return mixed[][] * @@ -373,7 +379,7 @@ private function evictEntityCacheRegion() * * @psalm-return array{0: list, 1: array} */ - private function processParameterMappings($paramMappings): array + private function processParameterMappings(array $paramMappings): array { $sqlParams = []; $types = []; @@ -463,7 +469,7 @@ private function resolveParameterValue(Parameter $parameter): array */ public function setQueryCacheDriver($queryCache): self { - $this->_queryCache = $queryCache; + $this->queryCache = $queryCache; return $this; } @@ -477,7 +483,7 @@ public function setQueryCacheDriver($queryCache): self */ public function useQueryCache($bool): self { - $this->_useQueryCache = $bool; + $this->useQueryCache = $bool; return $this; } @@ -490,8 +496,8 @@ public function useQueryCache($bool): self */ public function getQueryCacheDriver() { - if ($this->_queryCache) { - return $this->_queryCache; + if ($this->queryCache) { + return $this->queryCache; } return $this->_em->getConfiguration()->getQueryCacheImpl(); @@ -510,7 +516,7 @@ public function setQueryCacheLifetime($timeToLive): self $timeToLive = (int) $timeToLive; } - $this->_queryCacheTTL = $timeToLive; + $this->queryCacheTTL = $timeToLive; return $this; } @@ -522,7 +528,7 @@ public function setQueryCacheLifetime($timeToLive): self */ public function getQueryCacheLifetime() { - return $this->_queryCacheTTL; + return $this->queryCacheTTL; } /** @@ -534,7 +540,7 @@ public function getQueryCacheLifetime() */ public function expireQueryCache($expire = true): self { - $this->_expireQueryCache = $expire; + $this->expireQueryCache = $expire; return $this; } @@ -546,7 +552,7 @@ public function expireQueryCache($expire = true): self */ public function getExpireQueryCache() { - return $this->_expireQueryCache; + return $this->expireQueryCache; } /** @@ -556,7 +562,7 @@ public function free() { parent::free(); - $this->_dql = null; + $this->dql = null; $this->_state = self::STATE_CLEAN; } @@ -568,7 +574,7 @@ public function free() public function setDQL($dqlQuery): self { if ($dqlQuery !== null) { - $this->_dql = $dqlQuery; + $this->dql = $dqlQuery; $this->_state = self::STATE_DIRTY; } @@ -582,7 +588,7 @@ public function setDQL($dqlQuery): self */ public function getDQL() { - return $this->_dql; + return $this->dql; } /** @@ -621,8 +627,8 @@ public function contains($dql) */ public function setFirstResult($firstResult): self { - $this->_firstResult = $firstResult; - $this->_state = self::STATE_DIRTY; + $this->firstResult = $firstResult; + $this->_state = self::STATE_DIRTY; return $this; } @@ -635,7 +641,7 @@ public function setFirstResult($firstResult): self */ public function getFirstResult() { - return $this->_firstResult; + return $this->firstResult; } /** @@ -647,8 +653,8 @@ public function getFirstResult() */ public function setMaxResults($maxResults): self { - $this->_maxResults = $maxResults; - $this->_state = self::STATE_DIRTY; + $this->maxResults = $maxResults; + $this->_state = self::STATE_DIRTY; return $this; } @@ -661,15 +667,15 @@ public function setMaxResults($maxResults): self */ public function getMaxResults() { - return $this->_maxResults; + return $this->maxResults; } /** * Executes the query and returns an IterableResult that can be used to incrementally * iterated over the result. * - * @param ArrayCollection|array|null $parameters The query parameters. - * @param string|int $hydrationMode The hydration mode to use. + * @param ArrayCollection|mixed[]|null $parameters The query parameters. + * @param string|int $hydrationMode The hydration mode to use. * * @return IterableResult */ @@ -764,8 +770,8 @@ protected function _getQueryCacheId() $this->getDQL() . serialize($this->_hints) . '&platform=' . $platform . ($this->_em->hasFilters() ? $this->_em->getFilters()->getHash() : '') . - '&firstResult=' . $this->_firstResult . '&maxResult=' . $this->_maxResults . - '&hydrationMode=' . $this->_hydrationMode . '&types=' . serialize($this->_parsedTypes) . 'DOCTRINE_QUERY_CACHE_SALT' + '&firstResult=' . $this->firstResult . '&maxResult=' . $this->maxResults . + '&hydrationMode=' . $this->_hydrationMode . '&types=' . serialize($this->parsedTypes) . 'DOCTRINE_QUERY_CACHE_SALT' ); } @@ -774,7 +780,7 @@ protected function _getQueryCacheId() */ protected function getHash() { - return sha1(parent::getHash() . '-' . $this->_firstResult . '-' . $this->_maxResults); + return sha1(parent::getHash() . '-' . $this->firstResult . '-' . $this->maxResults); } /** diff --git a/lib/Doctrine/ORM/Query/TreeWalker.php b/lib/Doctrine/ORM/Query/TreeWalker.php index a8ab903912f..8cc8521fdf0 100644 --- a/lib/Doctrine/ORM/Query/TreeWalker.php +++ b/lib/Doctrine/ORM/Query/TreeWalker.php @@ -39,15 +39,17 @@ public function __construct($query, $parserResult, array $queryComponents); /** * Returns internal queryComponents array. * - * @return array + * @return array> + * + * @psalm-var array */ public function getQueryComponents(); /** * Sets or overrides a query component for a given dql alias. * - * @param string $dqlAlias The DQL alias. - * @param array $queryComponent + * @param string $dqlAlias The DQL alias. + * @param array $queryComponent * * @return void */ @@ -58,7 +60,7 @@ public function setQueryComponent($dqlAlias, array $queryComponent); * * @return string The SQL. */ - function walkSelectStatement(AST\SelectStatement $AST); + public function walkSelectStatement(AST\SelectStatement $AST); /** * Walks down a SelectClause AST node, thereby generating the appropriate SQL. @@ -67,7 +69,7 @@ function walkSelectStatement(AST\SelectStatement $AST); * * @return string The SQL. */ - function walkSelectClause($selectClause); + public function walkSelectClause($selectClause); /** * Walks down a FromClause AST node, thereby generating the appropriate SQL. @@ -76,7 +78,7 @@ function walkSelectClause($selectClause); * * @return string The SQL. */ - function walkFromClause($fromClause); + public function walkFromClause($fromClause); /** * Walks down a FunctionNode AST node, thereby generating the appropriate SQL. @@ -85,7 +87,7 @@ function walkFromClause($fromClause); * * @return string The SQL. */ - function walkFunction($function); + public function walkFunction($function); /** * Walks down an OrderByClause AST node, thereby generating the appropriate SQL. @@ -94,7 +96,7 @@ function walkFunction($function); * * @return string The SQL. */ - function walkOrderByClause($orderByClause); + public function walkOrderByClause($orderByClause); /** * Walks down an OrderByItem AST node, thereby generating the appropriate SQL. @@ -103,7 +105,7 @@ function walkOrderByClause($orderByClause); * * @return string The SQL. */ - function walkOrderByItem($orderByItem); + public function walkOrderByItem($orderByItem); /** * Walks down a HavingClause AST node, thereby generating the appropriate SQL. @@ -112,7 +114,7 @@ function walkOrderByItem($orderByItem); * * @return string The SQL. */ - function walkHavingClause($havingClause); + public function walkHavingClause($havingClause); /** * Walks down a Join AST node and creates the corresponding SQL. @@ -121,7 +123,7 @@ function walkHavingClause($havingClause); * * @return string The SQL. */ - function walkJoin($join); + public function walkJoin($join); /** * Walks down a SelectExpression AST node and generates the corresponding SQL. @@ -130,7 +132,7 @@ function walkJoin($join); * * @return string The SQL. */ - function walkSelectExpression($selectExpression); + public function walkSelectExpression($selectExpression); /** * Walks down a QuantifiedExpression AST node, thereby generating the appropriate SQL. @@ -139,7 +141,7 @@ function walkSelectExpression($selectExpression); * * @return string The SQL. */ - function walkQuantifiedExpression($qExpr); + public function walkQuantifiedExpression($qExpr); /** * Walks down a Subselect AST node, thereby generating the appropriate SQL. @@ -148,7 +150,7 @@ function walkQuantifiedExpression($qExpr); * * @return string The SQL. */ - function walkSubselect($subselect); + public function walkSubselect($subselect); /** * Walks down a SubselectFromClause AST node, thereby generating the appropriate SQL. @@ -157,7 +159,7 @@ function walkSubselect($subselect); * * @return string The SQL. */ - function walkSubselectFromClause($subselectFromClause); + public function walkSubselectFromClause($subselectFromClause); /** * Walks down a SimpleSelectClause AST node, thereby generating the appropriate SQL. @@ -166,7 +168,7 @@ function walkSubselectFromClause($subselectFromClause); * * @return string The SQL. */ - function walkSimpleSelectClause($simpleSelectClause); + public function walkSimpleSelectClause($simpleSelectClause); /** * Walks down a SimpleSelectExpression AST node, thereby generating the appropriate SQL. @@ -175,7 +177,7 @@ function walkSimpleSelectClause($simpleSelectClause); * * @return string The SQL. */ - function walkSimpleSelectExpression($simpleSelectExpression); + public function walkSimpleSelectExpression($simpleSelectExpression); /** * Walks down an AggregateExpression AST node, thereby generating the appropriate SQL. @@ -184,7 +186,7 @@ function walkSimpleSelectExpression($simpleSelectExpression); * * @return string The SQL. */ - function walkAggregateExpression($aggExpression); + public function walkAggregateExpression($aggExpression); /** * Walks down a GroupByClause AST node, thereby generating the appropriate SQL. @@ -193,7 +195,7 @@ function walkAggregateExpression($aggExpression); * * @return string The SQL. */ - function walkGroupByClause($groupByClause); + public function walkGroupByClause($groupByClause); /** * Walks down a GroupByItem AST node, thereby generating the appropriate SQL. @@ -202,28 +204,28 @@ function walkGroupByClause($groupByClause); * * @return string The SQL. */ - function walkGroupByItem($groupByItem); + public function walkGroupByItem($groupByItem); /** * Walks down an UpdateStatement AST node, thereby generating the appropriate SQL. * * @return string The SQL. */ - function walkUpdateStatement(AST\UpdateStatement $AST); + public function walkUpdateStatement(AST\UpdateStatement $AST); /** * Walks down a DeleteStatement AST node, thereby generating the appropriate SQL. * * @return string The SQL. */ - function walkDeleteStatement(AST\DeleteStatement $AST); + public function walkDeleteStatement(AST\DeleteStatement $AST); /** * Walks down a DeleteClause AST node, thereby generating the appropriate SQL. * * @return string The SQL. */ - function walkDeleteClause(AST\DeleteClause $deleteClause); + public function walkDeleteClause(AST\DeleteClause $deleteClause); /** * Walks down an UpdateClause AST node, thereby generating the appropriate SQL. @@ -232,7 +234,7 @@ function walkDeleteClause(AST\DeleteClause $deleteClause); * * @return string The SQL. */ - function walkUpdateClause($updateClause); + public function walkUpdateClause($updateClause); /** * Walks down an UpdateItem AST node, thereby generating the appropriate SQL. @@ -241,7 +243,7 @@ function walkUpdateClause($updateClause); * * @return string The SQL. */ - function walkUpdateItem($updateItem); + public function walkUpdateItem($updateItem); /** * Walks down a WhereClause AST node, thereby generating the appropriate SQL. @@ -251,7 +253,7 @@ function walkUpdateItem($updateItem); * * @return string The SQL. */ - function walkWhereClause($whereClause); + public function walkWhereClause($whereClause); /** * Walk down a ConditionalExpression AST node, thereby generating the appropriate SQL. @@ -260,7 +262,7 @@ function walkWhereClause($whereClause); * * @return string The SQL. */ - function walkConditionalExpression($condExpr); + public function walkConditionalExpression($condExpr); /** * Walks down a ConditionalTerm AST node, thereby generating the appropriate SQL. @@ -269,7 +271,7 @@ function walkConditionalExpression($condExpr); * * @return string The SQL. */ - function walkConditionalTerm($condTerm); + public function walkConditionalTerm($condTerm); /** * Walks down a ConditionalFactor AST node, thereby generating the appropriate SQL. @@ -278,7 +280,7 @@ function walkConditionalTerm($condTerm); * * @return string The SQL. */ - function walkConditionalFactor($factor); + public function walkConditionalFactor($factor); /** * Walks down a ConditionalPrimary AST node, thereby generating the appropriate SQL. @@ -287,7 +289,7 @@ function walkConditionalFactor($factor); * * @return string The SQL. */ - function walkConditionalPrimary($primary); + public function walkConditionalPrimary($primary); /** * Walks down an ExistsExpression AST node, thereby generating the appropriate SQL. @@ -296,7 +298,7 @@ function walkConditionalPrimary($primary); * * @return string The SQL. */ - function walkExistsExpression($existsExpr); + public function walkExistsExpression($existsExpr); /** * Walks down a CollectionMemberExpression AST node, thereby generating the appropriate SQL. @@ -305,7 +307,7 @@ function walkExistsExpression($existsExpr); * * @return string The SQL. */ - function walkCollectionMemberExpression($collMemberExpr); + public function walkCollectionMemberExpression($collMemberExpr); /** * Walks down an EmptyCollectionComparisonExpression AST node, thereby generating the appropriate SQL. @@ -314,7 +316,7 @@ function walkCollectionMemberExpression($collMemberExpr); * * @return string The SQL. */ - function walkEmptyCollectionComparisonExpression($emptyCollCompExpr); + public function walkEmptyCollectionComparisonExpression($emptyCollCompExpr); /** * Walks down a NullComparisonExpression AST node, thereby generating the appropriate SQL. @@ -323,7 +325,7 @@ function walkEmptyCollectionComparisonExpression($emptyCollCompExpr); * * @return string The SQL. */ - function walkNullComparisonExpression($nullCompExpr); + public function walkNullComparisonExpression($nullCompExpr); /** * Walks down an InExpression AST node, thereby generating the appropriate SQL. @@ -332,7 +334,7 @@ function walkNullComparisonExpression($nullCompExpr); * * @return string The SQL. */ - function walkInExpression($inExpr); + public function walkInExpression($inExpr); /** * Walks down an InstanceOfExpression AST node, thereby generating the appropriate SQL. @@ -341,7 +343,7 @@ function walkInExpression($inExpr); * * @return string The SQL. */ - function walkInstanceOfExpression($instanceOfExpr); + public function walkInstanceOfExpression($instanceOfExpr); /** * Walks down a literal that represents an AST node, thereby generating the appropriate SQL. @@ -350,7 +352,7 @@ function walkInstanceOfExpression($instanceOfExpr); * * @return string The SQL. */ - function walkLiteral($literal); + public function walkLiteral($literal); /** * Walks down a BetweenExpression AST node, thereby generating the appropriate SQL. @@ -359,7 +361,7 @@ function walkLiteral($literal); * * @return string The SQL. */ - function walkBetweenExpression($betweenExpr); + public function walkBetweenExpression($betweenExpr); /** * Walks down a LikeExpression AST node, thereby generating the appropriate SQL. @@ -368,7 +370,7 @@ function walkBetweenExpression($betweenExpr); * * @return string The SQL. */ - function walkLikeExpression($likeExpr); + public function walkLikeExpression($likeExpr); /** * Walks down a StateFieldPathExpression AST node, thereby generating the appropriate SQL. @@ -377,7 +379,7 @@ function walkLikeExpression($likeExpr); * * @return string The SQL. */ - function walkStateFieldPathExpression($stateFieldPathExpression); + public function walkStateFieldPathExpression($stateFieldPathExpression); /** * Walks down a ComparisonExpression AST node, thereby generating the appropriate SQL. @@ -386,7 +388,7 @@ function walkStateFieldPathExpression($stateFieldPathExpression); * * @return string The SQL. */ - function walkComparisonExpression($compExpr); + public function walkComparisonExpression($compExpr); /** * Walks down an InputParameter AST node, thereby generating the appropriate SQL. @@ -395,7 +397,7 @@ function walkComparisonExpression($compExpr); * * @return string The SQL. */ - function walkInputParameter($inputParam); + public function walkInputParameter($inputParam); /** * Walks down an ArithmeticExpression AST node, thereby generating the appropriate SQL. @@ -404,7 +406,7 @@ function walkInputParameter($inputParam); * * @return string The SQL. */ - function walkArithmeticExpression($arithmeticExpr); + public function walkArithmeticExpression($arithmeticExpr); /** * Walks down an ArithmeticTerm AST node, thereby generating the appropriate SQL. @@ -413,7 +415,7 @@ function walkArithmeticExpression($arithmeticExpr); * * @return string The SQL. */ - function walkArithmeticTerm($term); + public function walkArithmeticTerm($term); /** * Walks down a StringPrimary that represents an AST node, thereby generating the appropriate SQL. @@ -422,7 +424,7 @@ function walkArithmeticTerm($term); * * @return string The SQL. */ - function walkStringPrimary($stringPrimary); + public function walkStringPrimary($stringPrimary); /** * Walks down an ArithmeticFactor that represents an AST node, thereby generating the appropriate SQL. @@ -431,7 +433,7 @@ function walkStringPrimary($stringPrimary); * * @return string The SQL. */ - function walkArithmeticFactor($factor); + public function walkArithmeticFactor($factor); /** * Walks down an SimpleArithmeticExpression AST node, thereby generating the appropriate SQL. @@ -440,7 +442,7 @@ function walkArithmeticFactor($factor); * * @return string The SQL. */ - function walkSimpleArithmeticExpression($simpleArithmeticExpr); + public function walkSimpleArithmeticExpression($simpleArithmeticExpr); /** * Walks down a PathExpression AST node, thereby generating the appropriate SQL. @@ -449,7 +451,7 @@ function walkSimpleArithmeticExpression($simpleArithmeticExpr); * * @return string The SQL. */ - function walkPathExpression($pathExpr); + public function walkPathExpression($pathExpr); /** * Walks down a ResultVariable that represents an AST node, thereby generating the appropriate SQL. @@ -458,7 +460,7 @@ function walkPathExpression($pathExpr); * * @return string The SQL. */ - function walkResultVariable($resultVariable); + public function walkResultVariable($resultVariable); /** * Gets an executor that can be used to execute the result of this walker. @@ -467,5 +469,5 @@ function walkResultVariable($resultVariable); * * @return Exec\AbstractSqlExecutor */ - function getExecutor($AST); + public function getExecutor($AST); } diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 4fbe3636f71..7d9486e1ed5 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -1255,17 +1255,12 @@ private function executeDeletions($class) /** * Gets the commit order. * - * @param array|null $entityChangeSet - * - * @return array + * @return list */ - private function getCommitOrder(?array $entityChangeSet = null) + private function getCommitOrder(): array { - if ($entityChangeSet === null) { - $entityChangeSet = array_merge($this->entityInsertions, $this->entityUpdates, $this->entityDeletions); - } - - $calc = $this->getCommitOrderCalculator(); + $entityChangeSet = array_merge($this->entityInsertions, $this->entityUpdates, $this->entityDeletions); + $calc = $this->getCommitOrderCalculator(); // See if there are any new classes in the changeset, that are not in the // commit order graph yet (don't have a node).