diff --git a/lib/Doctrine/ORM/Cache/CacheFactory.php b/lib/Doctrine/ORM/Cache/CacheFactory.php index 60bd582c1d9..3d3e5928cef 100644 --- a/lib/Doctrine/ORM/Cache/CacheFactory.php +++ b/lib/Doctrine/ORM/Cache/CacheFactory.php @@ -14,6 +14,8 @@ /** * Contract for building second level cache regions components. + * + * @psalm-import-type AssociationMapping from ClassMetadata */ interface CacheFactory { @@ -31,7 +33,7 @@ public function buildCachedEntityPersister(EntityManagerInterface $em, EntityPer /** * Build a collection persister for the given relation mapping. * - * @param mixed[] $mapping The association mapping. + * @param AssociationMapping $mapping The association mapping. * * @return CachedCollectionPersister */ diff --git a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php index d16c46dbee0..40d398292c0 100644 --- a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php +++ b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php @@ -138,6 +138,7 @@ public function buildCachedEntityPersister(EntityManagerInterface $em, EntityPer */ public function buildCachedCollectionPersister(EntityManagerInterface $em, CollectionPersister $persister, array $mapping) { + assert(isset($mapping['cache'])); $usage = $mapping['cache']['usage']; $region = $this->getRegion($mapping['cache']); diff --git a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php index dab2722b638..d571f53f053 100644 --- a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php +++ b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php @@ -29,6 +29,8 @@ /** * Default query cache implementation. + * + * @psalm-import-type AssociationMapping from ClassMetadata */ class DefaultQueryCache implements QueryCache { @@ -326,8 +328,8 @@ public function put(QueryCacheKey $key, ResultSetMapping $rsm, $result, array $h } /** - * @param array $assoc - * @param mixed $assocValue + * @param AssociationMapping $assoc + * @param mixed $assocValue * * @return mixed[]|null * @psalm-return array{targetEntity: class-string, type: mixed, list?: array[], identifier?: array}|null diff --git a/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php b/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php index 1e22c220306..a4391c4bd71 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php @@ -25,6 +25,7 @@ use function assert; use function count; +/** @psalm-import-type AssociationMapping from ClassMetadata */ abstract class AbstractCollectionPersister implements CachedCollectionPersister { /** @var UnitOfWork */ @@ -64,7 +65,7 @@ abstract class AbstractCollectionPersister implements CachedCollectionPersister * @param CollectionPersister $persister The collection persister that will be cached. * @param Region $region The collection region. * @param EntityManagerInterface $em The entity manager. - * @param mixed[] $association The association mapping. + * @param AssociationMapping $association The association mapping. */ public function __construct(CollectionPersister $persister, Region $region, EntityManagerInterface $em, array $association) { diff --git a/lib/Doctrine/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersister.php b/lib/Doctrine/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersister.php index 4832adcde9c..fdae26caa7f 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersister.php @@ -7,14 +7,16 @@ use Doctrine\ORM\Cache\CollectionCacheKey; use Doctrine\ORM\Cache\ConcurrentRegion; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\Persisters\Collection\CollectionPersister; use function spl_object_id; +/** @psalm-import-type AssociationMapping from ClassMetadata */ class ReadWriteCachedCollectionPersister extends AbstractCollectionPersister { - /** @param mixed[] $association The association mapping. */ + /** @param AssociationMapping $association The association mapping. */ public function __construct(CollectionPersister $persister, ConcurrentRegion $region, EntityManagerInterface $em, array $association) { parent::__construct($persister, $region, $em, $association); diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index 5f969d33ce4..0bd629084d6 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -1855,30 +1855,7 @@ protected function _validateAndCompleteAssociationMapping(array $mapping) * @psalm-param array $mapping The mapping to validate & complete. * * @return mixed[] The validated & completed mapping. - * @psalm-return array{ - * mappedBy: mixed|null, - * inversedBy: mixed|null, - * isOwningSide: bool, - * sourceEntity: class-string, - * targetEntity: string, - * fieldName: mixed, - * fetch: mixed, - * cascade: array, - * isCascadeRemove: bool, - * isCascadePersist: bool, - * isCascadeRefresh: bool, - * isCascadeMerge: bool, - * isCascadeDetach: bool, - * type: int, - * originalField: string, - * originalClass: class-string, - * joinColumns?: array{0: array{name: string, referencedColumnName: string}}|mixed, - * id?: mixed, - * sourceToTargetKeyColumns?: array, - * joinColumnFieldNames?: array, - * targetToSourceKeyColumns?: array, - * orphanRemoval: bool - * } + * @psalm-return AssociationMapping * * @throws RuntimeException * @throws MappingException @@ -1968,22 +1945,7 @@ protected function _validateAndCompleteOneToOneMapping(array $mapping) * @psalm-param array $mapping The mapping to validate and complete. * * @return mixed[] The validated and completed mapping. - * @psalm-return array{ - * mappedBy: mixed, - * inversedBy: mixed, - * isOwningSide: bool, - * sourceEntity: string, - * targetEntity: string, - * fieldName: mixed, - * fetch: int|mixed, - * cascade: array, - * isCascadeRemove: bool, - * isCascadePersist: bool, - * isCascadeRefresh: bool, - * isCascadeMerge: bool, - * isCascadeDetach: bool, - * orphanRemoval: bool - * } + * @psalm-return AssociationMapping * * @throws MappingException * @throws InvalidArgumentException @@ -2011,30 +1973,7 @@ protected function _validateAndCompleteOneToManyMapping(array $mapping) * @psalm-param array $mapping The mapping to validate & complete. * * @return mixed[] The validated & completed mapping. - * @psalm-return array{ - * mappedBy: mixed, - * inversedBy: mixed, - * isOwningSide: bool, - * sourceEntity: class-string, - * targetEntity: string, - * fieldName: mixed, - * fetch: mixed, - * cascade: array, - * isCascadeRemove: bool, - * isCascadePersist: bool, - * isCascadeRefresh: bool, - * isCascadeMerge: bool, - * isCascadeDetach: bool, - * type: int, - * originalField: string, - * originalClass: class-string, - * joinTable?: array{inverseJoinColumns: mixed}|mixed, - * joinTableColumns?: list, - * isOnDeleteCascade?: true, - * relationToSourceKeyColumns?: array, - * relationToTargetKeyColumns?: array, - * orphanRemoval: bool - * } + * @psalm-return AssociationMapping * * @throws InvalidArgumentException */ @@ -3033,7 +2972,7 @@ public function mapManyToMany(array $mapping) /** * Stores the association mapping. * - * @psalm-param array $assocMapping + * @psalm-param AssociationMapping $assocMapping * * @return void * @@ -3185,7 +3124,7 @@ public function addEntityListener($eventName, $class, $method) * @see getDiscriminatorColumn() * * @param mixed[]|null $columnDef - * @psalm-param array{name: string|null, fieldName?: string, type?: string, length?: int, columnDefinition?: string|null, enumType?: class-string|null}|null $columnDef + * @psalm-param DiscriminatorColumnMapping|array{name: string|null, fieldName?: string, type?: string, length?: int, columnDefinition?: string|null, enumType?: class-string|null}|null $columnDef * * @return void * @@ -3891,7 +3830,7 @@ public function getSequencePrefix(AbstractPlatform $platform) return $sequencePrefix; } - /** @psalm-param array $mapping */ + /** @psalm-param AssociationMapping $mapping */ private function assertMappingOrderBy(array $mapping): void { if (isset($mapping['orderBy']) && ! is_array($mapping['orderBy'])) { diff --git a/lib/Doctrine/ORM/Mapping/QuoteStrategy.php b/lib/Doctrine/ORM/Mapping/QuoteStrategy.php index dcca9670c8c..b3c8a88f6b9 100644 --- a/lib/Doctrine/ORM/Mapping/QuoteStrategy.php +++ b/lib/Doctrine/ORM/Mapping/QuoteStrategy.php @@ -8,6 +8,9 @@ /** * A set of rules for determining the column, alias and table quotes. + * + * @psalm-import-type AssociationMapping from ClassMetadata + * @psalm-import-type JoinColumnData from ClassMetadata */ interface QuoteStrategy { @@ -39,7 +42,7 @@ public function getSequenceName(array $definition, ClassMetadata $class, Abstrac /** * Gets the (possibly quoted) name of the join table. * - * @param mixed[] $association + * @param AssociationMapping $association * * @return string */ @@ -48,7 +51,7 @@ public function getJoinTableName(array $association, ClassMetadata $class, Abstr /** * Gets the (possibly quoted) join column name. * - * @param mixed[] $joinColumn + * @param JoinColumnData $joinColumn * * @return string */ @@ -57,7 +60,7 @@ public function getJoinColumnName(array $joinColumn, ClassMetadata $class, Abstr /** * Gets the (possibly quoted) join column name. * - * @param mixed[] $joinColumn + * @param JoinColumnData $joinColumn * * @return string */ diff --git a/lib/Doctrine/ORM/ORMInvalidArgumentException.php b/lib/Doctrine/ORM/ORMInvalidArgumentException.php index edf047a82b7..e09114c0e7f 100644 --- a/lib/Doctrine/ORM/ORMInvalidArgumentException.php +++ b/lib/Doctrine/ORM/ORMInvalidArgumentException.php @@ -82,8 +82,8 @@ public static function readOnlyRequiresManagedEntity($entity) } /** - * @param array[][]|object[][] $newEntitiesWithAssociations non-empty an array - * of [array $associationMapping, object $entity] pairs + * @psalm-param non-empty-list $newEntitiesWithAssociations non-empty an array + * of [array $associationMapping, object $entity] pairs * * @return ORMInvalidArgumentException */ @@ -122,7 +122,7 @@ public static function newEntityFoundThroughRelationship(array $associationMappi /** * @param object $entry - * @psalm-param array $assoc + * @psalm-param AssociationMapping $assoc * * @return ORMInvalidArgumentException */ @@ -222,8 +222,8 @@ public static function invalidIdentifierBindingEntity(/* string $class */) } /** - * @param mixed[] $assoc - * @param mixed $actualValue + * @param AssociationMapping $assoc + * @param mixed $actualValue * * @return self */ diff --git a/lib/Doctrine/ORM/PersistentCollection.php b/lib/Doctrine/ORM/PersistentCollection.php index 36a5d806efd..9701cd7e378 100644 --- a/lib/Doctrine/ORM/PersistentCollection.php +++ b/lib/Doctrine/ORM/PersistentCollection.php @@ -36,6 +36,7 @@ * @psalm-template T * @template-extends AbstractLazyCollection * @template-implements Selectable + * @psalm-import-type AssociationMapping from ClassMetadata */ final class PersistentCollection extends AbstractLazyCollection implements Selectable { @@ -58,7 +59,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|null + * @psalm-var AssociationMapping|null */ private $association; @@ -113,7 +114,7 @@ public function __construct(EntityManagerInterface $em, $class, Collection $coll * describes the association between the owner and the elements of the collection. * * @param object $entity - * @psalm-param array $assoc + * @psalm-param AssociationMapping $assoc */ public function setOwner($entity, array $assoc): void { @@ -271,7 +272,7 @@ public function getInsertDiff(): array /** * INTERNAL: Gets the association mapping of the collection. * - * @psalm-return array|null + * @psalm-return AssociationMapping|null */ public function getMapping(): ?array { diff --git a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php index 0508aa2104a..1813319e75c 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php @@ -24,6 +24,8 @@ /** * Persister for many-to-many collections. + * + * @psalm-import-type AssociationMapping from ClassMetadata */ class ManyToManyPersister extends AbstractCollectionPersister { @@ -286,7 +288,7 @@ public function loadCriteria(PersistentCollection $collection, Criteria $criteri * JOIN. * * @param mixed[] $mapping Array containing mapping information. - * @psalm-param array $mapping + * @psalm-param AssociationMapping $mapping * * @return string[] ordered tuple: * - JOIN condition to add to the SQL @@ -339,7 +341,7 @@ protected function generateFilterConditionSQL(ClassMetadata $targetEntity, $targ * Generate ON condition * * @param mixed[] $mapping - * @psalm-param array $mapping + * @psalm-param AssociationMapping $mapping * * @return string[] * @psalm-return list diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index 0b655254dfd..1cc8e57db66 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -87,6 +87,8 @@ * * Subclasses can be created to provide custom persisting and querying strategies, * i.e. spanning multiple tables. + * + * @psalm-import-type AssociationMapping from ClassMetadata */ class BasicEntityPersister implements EntityPersister { @@ -1332,9 +1334,9 @@ protected function getSelectColumnsSQL() /** * Gets the SQL join fragment used when selecting entities from an association. * - * @param string $field - * @param mixed[] $assoc - * @param string $alias + * @param string $field + * @param AssociationMapping $assoc + * @param string $alias * * @return string */ @@ -1366,7 +1368,7 @@ protected function getSelectColumnAssociationSQL($field, $assoc, ClassMetadata $ * Gets the SQL join fragment used when selecting entities from a * many-to-many association. * - * @psalm-param array $manyToMany + * @psalm-param AssociationMapping $manyToMany * * @return string */ @@ -1694,7 +1696,7 @@ public function getSelectConditionStatementSQL($field, $value, $assoc = null, $c /** * Builds the left-hand-side of a where condition statement. * - * @psalm-param array|null $assoc + * @psalm-param AssociationMapping|null $assoc * * @return string[] * @psalm-return list @@ -1767,7 +1769,7 @@ private function getSelectConditionStatementColumnSQL( * Subclasses are supposed to override this method if they intend to change * or alter the criteria by which entities are selected. * - * @param mixed[]|null $assoc + * @param AssociationMapping|null $assoc * @psalm-param array $criteria * @psalm-param array|null $assoc * @@ -1810,7 +1812,7 @@ public function loadOneToManyCollection(array $assoc, $sourceEntity, PersistentC * Builds criteria and execute SQL statement to fetch the one to many entities from. * * @param object $sourceEntity - * @psalm-param array $assoc + * @psalm-param AssociationMapping $assoc */ private function getOneToManyStatement( array $assoc, diff --git a/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php index 8e494118e34..7f9d54450bf 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php @@ -14,6 +14,8 @@ /** * Entity persister interface * Define the behavior that should be implemented by all entity persisters. + * + * @psalm-import-type AssociationMapping from ClassMetadata */ interface EntityPersister { @@ -48,11 +50,11 @@ public function getInsertSQL(); * Gets the SELECT SQL to select one or more entities by a set of field criteria. * * @param mixed[]|Criteria $criteria - * @param mixed[]|null $assoc * @param int|null $lockMode * @param int|null $limit * @param int|null $offset * @param mixed[]|null $orderBy + * @psalm-param AssociationMapping|null $assoc * @psalm-param LockMode::*|null $lockMode * * @return string @@ -87,11 +89,10 @@ public function expandCriteriaParameters(Criteria $criteria); /** * Gets the SQL WHERE condition for matching a field with a given value. * - * @param string $field - * @param mixed $value - * @param mixed[]|null $assoc - * @param string|null $comparison - * @psalm-param array|null $assoc + * @param string $field + * @param mixed $value + * @param AssociationMapping|null $assoc + * @param string|null $comparison * * @return string */ @@ -171,19 +172,18 @@ public function getOwningTable($fieldName); /** * Loads an entity by a list of field criteria. * - * @param mixed[] $criteria The criteria by which to load the entity. - * @param object|null $entity The entity to load the data into. If not specified, - * a new entity is created. - * @param mixed[]|null $assoc The association that connects the entity - * to load to another entity, if any. - * @param mixed[] $hints Hints for entity creation. - * @param int|null $lockMode One of the \Doctrine\DBAL\LockMode::* constants - * or NULL if no specific lock mode should be used - * for loading the entity. - * @param int|null $limit Limit number of results. - * @param string[]|null $orderBy Criteria to order by. + * @param mixed[] $criteria The criteria by which to load the entity. + * @param object|null $entity The entity to load the data into. If not specified, + * a new entity is created. + * @param AssociationMapping|null $assoc The association that connects the entity + * to load to another entity, if any. + * @param mixed[] $hints Hints for entity creation. + * @param int|null $lockMode One of the \Doctrine\DBAL\LockMode::* constants + * or NULL if no specific lock mode should be used + * for loading the entity. + * @param int|null $limit Limit number of results. + * @param string[]|null $orderBy Criteria to order by. * @psalm-param array $criteria - * @psalm-param array|null $assoc * @psalm-param array $hints * @psalm-param LockMode::*|null $lockMode * @psalm-param array|null $orderBy @@ -222,7 +222,7 @@ public function loadById(array $identifier, $entity = null); * @psalm-param array $identifier The identifier of the entity to load. Must be provided if * the association to load represents the owning side, otherwise * the identifier is derived from the $sourceEntity. - * @psalm-param array $assoc The association to load. + * @psalm-param AssociationMapping $assoc The association to load. * * @return object The loaded and managed entity instance or NULL if the entity can not be found. * @@ -269,7 +269,7 @@ public function loadAll(array $criteria = [], ?array $orderBy = null, $limit = n * @param object $sourceEntity * @param int|null $offset * @param int|null $limit - * @psalm-param array $assoc + * @psalm-param AssociationMapping $assoc * * @return mixed[] */ @@ -280,7 +280,7 @@ public function getManyToManyCollection(array $assoc, $sourceEntity, $offset = n * * @param object $sourceEntity The entity that owns the collection. * @param PersistentCollection $collection The collection to fill. - * @psalm-param array $assoc The association mapping of the association being loaded. + * @psalm-param AssociationMapping $assoc The association mapping of the association being loaded. * * @return mixed[] */ @@ -291,7 +291,7 @@ public function loadManyToManyCollection(array $assoc, $sourceEntity, Persistent * * @param object $sourceEntity * @param PersistentCollection $collection The collection to load/fill. - * @psalm-param array $assoc + * @psalm-param AssociationMapping $assoc * * @return mixed */ @@ -314,7 +314,7 @@ public function lock(array $criteria, $lockMode); * @param object $sourceEntity * @param int|null $offset * @param int|null $limit - * @psalm-param array $assoc + * @psalm-param AssociationMapping $assoc * * @return mixed[] */ diff --git a/lib/Doctrine/ORM/Query/Parser.php b/lib/Doctrine/ORM/Query/Parser.php index 490525d9e4d..771c157657c 100644 --- a/lib/Doctrine/ORM/Query/Parser.php +++ b/lib/Doctrine/ORM/Query/Parser.php @@ -35,11 +35,12 @@ * An LL(*) recursive-descent parser for the context-free grammar of the Doctrine Query Language. * Parses a DQL query, reports any errors in it, and generates an AST. * + * @psalm-import-type AssociationMapping from ClassMetadata * @psalm-type DqlToken = Token * @psalm-type QueryComponent = array{ * metadata?: ClassMetadata, * parent?: string|null, - * relation?: mixed[]|null, + * relation?: AssociationMapping|null, * map?: string|null, * resultVariable?: AST\Node|string, * nestingLevel: int, diff --git a/lib/Doctrine/ORM/Query/QueryException.php b/lib/Doctrine/ORM/Query/QueryException.php index b14111fb388..be9b8ed750e 100644 --- a/lib/Doctrine/ORM/Query/QueryException.php +++ b/lib/Doctrine/ORM/Query/QueryException.php @@ -5,10 +5,12 @@ namespace Doctrine\ORM\Query; use Doctrine\ORM\Exception\ORMException; +use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Query\AST\PathExpression; use Exception; use Stringable; +/** @psalm-import-type AssociationMapping from ClassMetadata */ class QueryException extends ORMException { /** @@ -142,7 +144,7 @@ public static function invalidLiteral($literal) /** * @param string[] $assoc - * @psalm-param array $assoc + * @psalm-param AssociationMapping $assoc * * @return QueryException */ @@ -190,7 +192,7 @@ public static function associationPathInverseSideNotSupported(PathExpression $pa /** * @param string[] $assoc - * @psalm-param array $assoc + * @psalm-param AssociationMapping $assoc * * @return QueryException */ diff --git a/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php index 9030c236f53..c467e0e100e 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php @@ -39,6 +39,9 @@ * Show information about mapped entities. * * @link www.doctrine-project.org + * + * @psalm-import-type AssociationMapping from ClassMetadata + * @psalm-import-type FieldMapping from ClassMetadata */ final class MappingDescribeCommand extends AbstractEntityManagerCommand { @@ -246,7 +249,7 @@ private function formatField(string $label, $value): array /** * Format the association mappings * - * @psalm-param array> $propertyMappings + * @psalm-param array $propertyMappings * * @return string[][] * @psalm-return list diff --git a/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php b/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php index 2365acd4ccf..5b8d2167428 100644 --- a/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php +++ b/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php @@ -19,6 +19,8 @@ * * Mechanism to overwrite interfaces or classes specified as association * targets. + * + * @psalm-import-type AssociationMapping from ClassMetadata */ class ResolveTargetEntityListener implements EventSubscriber { @@ -97,7 +99,7 @@ public function loadClassMetadata(LoadClassMetadataEventArgs $args) } } - /** @param mixed[] $mapping */ + /** @param AssociationMapping $mapping */ private function remapAssociation(ClassMetadata $classMetadata, array $mapping): void { $newMapping = $this->resolveTargetEntities[$mapping['targetEntity']]; diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index 11d866cbe2a..33db0d9fe68 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -47,7 +47,9 @@ * * @link www.doctrine-project.org * + * @psalm-import-type AssociationMapping from ClassMetadata * @psalm-import-type FieldMapping from ClassMetadata + * @psalm-import-type JoinColumnData from ClassMetadata */ class SchemaTool { @@ -659,8 +661,8 @@ private function getDefiningClass(ClassMetadata $class, string $referencedColumn /** * Gathers columns and fk constraints that are required for one part of relationship. * - * @psalm-param array $joinColumns - * @psalm-param array $mapping + * @psalm-param array $joinColumns + * @psalm-param AssociationMapping $mapping * @psalm-param list $primaryKeyColumns * @psalm-param array indexed by respective object spl_object_id() */ private $nonCascadedNewDetectedEntities = []; @@ -257,7 +257,7 @@ class UnitOfWork implements PropertyChangedListener /** * The collection persister instances used to persist collections. * - * @psalm-var array + * @psalm-var array */ private $collectionPersisters = []; @@ -905,7 +905,7 @@ public function computeChangeSets() * Computes the changes of an association. * * @param mixed $value The value of the association. - * @psalm-param array $assoc The association mapping. + * @psalm-param AssociationMapping $assoc The association mapping. * * @throws ORMInvalidArgumentException * @throws ORMException @@ -3246,7 +3246,7 @@ public function getEntityPersister($entityName) /** * Gets a collection persister for a collection-valued association. * - * @psalm-param array $association + * @psalm-param AssociationMapping $association * * @return CollectionPersister */ diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 0b37804a1dd..4c69834938b 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -170,11 +170,6 @@ parameters: count: 2 path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - message: "#^Method Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataInfo\\:\\:_validateAndCompleteManyToManyMapping\\(\\) should return array\\{mappedBy\\: mixed, inversedBy\\: mixed, isOwningSide\\: bool, sourceEntity\\: class\\-string, targetEntity\\: string, fieldName\\: mixed, fetch\\: mixed, cascade\\: array\\, \\.\\.\\.\\} but returns array\\{cache\\?\\: array, cascade\\: array\\, declared\\?\\: class\\-string, fetch\\: mixed, fieldName\\: string, id\\?\\: bool, inherited\\?\\: class\\-string, indexBy\\?\\: string, \\.\\.\\.\\}\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php - - message: "#^Method Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataInfo\\:\\:fullyQualifiedClassName\\(\\) should return class\\-string\\|null but returns string\\|null\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 4ca1689a2b6..d270cc46421 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -495,6 +495,11 @@ $class + + + $association['joinTable'] + + $repositoryClassName @@ -585,6 +590,7 @@ ! $this->table ! class_exists($mapping['targetEntity']) $this->table + isset($mapping['orderBy']) && ! is_array($mapping['orderBy']) $mapping @@ -603,8 +609,6 @@ $this->subClasses - $mapping - $mapping $mapping $mapping $this->reflClass @@ -612,46 +616,6 @@ AssociationMapping FieldMapping - array{ - * mappedBy: mixed, - * inversedBy: mixed, - * isOwningSide: bool, - * sourceEntity: string, - * targetEntity: string, - * fieldName: mixed, - * fetch: int|mixed, - * cascade: array<array-key,string>, - * isCascadeRemove: bool, - * isCascadePersist: bool, - * isCascadeRefresh: bool, - * isCascadeMerge: bool, - * isCascadeDetach: bool, - * orphanRemoval: bool - * } - array{ - * mappedBy: mixed|null, - * inversedBy: mixed|null, - * isOwningSide: bool, - * sourceEntity: class-string, - * targetEntity: string, - * fieldName: mixed, - * fetch: mixed, - * cascade: array<string>, - * isCascadeRemove: bool, - * isCascadePersist: bool, - * isCascadeRefresh: bool, - * isCascadeMerge: bool, - * isCascadeDetach: bool, - * type: int, - * originalField: string, - * originalClass: class-string, - * joinColumns?: array{0: array{name: string, referencedColumnName: string}}|mixed, - * id?: mixed, - * sourceToTargetKeyColumns?: array<string, string>, - * joinColumnFieldNames?: array<string, string>, - * targetToSourceKeyColumns?: array<string, string>, - * orphanRemoval: bool - * } getReflectionClass @@ -659,7 +623,6 @@ $className $className $columnNames - $mapping $quotedColumnNames $this->namespace . '\\' . $className @@ -667,30 +630,6 @@ __toString - array{ - * mappedBy: mixed, - * inversedBy: mixed, - * isOwningSide: bool, - * sourceEntity: class-string, - * targetEntity: string, - * fieldName: mixed, - * fetch: mixed, - * cascade: array<string>, - * isCascadeRemove: bool, - * isCascadePersist: bool, - * isCascadeRefresh: bool, - * isCascadeMerge: bool, - * isCascadeDetach: bool, - * type: int, - * originalField: string, - * originalClass: class-string, - * joinTable?: array{inverseJoinColumns: mixed}|mixed, - * joinTableColumns?: list<mixed>, - * isOnDeleteCascade?: true, - * relationToSourceKeyColumns?: array, - * relationToTargetKeyColumns?: array, - * orphanRemoval: bool - * } array{usage: int, region: string|null} class-string|null list<string> @@ -795,6 +734,7 @@ getIdentifierColumnNames + $association['joinTable'] $class->associationMappings[$fieldName]['joinColumns'] @@ -1219,11 +1159,6 @@ $sql - - - $entity - - Collection<TKey, T> @@ -1274,11 +1209,22 @@ setValue setValue + + $this->association['orphanRemoval'] + $this->association['orphanRemoval'] + $this->association['orphanRemoval'] + [$this->unwrap(), 'add'] + + $mapping + + + [$mappedKey => $collection->getOwner(), $mapping['indexBy'] => $index] + $association $collection->getOwner() @@ -1290,6 +1236,7 @@ $collection->getOwner() $collection->getOwner() $collection->getOwner() + $column $filterMapping $filterMapping $indexBy @@ -1301,6 +1248,7 @@ $mapping $mapping $mapping + $mapping $mapping['joinTableColumns'] $mapping['relationToSourceKeyColumns'] $mapping['relationToSourceKeyColumns'][$joinTableColumn] @@ -1324,14 +1272,24 @@ $mapping['targetEntity'] $mapping['targetEntity'] $owner + $targetColumn + $association['joinTable'] + $association['joinTable'] + $association['joinTable']['inverseJoinColumns'] + $association['joinTable']['joinColumns'] + $mapping[$sourceRelationMode] + $mapping[$targetRelationMode] + $mapping[$targetRelationMode][$joinTableColumn] $mapping['indexBy'] $mapping['isOwningSide'] $mapping['isOwningSide'] $mapping['isOwningSide'] $mapping['isOwningSide'] $mapping['isOwningSide'] + $mapping['isOwningSide'] + $mapping['joinTable'] $mapping['joinTable'] $mapping['joinTable'] $mapping['joinTable'] @@ -1342,14 +1300,20 @@ $mapping['joinTable']['joinColumns'] $mapping['joinTable']['joinColumns'] $mapping['joinTable']['joinColumns'] + $mapping['joinTable']['joinColumns'] + $mapping['joinTableColumns'] + $mapping['joinTableColumns'] + $mapping['joinTableColumns'] $mapping['joinTableColumns'] $mapping['mappedBy'] $mapping['mappedBy'] $mapping['mappedBy'] + $mapping['mappedBy'] $mapping['relationToSourceKeyColumns'] $mapping['relationToSourceKeyColumns'] $mapping['relationToSourceKeyColumns'] $mapping['relationToSourceKeyColumns'][$joinTableColumn] + $mapping['relationToSourceKeyColumns'][$joinTableColumn] $mapping['relationToTargetKeyColumns'] $mapping['relationToTargetKeyColumns'][$joinTableColumn] $mapping['sourceEntity'] @@ -1373,14 +1337,21 @@ $associationSourceClass->associationMappings $sourceClass->associationMappings $targetClass->associationMappings + $targetClass->associationMappings + $targetClass->associationMappings $joinColumns + $joinColumns + $mapping[$sourceRelationMode] $mapping['joinTable']['inverseJoinColumns'] $mapping['joinTable']['inverseJoinColumns'] $mapping['joinTable']['joinColumns'] $mapping['joinTable']['joinColumns'] $mapping['joinTable']['joinColumns'] + $mapping['joinTable']['joinColumns'] + $mapping['joinTableColumns'] + $mapping['joinTableColumns'] $mapping['joinTableColumns'] $mapping['relationToSourceKeyColumns'] @@ -1395,16 +1366,33 @@ $association['joinTable'] $mapping[$sourceRelationMode] $mapping[$targetRelationMode] + $mapping['indexBy'] + $mapping['joinTable'] $mapping['joinTable'] + $mapping['joinTable'] + $mapping['joinTable'] + $mapping['joinTable'] + $mapping['joinTable'] + $mapping['joinTableColumns'] $mapping['joinTableColumns'] $mapping['joinTableColumns'] + $mapping['joinTableColumns'] + $mapping['relationToSourceKeyColumns'] + $mapping['relationToSourceKeyColumns'] $mapping['relationToSourceKeyColumns'] + $mapping['relationToTargetKeyColumns'] int|null + + [ + $mapping['mappedBy'] => $collection->getOwner(), + $mapping['indexBy'] => $index, + ] + $numDeleted $this->conn->executeStatement($statement, $parameters) @@ -1420,6 +1408,7 @@ $mapping $mapping['mappedBy'] $mapping['mappedBy'] + $mapping['mappedBy'] $mapping['sourceEntity'] $mapping['sourceEntity'] $mapping['targetEntity'] @@ -1448,14 +1437,20 @@ $targetClass->associationMappings + $mapping['orphanRemoval'] $targetClass->associationMappings[$mapping['mappedBy']]['joinColumns'] + + $assoc + $association + $value === null + $assoc $em->getMetadataFactory() $hints $hints @@ -1486,17 +1481,28 @@ $targetEntity + $assoc['mappedBy'] + $assoc['mappedBy'] $assoc['mappedBy'] $association $type $assoc['isOwningSide'] + $association['joinTable'] + $association['joinTable'] + $association['joinTable']['inverseJoinColumns'] + $association['joinTable']['joinColumns'] $class->associationMappings $class->associationMappings + $targetEntity->associationMappings + $this->class->associationMappings + + $joinColumns + getValue getValue @@ -1507,7 +1513,7 @@ setValue - $assoc['inversedBy'] + $assoc['joinColumns'] $assoc['joinColumns'] $assoc['joinColumns'] $assoc['relationToTargetKeyColumns'] @@ -1519,6 +1525,10 @@ $association['joinTable'] $association['joinTable'] $association['joinTable'] + $association['joinTable'] + $association['joinTable'] + $association['joinTable'] + $association['joinTable'] $owningAssoc['targetToSourceKeyColumns'] $owningAssoc['targetToSourceKeyColumns'] $this->class->associationMappings[$fieldName]['joinColumns'] @@ -2352,7 +2362,6 @@ $expr - $assoc $condExpr $condTerm $factor @@ -2378,6 +2387,7 @@ $subselect->whereClause + $targetClass->associationMappings $targetClass->associationMappings $targetClass->associationMappings $this->scalarResultAliasMap @@ -2393,8 +2403,6 @@ $assoc['joinTable'] $assoc['sourceToTargetKeyColumns'] $assoc['targetToSourceKeyColumns'] - $assoc['type'] - $assoc['type'] $association['sourceToTargetKeyColumns'] $association['targetToSourceKeyColumns'] $owningAssoc['joinTable'] @@ -3089,6 +3097,9 @@ unwrap unwrap + + $this->nonCascadedNewDetectedEntities + $i >= 0 && $this->entityDeletions $this->entityDeletions