diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index 232f6534a7a..1a2fc79331d 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -506,10 +506,8 @@ protected function getResultSetMapping() /** * Allows to translate entity namespaces to full qualified names. - * - * @return void */ - private function translateNamespaces(Query\ResultSetMapping $rsm) + private function translateNamespaces(Query\ResultSetMapping $rsm): void { $translate = function ($alias): string { return $this->_em->getClassMetadata($alias)->getName(); @@ -1132,10 +1130,7 @@ private function executeUsingQueryCache($parameters = null, $hydrationMode = nul return $result; } - /** - * @return TimestampCacheKey|null - */ - private function getTimestampKey() + private function getTimestampKey(): ?TimestampCacheKey { $entityName = reset($this->_resultSetMapping->aliasMap); diff --git a/lib/Doctrine/ORM/Cache/DefaultCache.php b/lib/Doctrine/ORM/Cache/DefaultCache.php index 54c933799cc..fe8ba92f4df 100644 --- a/lib/Doctrine/ORM/Cache/DefaultCache.php +++ b/lib/Doctrine/ORM/Cache/DefaultCache.php @@ -278,10 +278,8 @@ public function getQueryCache($regionName = null) /** * @param ClassMetadata $metadata The entity metadata. * @param mixed $identifier The entity identifier. - * - * @return EntityCacheKey */ - private function buildEntityCacheKey(ClassMetadata $metadata, $identifier) + private function buildEntityCacheKey(ClassMetadata $metadata, $identifier): EntityCacheKey { if (! is_array($identifier)) { $identifier = $this->toIdentifierArray($metadata, $identifier); @@ -294,11 +292,12 @@ private function buildEntityCacheKey(ClassMetadata $metadata, $identifier) * @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. - * - * @return CollectionCacheKey */ - private function buildCollectionCacheKey(ClassMetadata $metadata, $association, $ownerIdentifier) - { + private function buildCollectionCacheKey( + ClassMetadata $metadata, + string $association, + $ownerIdentifier + ): CollectionCacheKey { if (! is_array($ownerIdentifier)) { $ownerIdentifier = $this->toIdentifierArray($metadata, $ownerIdentifier); } @@ -312,7 +311,7 @@ private function buildCollectionCacheKey(ClassMetadata $metadata, $association, * * @return array */ - private function toIdentifierArray(ClassMetadata $metadata, $identifier) + private function toIdentifierArray(ClassMetadata $metadata, $identifier): array { if (is_object($identifier) && $this->em->getMetadataFactory()->hasMetadataFor(ClassUtils::getClass($identifier))) { $identifier = $this->uow->getSingleIdentifierValue($identifier); diff --git a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php index d67690f732d..7b9cf7b9e83 100644 --- a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php +++ b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php @@ -215,12 +215,7 @@ public function getRegion(array $cache) return $this->regions[$cache['region']] = $region; } - /** - * @param string $name - * - * @return CacheAdapter - */ - private function createRegionCache($name) + private function createRegionCache(string $name): CacheAdapter { $cacheAdapter = clone $this->cache; diff --git a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php index 4c64488bd42..8a3beac4549 100644 --- a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php +++ b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php @@ -347,7 +347,7 @@ public function put(QueryCacheKey $key, ResultSetMapping $rsm, $result, array $h * @return mixed[]|null * @psalm-return array{targetEntity: class-string, type: mixed, list?: array[], identifier?: array}|null */ - private function storeAssociationCache(QueryCacheKey $key, array $assoc, $assocValue) + private function storeAssociationCache(QueryCacheKey $key, array $assoc, $assocValue): ?array { $assocPersister = $this->uow->getEntityPersister($assoc['targetEntity']); $assocMetadata = $assocPersister->getClassMetadata(); @@ -397,13 +397,15 @@ private function storeAssociationCache(QueryCacheKey $key, array $assoc, $assocV } /** - * @param string $assocAlias * @param object $entity * * @return array|object */ - private function getAssociationValue(ResultSetMapping $rsm, $assocAlias, $entity) - { + private function getAssociationValue( + ResultSetMapping $rsm, + string $assocAlias, + $entity + ) { $path = []; $alias = $assocAlias; diff --git a/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php b/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php index 1baa39d9d91..0344c71af84 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php @@ -225,10 +225,8 @@ public function storeEntityCache($entity, EntityCacheKey $key) /** * @param object $entity - * - * @return void */ - private function storeJoinedAssociations($entity) + private function storeJoinedAssociations($entity): void { if ($this->joinedAssociations === null) { $associations = []; diff --git a/lib/Doctrine/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersister.php b/lib/Doctrine/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersister.php index c2b36c18d00..3469d9716e4 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersister.php @@ -100,17 +100,14 @@ public function update($entity) /** * @param object $entity - * @param bool $isChanged - * - * @return bool */ - private function updateCache($entity, $isChanged) + private function updateCache($entity, bool $isChanged): bool { $class = $this->metadataFactory->getMetadataFor(get_class($entity)); $key = new EntityCacheKey($class->rootEntityName, $this->uow->getEntityIdentifier($entity)); $entry = $this->hydrator->buildCacheEntry($class, $key, $entity); $cached = $this->region->put($key, $entry); - $isChanged = $isChanged ?: $cached; + $isChanged = $isChanged || $cached; if ($this->cacheLogger && $cached) { $this->cacheLogger->entityCachePut($this->regionName, $key); diff --git a/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php b/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php index 0bea7cc846f..69ea98087ce 100644 --- a/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php +++ b/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php @@ -83,10 +83,7 @@ public function __construct(Region $region, $directory, $lockLifetime) $this->lockLifetime = $lockLifetime; } - /** - * @return bool - */ - private function isLocked(CacheKey $key, ?Lock $lock = null) + private function isLocked(CacheKey $key, ?Lock $lock = null): bool { $filename = $this->getLockFileName($key); @@ -117,30 +114,23 @@ private function isLocked(CacheKey $key, ?Lock $lock = null) return true; } - /** - * @return string - */ - private function getLockFileName(CacheKey $key) + private function getLockFileName(CacheKey $key): string { return $this->directory . DIRECTORY_SEPARATOR . $key->hash . '.' . self::LOCK_EXTENSION; } /** - * @param string $filename - * - * @return false|string + * @return string|false */ - private function getLockContent($filename) + private function getLockContent(string $filename) { return @file_get_contents($filename); } /** - * @param string $filename - * - * @return false|int + * @return int|false */ - private function getLockTime($filename) + private function getLockTime(string $filename) { return @fileatime($filename); } diff --git a/lib/Doctrine/ORM/Cache/TimestampQueryCacheValidator.php b/lib/Doctrine/ORM/Cache/TimestampQueryCacheValidator.php index 196c4e1e0f2..a9cb6f07a7f 100644 --- a/lib/Doctrine/ORM/Cache/TimestampQueryCacheValidator.php +++ b/lib/Doctrine/ORM/Cache/TimestampQueryCacheValidator.php @@ -48,10 +48,7 @@ public function isValid(QueryCacheKey $key, QueryCacheEntry $entry) return $entry->time + $key->lifetime > microtime(true); } - /** - * @return bool - */ - private function regionUpdated(QueryCacheKey $key, QueryCacheEntry $entry) + private function regionUpdated(QueryCacheKey $key, QueryCacheEntry $entry): bool { if ($key->timestampKey === null) { return false; diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index 491438280fa..41b877d08da 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -799,11 +799,9 @@ public function getConfiguration() /** * Throws an exception if the EntityManager is closed or currently not active. * - * @return void - * * @throws ORMException If the EntityManager is closed. */ - private function errorIfClosed() + private function errorIfClosed(): void { if ($this->closed) { throw ORMException::entityManagerClosed(); diff --git a/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php b/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php index 0f08dec473f..e0ab9155423 100644 --- a/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php +++ b/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php @@ -113,13 +113,9 @@ public function setNewValue($field, $value) /** * Asserts the field exists in changeset. * - * @param string $field - * - * @return void - * * @throws InvalidArgumentException */ - private function assertValidField($field) + private function assertValidField(string $field): void { if (! isset($this->entityChangeSet[$field])) { throw new InvalidArgumentException(sprintf( diff --git a/lib/Doctrine/ORM/Internal/CommitOrderCalculator.php b/lib/Doctrine/ORM/Internal/CommitOrderCalculator.php index d9bdc1be259..a099d432466 100644 --- a/lib/Doctrine/ORM/Internal/CommitOrderCalculator.php +++ b/lib/Doctrine/ORM/Internal/CommitOrderCalculator.php @@ -146,12 +146,8 @@ public function sort() * Visit a given node definition for reordering. * * {@internal Highly performance-sensitive method.} - * - * @param stdClass $vertex - * - * @return void */ - private function visit($vertex) + private function visit(stdClass $vertex): void { $vertex->state = self::IN_PROGRESS; diff --git a/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php index 80772e8e0d9..28a63b700c0 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php @@ -259,15 +259,16 @@ protected function hydrateRowData(array $row, array &$result) * Updates the result pointer for an Entity. The result pointers point to the * last seen instance of each Entity type. This is used for graph construction. * - * @param mixed[] $coll The element. - * @param bool|int $index Index of the element in the collection. - * @param string $dqlAlias - * @param bool $oneToOne Whether it is a single-valued association or not. - * - * @return void + * @param mixed[]|null $coll The element. + * @param bool|int $index Index of the element in the collection. + * @param bool $oneToOne Whether it is a single-valued association or not. */ - private function updateResultPointer(array &$coll, $index, $dqlAlias, $oneToOne) - { + private function updateResultPointer( + ?array &$coll, + $index, + string $dqlAlias, + bool $oneToOne + ): void { if ($coll === null) { unset($this->_resultPointers[$dqlAlias]); // Ticket #1228 diff --git a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php index b5e917951a1..cff24818a74 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php @@ -171,15 +171,16 @@ protected function hydrateAllData() /** * Initializes a related collection. * - * @param object $entity The entity to which the collection belongs. - * @param ClassMetadata $class - * @param string $fieldName The name of the field on the entity that holds the collection. - * @param string $parentDqlAlias Alias of the parent fetch joining this collection. - * - * @return PersistentCollection + * @param object $entity The entity to which the collection belongs. + * @param string $fieldName The name of the field on the entity that holds the collection. + * @param string $parentDqlAlias Alias of the parent fetch joining this collection. */ - private function initRelatedCollection($entity, $class, $fieldName, $parentDqlAlias) - { + private function initRelatedCollection( + $entity, + ClassMetadata $class, + string $fieldName, + string $parentDqlAlias + ): PersistentCollection { $oid = spl_object_hash($entity); $relation = $class->associationMappings[$fieldName]; $value = $class->reflFields[$fieldName]->getValue($entity); @@ -225,11 +226,9 @@ private function initRelatedCollection($entity, $class, $fieldName, $parentDqlAl * @param string $dqlAlias The DQL alias of the entity's class. * @psalm-param array $data The instance data. * - * @return object The entity. - * * @throws HydrationException */ - private function getEntity(array $data, $dqlAlias) + private function getEntity(array $data, string $dqlAlias): object { $className = $this->_rsm->aliasMap[$dqlAlias]; @@ -272,12 +271,12 @@ private function getEntity(array $data, $dqlAlias) } /** - * @param string $className + * @psalm-param class-string $className * @psalm-param array $data * * @return mixed */ - private function getEntityFromIdentityMap($className, array $data) + private function getEntityFromIdentityMap(string $className, array $data) { // TODO: Abstract this code and UnitOfWork::createEntity() equivalent? $class = $this->_metadataCache[$className]; diff --git a/lib/Doctrine/ORM/Internal/HydrationCompleteHandler.php b/lib/Doctrine/ORM/Internal/HydrationCompleteHandler.php index b30134d0945..7632ae3d123 100644 --- a/lib/Doctrine/ORM/Internal/HydrationCompleteHandler.php +++ b/lib/Doctrine/ORM/Internal/HydrationCompleteHandler.php @@ -54,10 +54,8 @@ public function __construct(ListenersInvoker $listenersInvoker, EntityManagerInt * Method schedules invoking of postLoad entity to the very end of current hydration cycle. * * @param object $entity - * - * @return void */ - public function deferPostLoadInvoking(ClassMetadata $class, $entity) + public function deferPostLoadInvoking(ClassMetadata $class, $entity): void { $invoke = $this->listenersInvoker->getSubscribedSystems($class, Events::postLoad); @@ -72,10 +70,8 @@ public function deferPostLoadInvoking(ClassMetadata $class, $entity) * This method should me called after any hydration cycle completed. * * Method fires all deferred invocations of postLoad events - * - * @return void */ - public function hydrationComplete() + public function hydrationComplete(): void { $toInvoke = $this->deferredPostLoadInvocations; $this->deferredPostLoadInvocations = []; diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 80943b68203..ca3ac800033 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -61,7 +61,7 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory /** @var EntityManagerInterface|null */ private $em; - /** @var AbstractPlatform */ + /** @var AbstractPlatform|null */ private $targetPlatform; /** @var MappingDriver */ @@ -310,11 +310,9 @@ protected function newClassMetadataInstance($className) * Populates the discriminator value of the given metadata (if not set) by iterating over discriminator * map classes and looking for a fitting one. * - * @return void - * * @throws MappingException */ - private function resolveDiscriminatorValue(ClassMetadata $metadata) + private function resolveDiscriminatorValue(ClassMetadata $metadata): void { if ( $metadata->discriminatorValue @@ -357,11 +355,9 @@ private function resolveDiscriminatorValue(ClassMetadata $metadata) * The automatically generated discriminator map contains the lowercase short name of * each class as key. * - * @return void - * * @throws MappingException */ - private function addDefaultDiscriminatorMap(ClassMetadata $class) + private function addDefaultDiscriminatorMap(ClassMetadata $class): void { $allClasses = $this->driver->getAllClassNames(); $fqcn = $class->getName(); @@ -390,11 +386,9 @@ private function addDefaultDiscriminatorMap(ClassMetadata $class) /** * Gets the lower-case short name of a class. * - * @param string $className - * - * @return string + * @psalm-param class-string $className */ - private function getShortName($className) + private function getShortName(string $className): string { if (strpos($className, '\\') === false) { return strtolower($className); @@ -407,10 +401,8 @@ private function getShortName($className) /** * Adds inherited fields to the subclass mapping. - * - * @return void */ - private function addInheritedFields(ClassMetadata $subClass, ClassMetadata $parentClass) + private function addInheritedFields(ClassMetadata $subClass, ClassMetadata $parentClass): void { foreach ($parentClass->fieldMappings as $mapping) { if (! isset($mapping['inherited']) && ! $parentClass->isMappedSuperclass) { @@ -432,11 +424,9 @@ private function addInheritedFields(ClassMetadata $subClass, ClassMetadata $pare /** * Adds inherited association mappings to the subclass mapping. * - * @return void - * * @throws MappingException */ - private function addInheritedRelations(ClassMetadata $subClass, ClassMetadata $parentClass) + private function addInheritedRelations(ClassMetadata $subClass, ClassMetadata $parentClass): void { foreach ($parentClass->associationMappings as $field => $mapping) { if ($parentClass->isMappedSuperclass) { @@ -460,10 +450,7 @@ private function addInheritedRelations(ClassMetadata $subClass, ClassMetadata $p } } - /** - * @return void - */ - private function addInheritedEmbeddedClasses(ClassMetadata $subClass, ClassMetadata $parentClass) + private function addInheritedEmbeddedClasses(ClassMetadata $subClass, ClassMetadata $parentClass): void { foreach ($parentClass->embeddedClasses as $field => $embeddedClass) { if (! isset($embeddedClass['inherited']) && ! $parentClass->isMappedSuperclass) { @@ -484,11 +471,12 @@ private function addInheritedEmbeddedClasses(ClassMetadata $subClass, ClassMetad * @param ClassMetadata $subClass Sub embedded class metadata to add nested embedded classes metadata from. * @param ClassMetadata $parentClass Parent class to add nested embedded classes metadata to. * @param string $prefix Embedded classes' prefix to use for nested embedded classes field names. - * - * @return void */ - private function addNestedEmbeddedClasses(ClassMetadata $subClass, ClassMetadata $parentClass, $prefix) - { + private function addNestedEmbeddedClasses( + ClassMetadata $subClass, + ClassMetadata $parentClass, + string $prefix + ): void { foreach ($subClass->embeddedClasses as $property => $embeddableClass) { if (isset($embeddableClass['inherited'])) { continue; @@ -512,10 +500,8 @@ private function addNestedEmbeddedClasses(ClassMetadata $subClass, ClassMetadata /** * Copy the table indices from the parent class superclass to the child class - * - * @return void */ - private function addInheritedIndexes(ClassMetadata $subClass, ClassMetadata $parentClass) + private function addInheritedIndexes(ClassMetadata $subClass, ClassMetadata $parentClass): void { if (! $parentClass->isMappedSuperclass) { return; @@ -536,10 +522,8 @@ private function addInheritedIndexes(ClassMetadata $subClass, ClassMetadata $par /** * Adds inherited named queries to the subclass mapping. - * - * @return void */ - private function addInheritedNamedQueries(ClassMetadata $subClass, ClassMetadata $parentClass) + private function addInheritedNamedQueries(ClassMetadata $subClass, ClassMetadata $parentClass): void { foreach ($parentClass->namedQueries as $name => $query) { if (! isset($subClass->namedQueries[$name])) { @@ -555,10 +539,8 @@ private function addInheritedNamedQueries(ClassMetadata $subClass, ClassMetadata /** * Adds inherited named native queries to the subclass mapping. - * - * @return void */ - private function addInheritedNamedNativeQueries(ClassMetadata $subClass, ClassMetadata $parentClass) + private function addInheritedNamedNativeQueries(ClassMetadata $subClass, ClassMetadata $parentClass): void { foreach ($parentClass->namedNativeQueries as $name => $query) { if (! isset($subClass->namedNativeQueries[$name])) { @@ -577,10 +559,8 @@ private function addInheritedNamedNativeQueries(ClassMetadata $subClass, ClassMe /** * Adds inherited sql result set mappings to the subclass mapping. - * - * @return void */ - private function addInheritedSqlResultSetMappings(ClassMetadata $subClass, ClassMetadata $parentClass) + private function addInheritedSqlResultSetMappings(ClassMetadata $subClass, ClassMetadata $parentClass): void { foreach ($parentClass->sqlResultSetMappings as $name => $mapping) { if (! isset($subClass->sqlResultSetMappings[$name])) { @@ -609,11 +589,9 @@ private function addInheritedSqlResultSetMappings(ClassMetadata $subClass, Class * Completes the ID generator mapping. If "auto" is specified we choose the generator * most appropriate for the targeted database platform. * - * @return void - * * @throws ORMException */ - private function completeIdGeneratorMapping(ClassMetadataInfo $class) + private function completeIdGeneratorMapping(ClassMetadataInfo $class): void { $idGenType = $class->generatorType; if ($idGenType === ClassMetadata::GENERATOR_TYPE_AUTO) { @@ -724,10 +702,8 @@ private function completeIdGeneratorMapping(ClassMetadataInfo $class) /** * Inherits the ID generator mapping from a parent class. - * - * @return void */ - private function inheritIdGeneratorMapping(ClassMetadataInfo $class, ClassMetadataInfo $parent) + private function inheritIdGeneratorMapping(ClassMetadataInfo $class, ClassMetadataInfo $parent): void { if ($parent->isIdGeneratorSequence()) { $class->setSequenceGeneratorDefinition($parent->sequenceGeneratorDefinition); @@ -786,10 +762,7 @@ protected function isEntity(ClassMetadataInterface $class) return isset($class->isMappedSuperclass) && $class->isMappedSuperclass === false; } - /** - * @return Platforms\AbstractPlatform - */ - private function getTargetPlatform() + private function getTargetPlatform(): Platforms\AbstractPlatform { if (! $this->targetPlatform) { $this->targetPlatform = $this->em->getConnection()->getDatabasePlatform(); diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index 8c5b8402d51..9d1e90a303b 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -2613,11 +2613,9 @@ public function setPrimaryTable(array $table) /** * Checks whether the given type identifies an inheritance type. * - * @param int $type - * - * @return bool TRUE if the given type identifies an inheritance type, FALSe otherwise. + * @return bool TRUE if the given type identifies an inheritance type, FALSE otherwise. */ - private function isInheritanceType($type) + private function isInheritanceType(int $type): bool { return $type === self::INHERITANCE_TYPE_NONE || $type === self::INHERITANCE_TYPE_SINGLE_TABLE || diff --git a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php index e23c17a1aef..6c7fdb862ba 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php @@ -636,14 +636,11 @@ private function loadRelationShipMapping( /** * Attempts to resolve the fetch mode. * - * @param string $className The class name. - * @param string $fetchMode The fetch mode. - * - * @return int The fetch mode as defined in ClassMetadata. + * @psalm-return \Doctrine\ORM\Mapping\ClassMetadata::FETCH_* The fetch mode as defined in ClassMetadata. * * @throws MappingException If the fetch mode is not valid. */ - private function getFetchMode($className, $fetchMode) + private function getFetchMode(string $className, string $fetchMode): int { if (! defined('Doctrine\ORM\Mapping\ClassMetadata::FETCH_' . $fetchMode)) { throw MappingException::invalidFetchMode($className, $fetchMode); @@ -658,7 +655,7 @@ private function getFetchMode($className, $fetchMode) * @return callable[] * @psalm-return list */ - private function getMethodCallbacks(ReflectionMethod $method) + private function getMethodCallbacks(ReflectionMethod $method): array { $callbacks = []; $annotations = $this->reader->getMethodAnnotations($method); @@ -713,7 +710,7 @@ private function getMethodCallbacks(ReflectionMethod $method) * referencedColumnName: string * } */ - private function joinColumnToArray(Mapping\JoinColumn $joinColumn) + private function joinColumnToArray(Mapping\JoinColumn $joinColumn): array { return [ 'name' => $joinColumn->name, @@ -728,8 +725,6 @@ private function joinColumnToArray(Mapping\JoinColumn $joinColumn) /** * Parse the given Column as array * - * @param string $fieldName - * * @return mixed[] * @psalm-return array{ * fieldName: string, @@ -744,7 +739,7 @@ private function joinColumnToArray(Mapping\JoinColumn $joinColumn) * columnDefinition?: string * } */ - private function columnToArray($fieldName, Mapping\Column $column) + private function columnToArray(string $fieldName, Mapping\Column $column): array { $mapping = [ 'fieldName' => $fieldName, diff --git a/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php b/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php index be71403fa3e..e4e0c1c35eb 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php @@ -259,11 +259,9 @@ public function loadMetadataForClass($className, ClassMetadata $metadata) } /** - * @return void - * * @throws MappingException */ - private function reverseEngineerMappingFromDatabase() + private function reverseEngineerMappingFromDatabase(): void { if ($this->tables !== null) { return; @@ -315,10 +313,8 @@ private function reverseEngineerMappingFromDatabase() /** * Build indexes from a class metadata. - * - * @return void */ - private function buildIndexes(ClassMetadataInfo $metadata) + private function buildIndexes(ClassMetadataInfo $metadata): void { $tableName = $metadata->table['name']; $indexes = $this->tables[$tableName]->getIndexes(); @@ -340,10 +336,8 @@ private function buildIndexes(ClassMetadataInfo $metadata) /** * Build field mapping from class metadata. - * - * @return void */ - private function buildFieldMappings(ClassMetadataInfo $metadata) + private function buildFieldMappings(ClassMetadataInfo $metadata): void { $tableName = $metadata->table['name']; $columns = $this->tables[$tableName]->getColumns(); @@ -386,8 +380,6 @@ private function buildFieldMappings(ClassMetadataInfo $metadata) /** * Build field mapping from a schema column definition * - * @param string $tableName - * * @psalm-return array{ * fieldName: string, * columnName: string, @@ -404,7 +396,7 @@ private function buildFieldMappings(ClassMetadataInfo $metadata) * length?: int|null * } */ - private function buildFieldMapping($tableName, Column $column) + private function buildFieldMapping(string $tableName, Column $column): array { $fieldMapping = [ 'fieldName' => $this->getFieldNameForColumn($tableName, $column->getName(), false), @@ -506,7 +498,7 @@ private function buildToOneAssociationMappings(ClassMetadataInfo $metadata) * @return ForeignKeyConstraint[] * @psalm-return array */ - private function getTableForeignKeys(Table $table) + private function getTableForeignKeys(Table $table): array { return $this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints() ? $table->getForeignKeys() @@ -518,7 +510,7 @@ private function getTableForeignKeys(Table $table) * * @return string[] */ - private function getTablePrimaryKeys(Table $table) + private function getTablePrimaryKeys(Table $table): array { try { return $table->getPrimaryKey()->getColumns(); @@ -532,11 +524,9 @@ private function getTablePrimaryKeys(Table $table) /** * Returns the mapped class name for a table if it exists. Otherwise return "classified" version. * - * @param string $tableName - * - * @return string + * @psalm-return class-string */ - private function getClassNameForTable($tableName) + private function getClassNameForTable(string $tableName): string { if (isset($this->classNamesForTables[$tableName])) { return $this->namespace . $this->classNamesForTables[$tableName]; @@ -548,14 +538,13 @@ private function getClassNameForTable($tableName) /** * Return the mapped field name for a column, if it exists. Otherwise return camelized version. * - * @param string $tableName - * @param string $columnName - * @param bool $fk Whether the column is a foreignkey or not. - * - * @return string + * @param bool $fk Whether the column is a foreignkey or not. */ - private function getFieldNameForColumn($tableName, $columnName, $fk = false) - { + private function getFieldNameForColumn( + string $tableName, + string $columnName, + bool $fk = false + ): string { if (isset($this->fieldNamesForColumns[$tableName]) && isset($this->fieldNamesForColumns[$tableName][$columnName])) { return $this->fieldNamesForColumns[$tableName][$columnName]; } diff --git a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php index 8fd8d35f046..99c34abb37f 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php @@ -737,7 +737,7 @@ public function loadMetadataForClass($className, ClassMetadata $metadata) * @return mixed[] The options array. * @psalm-return array|bool|string> */ - private function parseOptions(SimpleXMLElement $options) + private function parseOptions(SimpleXMLElement $options): array { $array = []; @@ -779,7 +779,7 @@ private function parseOptions(SimpleXMLElement $options) * columnDefinition?: string * } */ - private function joinColumnToArray(SimpleXMLElement $joinColumnElement) + private function joinColumnToArray(SimpleXMLElement $joinColumnElement): array { $joinColumn = [ 'name' => (string) $joinColumnElement['name'], @@ -823,7 +823,7 @@ private function joinColumnToArray(SimpleXMLElement $joinColumnElement) * options?: array * } */ - private function columnToArray(SimpleXMLElement $fieldMapping) + private function columnToArray(SimpleXMLElement $fieldMapping): array { $mapping = [ 'fieldName' => (string) $fieldMapping['name'], @@ -878,7 +878,7 @@ private function columnToArray(SimpleXMLElement $fieldMapping) * @return mixed[] * @psalm-return array{usage: int|null, region?: string} */ - private function cacheToArray(SimpleXMLElement $cacheMapping) + private function cacheToArray(SimpleXMLElement $cacheMapping): array { $region = isset($cacheMapping['region']) ? (string) $cacheMapping['region'] : null; $usage = isset($cacheMapping['usage']) ? strtoupper($cacheMapping['usage']) : null; @@ -905,7 +905,7 @@ private function cacheToArray(SimpleXMLElement $cacheMapping) * @return string[] The list of cascade options. * @psalm-return list */ - private function getCascadeMappings(SimpleXMLElement $cascadeElement) + private function getCascadeMappings(SimpleXMLElement $cascadeElement): array { $cascades = []; foreach ($cascadeElement->children() as $action) { diff --git a/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php index 15aef6f497f..668bfe57802 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php @@ -887,7 +887,7 @@ private function columnToArray(string $fieldName, ?array $column): array * @return mixed[] * @psalm-return array{usage: int, region: string|null} */ - private function cacheToArray($cacheMapping) + private function cacheToArray(array $cacheMapping): array { $region = isset($cacheMapping['region']) ? (string) $cacheMapping['region'] : null; $usage = isset($cacheMapping['usage']) ? strtoupper($cacheMapping['usage']) : null; diff --git a/lib/Doctrine/ORM/Mapping/Reflection/ReflectionPropertiesGetter.php b/lib/Doctrine/ORM/Mapping/Reflection/ReflectionPropertiesGetter.php index 6030db40f58..c2c6afad451 100644 --- a/lib/Doctrine/ORM/Mapping/Reflection/ReflectionPropertiesGetter.php +++ b/lib/Doctrine/ORM/Mapping/Reflection/ReflectionPropertiesGetter.php @@ -55,7 +55,7 @@ public function __construct(ReflectionService $reflectionService) * * @return ReflectionProperty[] indexed by property internal name */ - public function getProperties($className) + public function getProperties($className): array { if (isset($this->properties[$className])) { return $this->properties[$className]; @@ -75,12 +75,10 @@ public function getProperties($className) } /** - * @param string $className - * * @return ReflectionClass[] * @psalm-return list> */ - private function getHierarchyClasses($className): array + private function getHierarchyClasses(string $className): array { $classes = []; $parentClassName = $className; @@ -121,18 +119,12 @@ private function getClassProperties(ReflectionClass $reflectionClass): array ); } - /** - * @return bool - */ - private function isInstanceProperty(ReflectionProperty $reflectionProperty) + private function isInstanceProperty(ReflectionProperty $reflectionProperty): bool { return ! $reflectionProperty->isStatic(); } - /** - * @return ReflectionProperty|null - */ - private function getAccessibleProperty(ReflectionProperty $property) + private function getAccessibleProperty(ReflectionProperty $property): ?ReflectionProperty { return $this->reflectionService->getAccessibleProperty( $property->getDeclaringClass()->getName(), @@ -140,10 +132,7 @@ private function getAccessibleProperty(ReflectionProperty $property) ); } - /** - * @return string - */ - private function getLogicalName(ReflectionProperty $property) + private function getLogicalName(ReflectionProperty $property): string { $propertyName = $property->getName(); diff --git a/lib/Doctrine/ORM/PersistentCollection.php b/lib/Doctrine/ORM/PersistentCollection.php index 0f7b47cc17b..e060db6e268 100644 --- a/lib/Doctrine/ORM/PersistentCollection.php +++ b/lib/Doctrine/ORM/PersistentCollection.php @@ -64,7 +64,7 @@ final class PersistentCollection extends AbstractLazyCollection implements Selec /** * The entity that owns this collection. * - * @var object + * @var object|null */ private $owner; @@ -72,7 +72,7 @@ final class PersistentCollection extends AbstractLazyCollection implements Selec * The association mapping the collection belongs to. * This is currently either a OneToManyMapping or a ManyToManyMapping. * - * @psalm-var array + * @psalm-var array|null */ private $association; @@ -128,10 +128,8 @@ public function __construct(EntityManagerInterface $em, $class, Collection $coll * * @param object $entity * @psalm-param array $assoc - * - * @return void */ - public function setOwner($entity, array $assoc) + public function setOwner($entity, array $assoc): void { $this->owner = $entity; $this->association = $assoc; @@ -142,7 +140,7 @@ public function setOwner($entity, array $assoc) * INTERNAL: * Gets the collection owner. * - * @return object + * @return object|null */ public function getOwner() { @@ -152,7 +150,7 @@ public function getOwner() /** * @return Mapping\ClassMetadata */ - public function getTypeClass() + public function getTypeClass(): Mapping\ClassMetadataInfo { return $this->typeClass; } @@ -163,10 +161,8 @@ public function getTypeClass() * complete bidirectional associations in the case of a one-to-many association. * * @param mixed $element The element to add. - * - * @return void */ - public function hydrateAdd($element) + public function hydrateAdd($element): void { $this->collection->add($element); @@ -193,10 +189,8 @@ public function hydrateAdd($element) * * @param mixed $key The key to set. * @param mixed $element The element to set. - * - * @return void */ - public function hydrateSet($key, $element) + public function hydrateSet($key, $element): void { $this->collection->set($key, $element); @@ -214,10 +208,8 @@ public function hydrateSet($key, $element) /** * Initializes the collection by loading its contents from the database * if the collection is not yet initialized. - * - * @return void */ - public function initialize() + public function initialize(): void { if ($this->initialized || ! $this->association) { return; @@ -231,10 +223,8 @@ public function initialize() /** * INTERNAL: * Tells this collection to take a snapshot of its current state. - * - * @return void */ - public function takeSnapshot() + public function takeSnapshot(): void { $this->snapshot = $this->collection->toArray(); $this->isDirty = false; @@ -246,7 +236,7 @@ public function takeSnapshot() * * @psalm-return array The last snapshot of the elements. */ - public function getSnapshot() + public function getSnapshot(): array { return $this->snapshot; } @@ -257,7 +247,7 @@ public function getSnapshot() * * @return mixed[] */ - public function getDeleteDiff() + public function getDeleteDiff(): array { return array_udiff_assoc( $this->snapshot, @@ -274,7 +264,7 @@ static function ($a, $b): int { * * @return mixed[] */ - public function getInsertDiff() + public function getInsertDiff(): array { return array_udiff_assoc( $this->collection->toArray(), @@ -288,19 +278,17 @@ static function ($a, $b): int { /** * INTERNAL: Gets the association mapping of the collection. * - * @psalm-return array + * @psalm-return array|null */ - public function getMapping() + public function getMapping(): ?array { return $this->association; } /** * Marks this collection as changed/dirty. - * - * @return void */ - private function changed() + private function changed(): void { if ($this->isDirty) { return; @@ -325,7 +313,7 @@ private function changed() * * @return bool TRUE if the collection is dirty, FALSE otherwise. */ - public function isDirty() + public function isDirty(): bool { return $this->isDirty; } @@ -334,10 +322,8 @@ public function isDirty() * Sets a boolean flag, indicating whether this collection is dirty. * * @param bool $dirty Whether the collection should be marked dirty or not. - * - * @return void */ - public function setDirty($dirty) + public function setDirty($dirty): void { $this->isDirty = $dirty; } @@ -346,10 +332,8 @@ public function setDirty($dirty) * Sets the initialized flag of the collection, forcing it into that state. * * @param bool $bool - * - * @return void */ - public function setInitialized($bool) + public function setInitialized($bool): void { $this->initialized = $bool; } @@ -388,7 +372,7 @@ public function remove($key) /** * {@inheritdoc} */ - public function removeElement($element) + public function removeElement($element): bool { $removed = parent::removeElement($element); @@ -413,7 +397,7 @@ public function removeElement($element) /** * {@inheritdoc} */ - public function containsKey($key) + public function containsKey($key): bool { if ( ! $this->initialized && $this->association['fetch'] === ClassMetadata::FETCH_EXTRA_LAZY @@ -430,7 +414,7 @@ public function containsKey($key) /** * {@inheritdoc} */ - public function contains($element) + public function contains($element): bool { if (! $this->initialized && $this->association['fetch'] === ClassMetadata::FETCH_EXTRA_LAZY) { $persister = $this->em->getUnitOfWork()->getCollectionPersister($this->association); @@ -461,10 +445,7 @@ public function get($key) return parent::get($key); } - /** - * {@inheritdoc} - */ - public function count() + public function count(): int { if (! $this->initialized && $this->association !== null && $this->association['fetch'] === ClassMetadata::FETCH_EXTRA_LAZY) { $persister = $this->em->getUnitOfWork()->getCollectionPersister($this->association); @@ -478,7 +459,7 @@ public function count() /** * {@inheritdoc} */ - public function set($key, $value) + public function set($key, $value): void { parent::set($key, $value); @@ -492,7 +473,7 @@ public function set($key, $value) /** * {@inheritdoc} */ - public function add($value) + public function add($value): bool { $this->collection->add($value); @@ -510,7 +491,7 @@ public function add($value) /** * {@inheritdoc} */ - public function offsetExists($offset) + public function offsetExists($offset): bool { return $this->containsKey($offset); } @@ -526,7 +507,7 @@ public function offsetGet($offset) /** * {@inheritdoc} */ - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (! isset($offset)) { $this->add($value); @@ -540,25 +521,19 @@ public function offsetSet($offset, $value) /** * {@inheritdoc} * - * @return object + * @return object|null */ public function offsetUnset($offset) { return $this->remove($offset); } - /** - * {@inheritdoc} - */ - public function isEmpty() + public function isEmpty(): bool { return $this->collection->isEmpty() && $this->count() === 0; } - /** - * {@inheritdoc} - */ - public function clear() + public function clear(): void { if ($this->initialized && $this->isEmpty()) { $this->collection->clear(); @@ -622,7 +597,7 @@ public function __sleep(): array * * @psalm-return array */ - public function slice($offset, $length = null) + public function slice($offset, $length = null): array { if (! $this->initialized && ! $this->isDirty && $this->association['fetch'] === ClassMetadata::FETCH_EXTRA_LAZY) { $persister = $this->em->getUnitOfWork()->getCollectionPersister($this->association); @@ -643,8 +618,6 @@ public function slice($offset, $length = null) * 3. Snapshot leads to invalid diffs being generated. * 4. Lazy loading grabs entities from old owner object. * 5. New collection is connected to old owner and leads to duplicate keys. - * - * @return void */ public function __clone() { @@ -668,7 +641,7 @@ public function __clone() * * @throws RuntimeException */ - public function matching(Criteria $criteria) + public function matching(Criteria $criteria): Collection { if ($this->isDirty) { $this->initialize(); @@ -705,15 +678,12 @@ public function matching(Criteria $criteria) * * @return Collection */ - public function unwrap() + public function unwrap(): Collection { return $this->collection; } - /** - * {@inheritdoc} - */ - protected function doInitialize() + protected function doInitialize(): void { // Has NEW objects added through add(). Remember them. $newlyAddedDirtyObjects = []; diff --git a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php index ac35f3491cd..4583f165207 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php @@ -529,8 +529,10 @@ protected function getInsertRowSQLParameters(PersistentCollection $collection, $ * @return mixed[] * @psalm-return list */ - private function collectJoinTableColumnParameters(PersistentCollection $collection, $element) - { + private function collectJoinTableColumnParameters( + PersistentCollection $collection, + $element + ): array { $params = []; $mapping = $collection->getMapping(); $isComposite = count($mapping['joinTableColumns']) > 2; @@ -566,8 +568,7 @@ private function collectJoinTableColumnParameters(PersistentCollection $collecti } /** - * @param string $key - * @param bool $addFilters Whether the filter SQL should be included or not. + * @param bool $addFilters Whether the filter SQL should be included or not. * * @return mixed[] ordered vector: * - quoted join table name @@ -576,8 +577,11 @@ private function collectJoinTableColumnParameters(PersistentCollection $collecti * - types of the parameters to be bound for filtering * @psalm-return array{0: string, 1: list, 2: list, 3: list} */ - private function getJoinTableRestrictionsWithKey(PersistentCollection $collection, $key, $addFilters) - { + private function getJoinTableRestrictionsWithKey( + PersistentCollection $collection, + string $key, + bool $addFilters + ): array { $filterMapping = $collection->getMapping(); $mapping = $filterMapping; $indexBy = $mapping['indexBy']; @@ -651,8 +655,8 @@ private function getJoinTableRestrictionsWithKey(PersistentCollection $collectio } /** + * @param bool $addFilters Whether the filter SQL should be included or not. * @param object $element - * @param bool $addFilters Whether the filter SQL should be included or not. * * @return mixed[] ordered vector: * - quoted join table name @@ -661,8 +665,11 @@ private function getJoinTableRestrictionsWithKey(PersistentCollection $collectio * - types of the parameters to be bound for filtering * @psalm-return array{0: string, 1: list, 2: list, 3: list} */ - private function getJoinTableRestrictions(PersistentCollection $collection, $element, $addFilters) - { + private function getJoinTableRestrictions( + PersistentCollection $collection, + $element, + bool $addFilters + ): array { $filterMapping = $collection->getMapping(); $mapping = $filterMapping; @@ -722,7 +729,7 @@ private function getJoinTableRestrictions(PersistentCollection $collection, $ele * * @return mixed[][] */ - private function expandCriteriaParameters(Criteria $criteria) + private function expandCriteriaParameters(Criteria $criteria): array { $expression = $criteria->getWhereExpression(); @@ -739,10 +746,7 @@ private function expandCriteriaParameters(Criteria $criteria) return $types; } - /** - * @return string - */ - private function getOrderingSql(Criteria $criteria, ClassMetadata $targetClass) + private function getOrderingSql(Criteria $criteria, ClassMetadata $targetClass): string { $orderings = $criteria->getOrderings(); if ($orderings) { @@ -763,11 +767,9 @@ private function getOrderingSql(Criteria $criteria, ClassMetadata $targetClass) } /** - * @return string - * * @throws DBALException */ - private function getLimitSql(Criteria $criteria) + private function getLimitSql(Criteria $criteria): string { $limit = $criteria->getMaxResults(); $offset = $criteria->getFirstResult(); diff --git a/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php index f872cc1c6d4..36efcc6999a 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php @@ -180,11 +180,9 @@ public function loadCriteria(PersistentCollection $collection, Criteria $criteri } /** - * @return int - * * @throws DBALException */ - private function deleteEntityCollection(PersistentCollection $collection) + private function deleteEntityCollection(PersistentCollection $collection): int { $mapping = $collection->getMapping(); $identifier = $this->uow->getEntityIdentifier($collection->getOwner()); @@ -210,11 +208,9 @@ private function deleteEntityCollection(PersistentCollection $collection) * * Thanks Steve Ebersole (Hibernate) for idea on how to tackle reliably this scenario, we owe him a beer! =) * - * @return int - * * @throws DBALException */ - private function deleteJoinedEntityCollection(PersistentCollection $collection) + private function deleteJoinedEntityCollection(PersistentCollection $collection): int { $mapping = $collection->getMapping(); $sourceClass = $this->em->getClassMetadata($mapping['sourceEntity']); diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index 8496a897440..addea92a41c 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -24,9 +24,9 @@ use Doctrine\Common\Collections\Expr\Comparison; use Doctrine\Common\Util\ClassUtils; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\Driver\ResultStatement as DriverStatement; use Doctrine\DBAL\LockMode; use Doctrine\DBAL\Platforms\AbstractPlatform; -use Doctrine\DBAL\Statement; use Doctrine\DBAL\Types\Type; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadata; @@ -414,13 +414,15 @@ public function update($entity) * @param mixed[] $updateData The map of columns to update (column => value). * @param bool $versioned Whether the UPDATE should be versioned. * - * @return void - * * @throws ORMException * @throws OptimisticLockException */ - final protected function updateTable($entity, $quotedTableName, array $updateData, $versioned = false) - { + final protected function updateTable( + $entity, + $quotedTableName, + array $updateData, + $versioned = false + ): void { $set = []; $types = []; $params = []; @@ -913,12 +915,11 @@ public function getManyToManyCollection(array $assoc, $sourceEntity, $offset = n /** * Loads an array of entities from a given DBAL statement. * - * @param mixed[] $assoc - * @param Statement $stmt + * @param mixed[] $assoc * * @return mixed[] */ - private function loadArrayFromStatement($assoc, $stmt) + private function loadArrayFromStatement(array $assoc, DriverStatement $stmt): array { $rsm = $this->currentPersisterContext->rsm; $hints = [UnitOfWork::HINT_DEFEREAGERLOAD => true]; @@ -934,14 +935,15 @@ private function loadArrayFromStatement($assoc, $stmt) /** * Hydrates a collection from a given DBAL statement. * - * @param mixed[] $assoc - * @param Statement $stmt - * @param PersistentCollection $coll + * @param mixed[] $assoc * * @return mixed[] */ - private function loadCollectionFromStatement($assoc, $stmt, $coll) - { + private function loadCollectionFromStatement( + array $assoc, + DriverStatement $stmt, + PersistentCollection $coll + ): array { $rsm = $this->currentPersisterContext->rsm; $hints = [ UnitOfWork::HINT_DEFEREAGERLOAD => true, @@ -969,7 +971,7 @@ public function loadManyToManyCollection(array $assoc, $sourceEntity, Persistent /** * @psalm-param array $assoc * - * @return \Doctrine\DBAL\Driver\Statement + * @return DriverStatement * * @throws MappingException */ @@ -1650,7 +1652,6 @@ public function getSelectConditionStatementSQL($field, $value, $assoc = null, $c /** * Builds the left-hand-side of a where condition statement. * - * @param string $field * @psalm-param array|null $assoc * * @return string[] @@ -1658,8 +1659,10 @@ public function getSelectConditionStatementSQL($field, $value, $assoc = null, $c * * @throws ORMException */ - private function getSelectConditionStatementColumnSQL($field, $assoc = null) - { + private function getSelectConditionStatementColumnSQL( + string $field, + ?array $assoc = null + ): array { if (isset($this->class->fieldMappings[$field])) { $className = $this->class->fieldMappings[$field]['inherited'] ?? $this->class->name; @@ -1759,15 +1762,14 @@ public function loadOneToManyCollection(array $assoc, $sourceEntity, PersistentC /** * Builds criteria and execute SQL statement to fetch the one to many entities from. * - * @param object $sourceEntity - * @param int|null $offset - * @param int|null $limit * @psalm-param array $assoc - * - * @return Statement */ - private function getOneToManyStatement(array $assoc, $sourceEntity, $offset = null, $limit = null) - { + private function getOneToManyStatement( + array $assoc, + object $sourceEntity, + ?int $offset = null, + ?int $limit = null + ): DriverStatement { $this->switchPersisterContext($offset, $limit); $criteria = []; @@ -1845,7 +1847,7 @@ public function expandParameters($criteria) * @return mixed[][] * @psalm-return array{0: array, 1: list} */ - private function expandToManyParameters($criteria) + private function expandToManyParameters(array $criteria): array { $params = []; $types = []; @@ -1865,15 +1867,14 @@ private function expandToManyParameters($criteria) /** * Infers field types to be used by parameter type casting. * - * @param string $field - * @param mixed $value + * @param mixed $value * * @return int[]|null[]|string[] * @psalm-return list * * @throws QueryException */ - private function getTypes($field, $value, ClassMetadata $class) + private function getTypes(string $field, $value, ClassMetadata $class): array { $types = []; @@ -1924,7 +1925,7 @@ private function getTypes($field, $value, ClassMetadata $class) * * @return mixed[] */ - private function getValues($value) + private function getValues($value): array { if (is_array($value)) { $newValue = []; diff --git a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php index 0ad5bab07b3..1f5026bb669 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php @@ -68,10 +68,8 @@ protected function getDiscriminatorColumnTableName() /** * This function finds the ClassMetadata instance in an inheritance hierarchy * that is responsible for enabling versioning. - * - * @return ClassMetadata */ - private function getVersionedClassMetadata() + private function getVersionedClassMetadata(): ClassMetadata { if (isset($this->class->fieldMappings[$this->class->versionField]['inherited'])) { $definingClassName = $this->class->fieldMappings[$this->class->versionField]['inherited']; @@ -576,12 +574,7 @@ protected function assignDefaultVersionValue($entity, array $id) $this->class->setFieldValue($entity, $this->class->versionField, $value); } - /** - * @param string $baseTableAlias - * - * @return string - */ - private function getJoinSql($baseTableAlias) + private function getJoinSql(string $baseTableAlias): string { $joinSql = ''; $identifierColumn = $this->class->getIdentifierColumnNames(); diff --git a/lib/Doctrine/ORM/Proxy/ProxyFactory.php b/lib/Doctrine/ORM/Proxy/ProxyFactory.php index d7c8c156581..f853b2ebb07 100644 --- a/lib/Doctrine/ORM/Proxy/ProxyFactory.php +++ b/lib/Doctrine/ORM/Proxy/ProxyFactory.php @@ -109,12 +109,11 @@ protected function createProxyDefinition($className) /** * Creates a closure capable of initializing a proxy * - * @return Closure * @psalm-return Closure(BaseProxy):void * * @throws EntityNotFoundException */ - private function createInitializer(ClassMetadata $classMetadata, EntityPersister $entityPersister) + private function createInitializer(ClassMetadata $classMetadata, EntityPersister $entityPersister): Closure { $wakeupProxy = $classMetadata->getReflectionClass()->hasMethod('__wakeup'); @@ -161,12 +160,11 @@ private function createInitializer(ClassMetadata $classMetadata, EntityPersister /** * Creates a closure capable of finalizing state a cloned proxy * - * @return Closure * @psalm-return Closure(BaseProxy):void * * @throws EntityNotFoundException */ - private function createCloner(ClassMetadata $classMetadata, EntityPersister $entityPersister) + private function createCloner(ClassMetadata $classMetadata, EntityPersister $entityPersister): Closure { return function (BaseProxy $proxy) use ($entityPersister, $classMetadata): void { if ($proxy->__isInitialized()) { diff --git a/lib/Doctrine/ORM/Query.php b/lib/Doctrine/ORM/Query.php index d08ebdc7877..88cd5aaf027 100644 --- a/lib/Doctrine/ORM/Query.php +++ b/lib/Doctrine/ORM/Query.php @@ -22,6 +22,7 @@ use Doctrine\Common\Cache\Cache; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\LockMode; use Doctrine\DBAL\Types\Type; use Doctrine\ORM\Internal\Hydration\IterableResult; @@ -234,10 +235,8 @@ protected function getResultSetMapping() * Parses the DQL query, if necessary, and stores the parser result. * * Note: Populates $this->_parserResult as a side-effect. - * - * @return ParserResult */ - private function parse() + private function parse(): ParserResult { $types = []; @@ -335,15 +334,13 @@ protected function _doExecute() * @param array $sqlParams * @param array $types * @param array $connectionParams - * - * @return void */ private function evictResultSetCache( AbstractSqlExecutor $executor, array $sqlParams, array $types, array $connectionParams - ) { + ): void { if ($this->_queryCacheProfile === null || ! $this->getExpireResultCache()) { return; } @@ -360,10 +357,8 @@ private function evictResultSetCache( /** * Evict entity cache region - * - * @return void */ - private function evictEntityCacheRegion() + private function evictEntityCacheRegion(): void { $AST = $this->getAST(); @@ -502,7 +497,7 @@ public function useQueryCache($bool): self * @return Cache|null The cache driver used for query caching or NULL, if * this Query does not use query caching. */ - public function getQueryCacheDriver() + public function getQueryCacheDriver(): ?Cache { if ($this->queryCache) { return $this->queryCache; @@ -531,10 +526,8 @@ public function setQueryCacheLifetime($timeToLive): self /** * Retrieves the lifetime of resultset cache. - * - * @return int */ - public function getQueryCacheLifetime() + public function getQueryCacheLifetime(): ?int { return $this->queryCacheTTL; } @@ -555,20 +548,16 @@ public function expireQueryCache($expire = true): self /** * Retrieves if the query cache is active or not. - * - * @return bool */ - public function getExpireQueryCache() + public function getExpireQueryCache(): bool { return $this->expireQueryCache; } /** - * @return void - * * @override */ - public function free() + public function free(): void { parent::free(); @@ -593,10 +582,8 @@ public function setDQL($dqlQuery): self /** * Returns the DQL query that is represented by this query object. - * - * @return string|null */ - public function getDQL() + public function getDQL(): ?string { return $this->dql; } @@ -611,7 +598,7 @@ public function getDQL() * * @return int The query state. */ - public function getState() + public function getState(): int { return $this->_state; } @@ -620,10 +607,8 @@ public function getState() * Method to check if an arbitrary piece of DQL exists * * @param string $dql Arbitrary piece of DQL to check for. - * - * @return bool */ - public function contains($dql) + public function contains($dql): bool { return stripos($this->getDQL(), $dql) !== false; } @@ -649,7 +634,7 @@ public function setFirstResult($firstResult): self * * @return int|null The position of the first result. */ - public function getFirstResult() + public function getFirstResult(): ?int { return $this->firstResult; } @@ -675,7 +660,7 @@ public function setMaxResults($maxResults): self * * @return int|null Maximum number of results. */ - public function getMaxResults() + public function getMaxResults(): ?int { return $this->maxResults; } @@ -689,10 +674,8 @@ public function getMaxResults() * @param ArrayCollection|mixed[]|null $parameters The query parameters. * @param string|int $hydrationMode The hydration mode to use. * @psalm-param ArrayCollection|array|null $parameters - * - * @return IterableResult */ - public function iterate($parameters = null, $hydrationMode = self::HYDRATE_OBJECT) + public function iterate($parameters = null, $hydrationMode = self::HYDRATE_OBJECT): IterableResult { $this->setHint(self::HINT_INTERNAL_ITERATION, true); @@ -710,7 +693,7 @@ public function toIterable(iterable $parameters = [], $hydrationMode = self::HYD /** * {@inheritdoc} */ - public function setHint($name, $value) + public function setHint($name, $value): self { $this->_state = self::STATE_DIRTY; @@ -720,7 +703,7 @@ public function setHint($name, $value) /** * {@inheritdoc} */ - public function setHydrationMode($hydrationMode) + public function setHydrationMode($hydrationMode): self { $this->_state = self::STATE_DIRTY; @@ -754,7 +737,7 @@ public function setLockMode($lockMode): self * * @return int|null The current lock mode of this query or NULL if no specific lock mode is set. */ - public function getLockMode() + public function getLockMode(): ?int { $lockMode = $this->getHint(self::HINT_LOCK_MODE); @@ -786,18 +769,13 @@ protected function getQueryCacheId(): string ); } - /** - * {@inheritdoc} - */ - protected function getHash() + protected function getHash(): string { return sha1(parent::getHash() . '-' . $this->firstResult . '-' . $this->maxResults); } /** * Cleanup Query resource when clone is called. - * - * @return void */ public function __clone() { diff --git a/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php index 9a6642decf9..e41122b37c7 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php @@ -93,10 +93,9 @@ public function parse(Parser $parser) } /** - * @return int * @psalm-return AbstractPlatform::TRIM_* */ - private function getTrimMode() + private function getTrimMode(): int { if ($this->leading) { return AbstractPlatform::TRIM_LEADING; @@ -113,10 +112,7 @@ private function getTrimMode() return AbstractPlatform::TRIM_UNSPECIFIED; } - /** - * @return void - */ - private function parseTrimMode(Parser $parser) + private function parseTrimMode(Parser $parser): void { $lexer = $parser->getLexer(); $value = $lexer->lookahead['value']; diff --git a/lib/Doctrine/ORM/Query/Expr/Composite.php b/lib/Doctrine/ORM/Query/Expr/Composite.php index 425e352d01a..b84902eeb4d 100644 --- a/lib/Doctrine/ORM/Query/Expr/Composite.php +++ b/lib/Doctrine/ORM/Query/Expr/Composite.php @@ -51,10 +51,8 @@ public function __toString() /** * @param string|object $part - * - * @return string */ - private function processQueryPart($part) + private function processQueryPart($part): string { $queryPart = (string) $part; diff --git a/lib/Doctrine/ORM/Query/Filter/SQLFilter.php b/lib/Doctrine/ORM/Query/Filter/SQLFilter.php index f9cb0a59a40..9cd80d05482 100644 --- a/lib/Doctrine/ORM/Query/Filter/SQLFilter.php +++ b/lib/Doctrine/ORM/Query/Filter/SQLFilter.php @@ -135,10 +135,8 @@ final public function __toString() /** * Returns the database connection used by the entity manager - * - * @return Connection */ - final protected function getConnection() + final protected function getConnection(): Connection { return $this->em->getConnection(); } diff --git a/lib/Doctrine/ORM/Query/Parser.php b/lib/Doctrine/ORM/Query/Parser.php index 60244a8e63e..d8199649d89 100644 --- a/lib/Doctrine/ORM/Query/Parser.php +++ b/lib/Doctrine/ORM/Query/Parser.php @@ -463,10 +463,8 @@ public function parse() * as the hydration process relies on that order for proper operation. * * @param AST\SelectStatement|AST\DeleteStatement|AST\UpdateStatement $AST - * - * @return void */ - private function fixIdentificationVariableOrder($AST) + private function fixIdentificationVariableOrder(Node $AST): void { if (count($this->identVariableExpressions) <= 1) { return; @@ -557,7 +555,7 @@ public function semanticalError($message = '', $token = null) * @return mixed[] * @psalm-return array{value: string, type: int|null|string, position: int}|null */ - private function peekBeyondClosingParenthesis(bool $resetPeek = true) + private function peekBeyondClosingParenthesis(bool $resetPeek = true): ?array { $token = $this->lexer->peek(); $numUnmatched = 1; @@ -589,9 +587,9 @@ private function peekBeyondClosingParenthesis(bool $resetPeek = true) /** * Checks if the given token indicates a mathematical operator. * - * @psalm-param array $token + * @psalm-param array|null $token */ - private function isMathOperator($token): bool + private function isMathOperator(?array $token): bool { return $token !== null && in_array($token['type'], [Lexer::T_PLUS, Lexer::T_MINUS, Lexer::T_DIVIDE, Lexer::T_MULTIPLY]); } @@ -1039,11 +1037,9 @@ public function AbstractSchemaName() * * @param string $schemaName The name to validate. * - * @return void - * * @throws QueryException if the name does not exist. */ - private function validateAbstractSchemaName($schemaName) + private function validateAbstractSchemaName(string $schemaName): void { if (! (class_exists($schemaName, true) || interface_exists($schemaName, true))) { $this->semanticalError( @@ -3488,10 +3484,8 @@ public function FunctionDeclaration() /** * Helper function for FunctionDeclaration grammar rule. - * - * @return FunctionNode */ - private function CustomFunctionDeclaration() + private function CustomFunctionDeclaration(): ?FunctionNode { $token = $this->lexer->lookahead; $funcName = strtolower($token['value']); diff --git a/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php b/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php index 9a2af839d1f..23c7714c445 100644 --- a/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php +++ b/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php @@ -194,13 +194,9 @@ private function isInheritanceSupported(ClassMetadataInfo $classMetadata): bool /** * Gets column alias for a given column. * - * @param string $columnName - * @param int $mode * @psalm-param array $customRenameColumns - * - * @return string */ - private function getColumnAlias($columnName, $mode, array $customRenameColumns) + private function getColumnAlias(string $columnName, int $mode, array $customRenameColumns): string { switch ($mode) { case self::COLUMN_RENAMING_INCREMENT: @@ -211,6 +207,12 @@ private function getColumnAlias($columnName, $mode, array $customRenameColumns) case self::COLUMN_RENAMING_NONE: return $columnName; + + default: + throw new InvalidArgumentException(sprintf( + '%d is not a valid value for $mode', + $mode + )); } } @@ -219,15 +221,18 @@ private function getColumnAlias($columnName, $mode, array $customRenameColumns) * * This depends on the renaming mode selected by the user. * - * @param string $className - * @param int $mode + * @psalm-param class-string $className + * @psalm-param self::COLUMN_RENAMING_* $mode * @psalm-param array $customRenameColumns * * @return string[] * @psalm-return array */ - private function getColumnAliasMap($className, $mode, array $customRenameColumns) - { + private function getColumnAliasMap( + string $className, + int $mode, + array $customRenameColumns + ): array { if ($customRenameColumns) { // for BC with 2.2-2.3 API $mode = self::COLUMN_RENAMING_CUSTOM; } diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index fc36b82edd1..e93d463d2fc 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -934,11 +934,11 @@ public function walkRangeVariableDeclaration($rangeVariableDeclaration) /** * Generate appropriate SQL for RangeVariableDeclaration AST node - * - * @param AST\RangeVariableDeclaration $rangeVariableDeclaration */ - private function generateRangeVariableDeclarationSQL($rangeVariableDeclaration, bool $buildNestedJoins): string - { + private function generateRangeVariableDeclarationSQL( + AST\RangeVariableDeclaration $rangeVariableDeclaration, + bool $buildNestedJoins + ): string { $class = $this->em->getClassMetadata($rangeVariableDeclaration->abstractSchemaName); $dqlAlias = $rangeVariableDeclaration->aliasIdentificationVariable; @@ -2352,8 +2352,10 @@ public function walkResultVariable($resultVariable) * * @throws QueryException */ - private function getChildDiscriminatorsFromClassMetadata(ClassMetadataInfo $rootClass, AST\InstanceOfExpression $instanceOfExpr): string - { + private function getChildDiscriminatorsFromClassMetadata( + ClassMetadataInfo $rootClass, + AST\InstanceOfExpression $instanceOfExpr + ): string { $sqlParameterList = []; $discriminators = []; foreach ($instanceOfExpr->value as $parameter) { diff --git a/lib/Doctrine/ORM/QueryBuilder.php b/lib/Doctrine/ORM/QueryBuilder.php index 365ac4a570c..6541f8c2420 100644 --- a/lib/Doctrine/ORM/QueryBuilder.php +++ b/lib/Doctrine/ORM/QueryBuilder.php @@ -292,7 +292,7 @@ public function getType() /** * Gets the associated EntityManager for this query builder. * - * @return EntityManager + * @return EntityManagerInterface */ public function getEntityManager() { @@ -393,10 +393,8 @@ public function getQuery() * * @param string $alias The alias of the new join entity * @param string $parentAlias The parent entity alias of the join relationship - * - * @return string */ - private function findRootAlias($alias, $parentAlias) + private function findRootAlias(string $alias, string $parentAlias): string { $rootAlias = null; @@ -1388,10 +1386,7 @@ public function getDQLParts() return $this->_dqlParts; } - /** - * @return string - */ - private function getDQLForDelete() + private function getDQLForDelete(): string { return 'DELETE' . $this->getReducedDQLQueryPart('from', ['pre' => ' ', 'separator' => ', ']) @@ -1399,10 +1394,7 @@ private function getDQLForDelete() . $this->getReducedDQLQueryPart('orderBy', ['pre' => ' ORDER BY ', 'separator' => ', ']); } - /** - * @return string - */ - private function getDQLForUpdate() + private function getDQLForUpdate(): string { return 'UPDATE' . $this->getReducedDQLQueryPart('from', ['pre' => ' ', 'separator' => ', ']) @@ -1411,10 +1403,7 @@ private function getDQLForUpdate() . $this->getReducedDQLQueryPart('orderBy', ['pre' => ' ORDER BY ', 'separator' => ', ']); } - /** - * @return string - */ - private function getDQLForSelect() + private function getDQLForSelect(): string { $dql = 'SELECT' . ($this->_dqlParts['distinct'] === true ? ' DISTINCT' : '') diff --git a/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php b/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php index 53a1b017cb1..f7fe2476a42 100644 --- a/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php +++ b/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php @@ -40,7 +40,7 @@ final class DefaultRepositoryFactory implements RepositoryFactory /** * {@inheritdoc} */ - public function getRepository(EntityManagerInterface $entityManager, $entityName) + public function getRepository(EntityManagerInterface $entityManager, $entityName): ObjectRepository { $repositoryHash = $entityManager->getClassMetadata($entityName)->getName() . spl_object_hash($entityManager); @@ -56,11 +56,11 @@ public function getRepository(EntityManagerInterface $entityManager, $entityName * * @param EntityManagerInterface $entityManager The EntityManager instance. * @param string $entityName The name of the entity. - * - * @return ObjectRepository */ - private function createRepository(EntityManagerInterface $entityManager, $entityName) - { + private function createRepository( + EntityManagerInterface $entityManager, + string $entityName + ): ObjectRepository { $metadata = $entityManager->getClassMetadata($entityName); $repositoryClassName = $metadata->customRepositoryClassName ?: $entityManager->getConfiguration()->getDefaultRepositoryClassName(); diff --git a/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php index 02b95ea16f2..87fffe0f4d7 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php @@ -58,10 +58,7 @@ */ final class MappingDescribeCommand extends AbstractEntityManagerCommand { - /** - * {@inheritdoc} - */ - protected function configure() + protected function configure(): void { $this->setName('orm:mapping:describe') ->addArgument('entityName', InputArgument::REQUIRED, 'Full or partial name of entity') @@ -79,10 +76,7 @@ protected function configure() ); } - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $ui = new SymfonyStyle($input, $output); @@ -97,11 +91,12 @@ protected function execute(InputInterface $input, OutputInterface $output) * Display all the mapping information for a single Entity. * * @param string $entityName Full or partial entity class name - * - * @return void */ - private function displayEntity($entityName, EntityManagerInterface $entityManager, SymfonyStyle $ui) - { + private function displayEntity( + string $entityName, + EntityManagerInterface $entityManager, + SymfonyStyle $ui + ): void { $metadata = $this->getClassMetadata($entityName, $entityManager); $ui->table( @@ -172,11 +167,11 @@ private function getMappedEntities(EntityManagerInterface $entityManager): array * name * * @param string $entityName Full or partial entity name - * - * @return ClassMetadata */ - private function getClassMetadata($entityName, EntityManagerInterface $entityManager) - { + private function getClassMetadata( + string $entityName, + EntityManagerInterface $entityManager + ): ClassMetadata { try { return $entityManager->getClassMetadata($entityName); } catch (MappingException $e) { @@ -211,10 +206,8 @@ static function ($mappedEntity) use ($entityName) { * Format the given value for console output * * @param mixed $value - * - * @return string */ - private function formatValue($value) + private function formatValue($value): string { if ($value === '') { return ''; @@ -256,7 +249,7 @@ private function formatValue($value) * @return string[] * @psalm-return array{0: string, 1: string} */ - private function formatField($label, $value): array + private function formatField(string $label, $value): array { if ($value === null) { $value = 'None'; diff --git a/lib/Doctrine/ORM/Tools/ConvertDoctrine1Schema.php b/lib/Doctrine/ORM/Tools/ConvertDoctrine1Schema.php index d1a1f162dd5..7c1a0cf8274 100644 --- a/lib/Doctrine/ORM/Tools/ConvertDoctrine1Schema.php +++ b/lib/Doctrine/ORM/Tools/ConvertDoctrine1Schema.php @@ -106,8 +106,10 @@ public function getMetadata() /** * @param mixed[] $mappingInformation */ - private function convertToClassMetadataInfo(string $className, $mappingInformation): ClassMetadataInfo - { + private function convertToClassMetadataInfo( + string $className, + array $mappingInformation + ): ClassMetadataInfo { $metadata = new ClassMetadataInfo($className); $this->convertTableName($className, $mappingInformation, $metadata); @@ -136,13 +138,13 @@ private function convertTableName(string $className, array $model, ClassMetadata } /** - * @param string $className * @param mixed[] $model - * - * @return void */ - private function convertColumns($className, array $model, ClassMetadataInfo $metadata) - { + private function convertColumns( + string $className, + array $model, + ClassMetadataInfo $metadata + ): void { $id = false; if (isset($model['columns']) && $model['columns']) { @@ -168,16 +170,18 @@ private function convertColumns($className, array $model, ClassMetadataInfo $met } /** - * @param string $className - * @param string $name * @param string|mixed[] $column * * @return mixed[] * * @throws ToolsException */ - private function convertColumn($className, $name, $column, ClassMetadataInfo $metadata) - { + private function convertColumn( + string $className, + string $name, + $column, + ClassMetadataInfo $metadata + ): array { if (is_string($column)) { $string = $column; $column = []; @@ -258,13 +262,13 @@ private function convertColumn($className, $name, $column, ClassMetadataInfo $me } /** - * @param string $className * @param mixed[] $model - * - * @return void */ - private function convertIndexes($className, array $model, ClassMetadataInfo $metadata) - { + private function convertIndexes( + string $className, + array $model, + ClassMetadataInfo $metadata + ): void { if (empty($model['indexes'])) { return; } @@ -280,13 +284,13 @@ private function convertIndexes($className, array $model, ClassMetadataInfo $met } /** - * @param string $className * @param mixed[] $model - * - * @return void */ - private function convertRelations($className, array $model, ClassMetadataInfo $metadata) - { + private function convertRelations( + string $className, + array $model, + ClassMetadataInfo $metadata + ): void { if (empty($model['relations'])) { return; } diff --git a/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php b/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php index f9a9b046aba..e4ee09ae2b0 100644 --- a/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php +++ b/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php @@ -137,10 +137,8 @@ public function dumpIdentityMap(EntityManagerInterface $em) /** * @param mixed $var - * - * @return string */ - private function getType($var) + private function getType($var): string { if (is_object($var)) { $refl = new ReflectionObject($var); @@ -153,10 +151,8 @@ private function getType($var) /** * @param object $entity - * - * @return string */ - private function getIdString($entity, UnitOfWork $uow) + private function getIdString($entity, UnitOfWork $uow): string { if ($uow->isInIdentityMap($entity)) { $ids = $uow->getEntityIdentifier($entity); diff --git a/lib/Doctrine/ORM/Tools/EntityGenerator.php b/lib/Doctrine/ORM/Tools/EntityGenerator.php index 959d02d23fb..a10e165dba0 100644 --- a/lib/Doctrine/ORM/Tools/EntityGenerator.php +++ b/lib/Doctrine/ORM/Tools/EntityGenerator.php @@ -747,10 +747,7 @@ protected function generateEntityConstructor(ClassMetadataInfo $metadata) return ''; } - /** - * @return string - */ - private function generateEmbeddableConstructor(ClassMetadataInfo $metadata) + private function generateEmbeddableConstructor(ClassMetadataInfo $metadata): string { $paramTypes = []; $paramVariables = []; diff --git a/lib/Doctrine/ORM/Tools/EntityRepositoryGenerator.php b/lib/Doctrine/ORM/Tools/EntityRepositoryGenerator.php index 6bf9baf7fcd..cc8852f7ec3 100644 --- a/lib/Doctrine/ORM/Tools/EntityRepositoryGenerator.php +++ b/lib/Doctrine/ORM/Tools/EntityRepositoryGenerator.php @@ -96,11 +96,9 @@ public function generateEntityRepositoryClass($fullClassName) /** * Generates the namespace, if class do not have namespace, return empty string instead. * - * @param string $fullClassName - * - * @return string $namespace + * @psalm-param class-string $fullClassName */ - private function getClassNamespace($fullClassName) + private function getClassNamespace(string $fullClassName): string { return substr($fullClassName, 0, strrpos($fullClassName, '\\')); } @@ -108,11 +106,9 @@ private function getClassNamespace($fullClassName) /** * Generates the class name * - * @param string $fullClassName - * - * @return string + * @psalm-param class-string $fullClassName */ - private function generateClassName($fullClassName) + private function generateClassName(string $fullClassName): string { $namespace = $this->getClassNamespace($fullClassName); @@ -128,23 +124,16 @@ private function generateClassName($fullClassName) /** * Generates the namespace statement, if class do not have namespace, return empty string instead. * - * @param string $fullClassName The full repository class name. - * - * @return string + * @psalm-param class-string $fullClassName The full repository class name. */ - private function generateEntityRepositoryNamespace($fullClassName) + private function generateEntityRepositoryNamespace(string $fullClassName): string { $namespace = $this->getClassNamespace($fullClassName); return $namespace ? 'namespace ' . $namespace . ';' : ''; } - /** - * @param string $fullClassName - * - * @return string $repositoryName - */ - private function generateEntityRepositoryName($fullClassName) + private function generateEntityRepositoryName(string $fullClassName): string { $namespace = $this->getClassNamespace($fullClassName); diff --git a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php index 6a80ddfc40f..a47a018dd0a 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php @@ -128,10 +128,8 @@ public function __construct($query, $parserResult, array $queryComponents) /** * Check if the platform supports the ROW_NUMBER window function. - * - * @return bool */ - private function platformSupportsRowNumber() + private function platformSupportsRowNumber(): bool { return $this->platform instanceof PostgreSqlPlatform || $this->platform instanceof SQLServerPlatform @@ -145,10 +143,8 @@ private function platformSupportsRowNumber() /** * Rebuilds a select statement's order by clause for use in a * ROW_NUMBER() OVER() expression. - * - * @return void */ - private function rebuildOrderByForRowNumber(SelectStatement $AST) + private function rebuildOrderByForRowNumber(SelectStatement $AST): void { $orderByClause = $AST->orderByClause; $selectAliasToExpressionMap = []; @@ -307,10 +303,8 @@ public function walkSelectStatementWithoutRowNumber(SelectStatement $AST, $addMi /** * Finds all PathExpressions in an AST's OrderByClause, and ensures that * the referenced fields are present in the SelectClause of the passed AST. - * - * @return void */ - private function addMissingItemsFromOrderByToSelect(SelectStatement $AST) + private function addMissingItemsFromOrderByToSelect(SelectStatement $AST): void { $this->orderByPathExpressions = []; @@ -490,12 +484,10 @@ public function getOrderByPathExpressions() } /** - * @return string - * * @throws OptimisticLockException * @throws QueryException */ - private function getInnerSQL(SelectStatement $AST) + private function getInnerSQL(SelectStatement $AST): string { // Set every select expression as visible(hidden = false) to // make $AST have scalar mappings properly - this is relevant for referencing selected @@ -520,7 +512,7 @@ private function getInnerSQL(SelectStatement $AST) /** * @return string[] */ - private function getSQLIdentifier(SelectStatement $AST) + private function getSQLIdentifier(SelectStatement $AST): array { // Find out the SQL alias of the identifier column of the root entity. // It may be possible to make this work with multiple root entities but that diff --git a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php index 129f3dcc140..694d06b4d3b 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php @@ -24,6 +24,7 @@ use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\ORM\Query; use Doctrine\ORM\Query\AST\Functions\IdentityFunction; +use Doctrine\ORM\Query\AST\Node; use Doctrine\ORM\Query\AST\PathExpression; use Doctrine\ORM\Query\AST\SelectExpression; use Doctrine\ORM\Query\AST\SelectStatement; @@ -121,10 +122,8 @@ public function walkSelectStatement(SelectStatement $AST) /** * Validate the AST to ensure that this walker is able to properly manipulate it. - * - * @return void */ - private function validate(SelectStatement $AST) + private function validate(SelectStatement $AST): void { // Prevent LimitSubqueryWalker from being used with queries that include // a limit, a fetched to-many join, and an order by condition that @@ -165,7 +164,7 @@ private function validate(SelectStatement $AST) * * @return IdentityFunction|PathExpression */ - private function createSelectExpressionItem(PathExpression $pathExpression) + private function createSelectExpressionItem(PathExpression $pathExpression): Node { if ($pathExpression->type === PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION) { $identity = new IdentityFunction('identity'); diff --git a/lib/Doctrine/ORM/Tools/Pagination/Paginator.php b/lib/Doctrine/ORM/Tools/Pagination/Paginator.php index d7387faa4fa..318e0ef4c69 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/Paginator.php +++ b/lib/Doctrine/ORM/Tools/Pagination/Paginator.php @@ -181,14 +181,7 @@ public function getIterator() return new ArrayIterator($result); } - /** - * Clones a query. - * - * @param Query $query The query. - * - * @return Query The cloned query. - */ - private function cloneQuery(Query $query) + private function cloneQuery(Query $query): Query { $cloneQuery = clone $query; @@ -204,12 +197,8 @@ private function cloneQuery(Query $query) /** * Determines whether to use an output walker for the query. - * - * @param Query $query The query. - * - * @return bool */ - private function useOutputWalker(Query $query) + private function useOutputWalker(Query $query): bool { if ($this->useOutputWalkers === null) { return (bool) $query->getHint(Query::HINT_CUSTOM_OUTPUT_WALKER) === false; @@ -221,11 +210,9 @@ private function useOutputWalker(Query $query) /** * Appends a custom tree walker to the tree walkers hint. * - * @param string $walkerClass - * - * @return void + * @psalm-param class-string $walkerClass */ - private function appendTreeWalker(Query $query, $walkerClass) + private function appendTreeWalker(Query $query, string $walkerClass): void { $hints = $query->getHint(Query::HINT_CUSTOM_TREE_WALKERS); @@ -239,10 +226,8 @@ private function appendTreeWalker(Query $query, $walkerClass) /** * Returns Query prepared to count. - * - * @return Query */ - private function getCountQuery() + private function getCountQuery(): Query { $countQuery = $this->cloneQuery($this->query); diff --git a/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php b/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php index 4218020b906..63b75fc1f07 100644 --- a/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php +++ b/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php @@ -25,7 +25,6 @@ use Doctrine\ORM\Event\OnClassMetadataNotFoundEventArgs; use Doctrine\ORM\Events; use Doctrine\ORM\Mapping\ClassMetadata; -use Doctrine\ORM\Mapping\ClassMetadataInfo; use function array_key_exists; use function array_replace_recursive; @@ -109,12 +108,9 @@ public function loadClassMetadata(LoadClassMetadataEventArgs $args) } /** - * @param ClassMetadataInfo $classMetadata - * @param mixed[] $mapping - * - * @return void + * @param mixed[] $mapping */ - private function remapAssociation($classMetadata, $mapping) + private function remapAssociation(ClassMetadata $classMetadata, array $mapping): void { $newMapping = $this->resolveTargetEntities[$mapping['targetEntity']]; $newMapping = array_replace_recursive($mapping, $newMapping); diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index 2ccbede124c..f952ba1475c 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -422,12 +422,8 @@ static function (ClassMetadata $class) use ($idMapping): bool { /** * Gets a portable column definition as required by the DBAL for the discriminator * column of a class. - * - * @param ClassMetadata $class - * - * @return void */ - private function addDiscriminatorColumnDefinition($class, Table $table) + private function addDiscriminatorColumnDefinition(ClassMetadata $class, Table $table): void { $discrColumn = $class->discriminatorColumn; @@ -454,12 +450,8 @@ private function addDiscriminatorColumnDefinition($class, Table $table) /** * Gathers the column definitions as required by the DBAL of all field mappings * found in the given class. - * - * @param ClassMetadata $class - * - * @return void */ - private function gatherColumns($class, Table $table) + private function gatherColumns(ClassMetadata $class, Table $table): void { $pkColumns = []; diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 12ad28277a8..8bf26fd5f00 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -513,10 +513,8 @@ private function postCommitCleanup($entity): void /** * Computes the changesets of all entities scheduled for insertion. - * - * @return void */ - private function computeScheduleInsertsChangeSets() + private function computeScheduleInsertsChangeSets(): void { foreach ($this->entityInsertions as $entity) { $class = $this->em->getClassMetadata(get_class($entity)); @@ -535,11 +533,9 @@ private function computeScheduleInsertsChangeSets() * * @param object $entity * - * @return void - * * @throws InvalidArgumentException */ - private function computeSingleEntityChangeSet($entity) + private function computeSingleEntityChangeSet($entity): void { $state = $this->getEntityState($entity); @@ -964,12 +960,9 @@ private function computeAssociationChanges(array $assoc, $value): void } /** - * @param ClassMetadata $class - * @param object $entity - * - * @return void + * @param object $entity */ - private function persistNew($class, $entity) + private function persistNew(ClassMetadata $class, $entity): void { $oid = spl_object_hash($entity); $invoke = $this->listenersInvoker->getSubscribedSystems($class, Events::prePersist); @@ -1091,12 +1084,8 @@ public function recomputeSingleEntityChangeSet(ClassMetadata $class, $entity) /** * Executes all entity insertions for entities of the specified type. - * - * @param ClassMetadata $class - * - * @return void */ - private function executeInserts($class) + private function executeInserts(ClassMetadata $class): void { $entities = []; $className = $class->name; @@ -1158,8 +1147,11 @@ private function executeInserts($class) /** * @param object $entity */ - private function addToEntityIdentifiersAndEntityMap(ClassMetadata $class, string $oid, $entity): void - { + private function addToEntityIdentifiersAndEntityMap( + ClassMetadata $class, + string $oid, + $entity + ): void { $identifier = []; foreach ($class->getIdentifierFieldNames() as $idField) { @@ -1181,12 +1173,8 @@ private function addToEntityIdentifiersAndEntityMap(ClassMetadata $class, string /** * Executes all entity updates for entities of the specified type. - * - * @param ClassMetadata $class - * - * @return void */ - private function executeUpdates($class) + private function executeUpdates(ClassMetadata $class): void { $className = $class->name; $persister = $this->getEntityPersister($className); @@ -1218,12 +1206,8 @@ private function executeUpdates($class) /** * Executes all entity deletions for entities of the specified type. - * - * @param ClassMetadata $class - * - * @return void */ - private function executeDeletions($class) + private function executeDeletions(ClassMetadata $class): void { $className = $class->name; $persister = $this->getEntityPersister($className); @@ -1931,6 +1915,7 @@ public function merge($entity) /** * Executes a merge operation on an entity. * + * @param object $entity * @param string[] $assoc * @psalm-param array $visited * @@ -1942,7 +1927,7 @@ public function merge($entity) * @throws EntityNotFoundException if an assigned identifier is used in the entity, but none is provided. */ private function doMerge( - object $entity, + $entity, array &$visited, ?object $prevManagedCopy = null, array $assoc = [] @@ -2038,12 +2023,13 @@ private function doMerge( * @param object $entity * @param object $managedCopy * - * @return void - * * @throws OptimisticLockException */ - private function ensureVersionMatch(ClassMetadata $class, $entity, $managedCopy) - { + private function ensureVersionMatch( + ClassMetadata $class, + $entity, + $managedCopy + ): void { if (! ($class->isVersioned && $this->isLoaded($managedCopy) && $this->isLoaded($entity))) { return; } @@ -2065,10 +2051,8 @@ private function ensureVersionMatch(ClassMetadata $class, $entity, $managedCopy) * Tests if an entity is loaded - must either be a loaded proxy or not a proxy * * @param object $entity - * - * @return bool */ - private function isLoaded($entity) + private function isLoaded($entity): bool { return ! ($entity instanceof Proxy) || $entity->__isInitialized(); } @@ -2076,10 +2060,11 @@ private function isLoaded($entity) /** * Sets/adds associated managed copies into the previous entity's association field * + * @param object $entity * @param string[] $association */ private function updateAssociationWithMergedEntity( - object $entity, + $entity, array $association, object $previousManagedCopy, object $managedCopy @@ -2121,14 +2106,15 @@ public function detach($entity) /** * Executes a detach operation on the given entity. * - * @param object $entity + * @param object $entity * @param mixed[] $visited * @param bool $noCascade if true, don't cascade detach operation. - * - * @return void */ - private function doDetach($entity, array &$visited, $noCascade = false) - { + private function doDetach( + $entity, + array &$visited, + bool $noCascade = false + ): void { $oid = spl_object_hash($entity); if (isset($visited[$oid])) { @@ -2257,9 +2243,10 @@ static function ($assoc) { /** * Cascades a detach operation to associated entities. * + * @param object $entity * @param array $visited */ - private function cascadeDetach(object $entity, array &$visited): void + private function cascadeDetach($entity, array &$visited): void { $class = $this->em->getClassMetadata(get_class($entity)); @@ -2300,9 +2287,11 @@ static function ($assoc) { /** * Cascades a merge operation to associated entities. * + * @param object $entity + * @param object $managedCopy * @psalm-param array $visited */ - private function cascadeMerge(object $entity, object $managedCopy, array &$visited): void + private function cascadeMerge($entity, $managedCopy, array &$visited): void { $class = $this->em->getClassMetadata(get_class($entity)); @@ -2338,9 +2327,10 @@ static function ($assoc) { /** * Cascades the save operation to associated entities. * + * @param object $entity * @psalm-param array $visited */ - private function cascadePersist(object $entity, array &$visited): void + private function cascadePersist($entity, array &$visited): void { $class = $this->em->getClassMetadata(get_class($entity)); @@ -2397,9 +2387,10 @@ static function ($assoc) { /** * Cascades the delete operation to associated entities. * + * @param object $entity * @psalm-param array $visited */ - private function cascadeRemove(object $entity, array &$visited): void + private function cascadeRemove($entity, array &$visited): void { $class = $this->em->getClassMetadata(get_class($entity)); @@ -2609,12 +2600,7 @@ public function isCollectionScheduledForDeletion(PersistentCollection $coll) return isset($this->collectionDeletions[spl_object_hash($coll)]); } - /** - * @param ClassMetadata $class - * - * @return ObjectManagerAware|object - */ - private function newInstance($class) + private function newInstance(ClassMetadata $class): object { $entity = $class->newInstance(); diff --git a/lib/Doctrine/ORM/Utility/IdentifierFlattener.php b/lib/Doctrine/ORM/Utility/IdentifierFlattener.php index 954501d4a4b..216fd66cb05 100644 --- a/lib/Doctrine/ORM/Utility/IdentifierFlattener.php +++ b/lib/Doctrine/ORM/Utility/IdentifierFlattener.php @@ -64,7 +64,7 @@ public function __construct(UnitOfWork $unitOfWork, ClassMetadataFactory $metada * * @psalm-return array */ - public function flattenIdentifier(ClassMetadata $class, array $id) + public function flattenIdentifier(ClassMetadata $class, array $id): array { $flatId = []; diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 233551005ed..47edd183c51 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -405,11 +405,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php - - - message: "#^Strict comparison using \\=\\=\\= between array and null will always evaluate to false\\.$#" - count: 1 - path: lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php - - message: "#^Access to an undefined property Doctrine\\\\ORM\\\\Proxy\\\\Proxy\\:\\:\\$__isInitialized__\\.$#" count: 1 @@ -617,7 +612,7 @@ parameters: - message: "#^Negated boolean expression is always false\\.$#" - count: 4 + count: 3 path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - @@ -1395,14 +1390,9 @@ parameters: count: 2 path: lib/Doctrine/ORM/PersistentCollection.php - - - message: "#^Property Doctrine\\\\ORM\\\\PersistentCollection\\\\:\\:\\$owner \\(object\\) does not accept null\\.$#" - count: 1 - path: lib/Doctrine/ORM/PersistentCollection.php - - message: "#^Right side of && is always true\\.$#" - count: 7 + count: 2 path: lib/Doctrine/ORM/PersistentCollection.php - @@ -1420,31 +1410,11 @@ parameters: count: 1 path: lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php - - - message: "#^Method Doctrine\\\\ORM\\\\Persisters\\\\Entity\\\\BasicEntityPersister\\:\\:getManyToManyStatement\\(\\) should return Doctrine\\\\DBAL\\\\Driver\\\\Statement but returns Doctrine\\\\DBAL\\\\Driver\\\\ResultStatement&Doctrine\\\\DBAL\\\\Result\\.$#" - count: 1 - path: lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php - - - - message: "#^Method Doctrine\\\\ORM\\\\Persisters\\\\Entity\\\\BasicEntityPersister\\:\\:getOneToManyStatement\\(\\) should return Doctrine\\\\DBAL\\\\Statement but returns Doctrine\\\\DBAL\\\\Driver\\\\ResultStatement&Doctrine\\\\DBAL\\\\Result\\.$#" - count: 1 - path: lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php - - message: "#^Parameter \\#1 \\$em of method Doctrine\\\\ORM\\\\Id\\\\AbstractIdGenerator\\:\\:generate\\(\\) expects Doctrine\\\\ORM\\\\EntityManager, Doctrine\\\\ORM\\\\EntityManagerInterface given\\.$#" count: 1 path: lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php - - - message: "#^Parameter \\#2 \\$stmt of method Doctrine\\\\ORM\\\\Persisters\\\\Entity\\\\BasicEntityPersister\\:\\:loadArrayFromStatement\\(\\) expects Doctrine\\\\DBAL\\\\Statement, Doctrine\\\\DBAL\\\\Driver\\\\Statement given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php - - - - message: "#^Parameter \\#2 \\$stmt of method Doctrine\\\\ORM\\\\Persisters\\\\Entity\\\\BasicEntityPersister\\:\\:loadCollectionFromStatement\\(\\) expects Doctrine\\\\DBAL\\\\Statement, Doctrine\\\\DBAL\\\\Driver\\\\Statement given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php - - message: "#^Parameter \\#3 \\$hints of method Doctrine\\\\ORM\\\\Internal\\\\Hydration\\\\AbstractHydrator\\:\\:hydrateAll\\(\\) expects array\\, array\\ given\\.$#" count: 1 @@ -1515,21 +1485,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Query.php - - - message: "#^Method Doctrine\\\\ORM\\\\QueryBuilder\\:\\:getEntityManager\\(\\) should return Doctrine\\\\ORM\\\\EntityManager but returns Doctrine\\\\ORM\\\\EntityManagerInterface\\.$#" - count: 1 - path: lib/Doctrine/ORM/QueryBuilder.php - - - - message: "#^PHPDoc tag @param references unknown parameter\\: \\$where$#" - count: 2 - path: lib/Doctrine/ORM/QueryBuilder.php - - - - message: "#^Parameter \\#2 \\$dqlPart of method Doctrine\\\\ORM\\\\QueryBuilder\\:\\:add\\(\\) expects array\\<'join'\\|int, array\\\\|string\\>\\|object\\|string, array\\ given\\.$#" - count: 2 - path: lib/Doctrine/ORM/QueryBuilder.php - - message: "#^Access to an undefined property Doctrine\\\\ORM\\\\Query\\\\AST\\\\Node\\:\\:\\$value\\.$#" count: 1 @@ -1695,11 +1650,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Query/Parser.php - - - message: "#^Method Doctrine\\\\ORM\\\\Query\\\\Parser\\:\\:CustomFunctionDeclaration\\(\\) should return Doctrine\\\\ORM\\\\Query\\\\AST\\\\Functions\\\\FunctionNode but returns null\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/Parser.php - - message: """ @@ -1737,13 +1687,13 @@ parameters: path: lib/Doctrine/ORM/Query/Parser.php - - message: "#^Method Doctrine\\\\ORM\\\\Query\\\\ResultSetMappingBuilder\\:\\:getColumnAlias\\(\\) should return string but return statement is missing\\.$#" + message: "#^Parameter \\#2 \\$class of static method Doctrine\\\\ORM\\\\Utility\\\\PersisterHelper\\:\\:getTypeOfColumn\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata, Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataInfo given\\.$#" count: 1 path: lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php - - message: "#^Parameter \\#2 \\$class of static method Doctrine\\\\ORM\\\\Utility\\\\PersisterHelper\\:\\:getTypeOfColumn\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata, Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataInfo given\\.$#" - count: 1 + message: "#^Parameter \\#2 \\$mode of method Doctrine\\\\ORM\\\\Query\\\\ResultSetMappingBuilder\\:\\:getColumnAliasMap\\(\\) expects 1\\|2\\|3, int given\\.$#" + count: 2 path: lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php - @@ -2286,6 +2236,16 @@ parameters: count: 1 path: lib/Doctrine/ORM/Query/TreeWalkerChainIterator.php + - + message: "#^PHPDoc tag @param references unknown parameter\\: \\$where$#" + count: 2 + path: lib/Doctrine/ORM/QueryBuilder.php + + - + message: "#^Parameter \\#2 \\$dqlPart of method Doctrine\\\\ORM\\\\QueryBuilder\\:\\:add\\(\\) expects array\\<'join'\\|int, array\\\\|string\\>\\|object\\|string, array\\ given\\.$#" + count: 2 + path: lib/Doctrine/ORM/QueryBuilder.php + - message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#" count: 1 @@ -2546,11 +2506,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/UnitOfWork.php - - - message: "#^Strict comparison using \\=\\=\\= between object and null will always evaluate to false\\.$#" - count: 1 - path: lib/Doctrine/ORM/UnitOfWork.php - - message: "#^Strict comparison using \\=\\=\\= between string and 4 will always evaluate to false\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index b8283906d46..39b4287aecc 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -368,10 +368,6 @@ - - $paramMappings - $sqlPositions - mixed @@ -379,9 +375,6 @@ $hydrationMode $parameters - - $sqlPositions - @@ -426,8 +419,7 @@ $this->identVariableExpressions[$dqlAlias] $this->queryComponents[$dqlAlias] - - FunctionNode + SelectStatement|UpdateStatement|DeleteStatement @@ -448,7 +440,7 @@ AST\BetweenExpression| ArithmeticFactor - + $aliasIdentVariable $factors[0] $identVariable @@ -458,14 +450,8 @@ $terms[0] $this->lexer->token['value'] $this->lexer->token['value'] - null - - - string - - $selectedClass['class']->name