diff --git a/composer.json b/composer.json index 5e2394e054..37d51e10b8 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,7 @@ "squizlabs/php_codesniffer": "3.7.1", "symfony/cache": "^4.4 || ^5.4 || ^6.0", "symfony/yaml": "^3.4 || ^4.0 || ^5.0 || ^6.0", - "vimeo/psalm": "4.30.0 || 5.2.0" + "vimeo/psalm": "4.30.0 || 5.3.0" }, "conflict": { "doctrine/annotations": "<1.13 || >= 2.0" diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index 955c3993f0..c9fecaeda8 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -75,7 +75,7 @@ * @template-implements ClassMetadata * @psalm-type FieldMapping = array{ * type: string, - * fieldName: string, + * fieldName: non-empty-string, * columnName: string, * length?: int, * id?: bool, @@ -102,7 +102,7 @@ * referencedColumnName: string, * unique?: bool, * quoted?: bool, - * fieldName?: string, + * fieldName?: non-empty-string, * onDelete?: string, * columnDefinition?: string, * nullable?: bool, @@ -112,7 +112,7 @@ * cascade: array, * declared?: class-string, * fetch: mixed, - * fieldName: string, + * fieldName: non-empty-string, * id?: bool, * inherited?: class-string, * indexBy?: string, @@ -142,6 +142,13 @@ * type: int, * unique?: bool, * } + * @psalm-type DiscriminatorColumnMapping = array{ + * name: string, + * fieldName: non-empty-string, + * type: string, + * length?: int, + * columnDefinition?: string|null, + * } */ class ClassMetadataInfo implements ClassMetadata { @@ -574,7 +581,8 @@ class ClassMetadataInfo implements ClassMetadata * READ-ONLY: The definition of the discriminator column used in JOINED and SINGLE_TABLE * inheritance mappings. * - * @psalm-var array{name: string, fieldName: string, type: string, length?: int, columnDefinition?: string|null}|null + * @var array + * @psalm-var DiscriminatorColumnMapping|null */ public $discriminatorColumn; @@ -3215,7 +3223,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}|null $columnDef + * @psalm-param array{name: string|null, fieldName?: non-empty-string, type?: string, length?: int, columnDefinition?: string|null}|null $columnDef * * @return void * @@ -3248,7 +3256,10 @@ public function setDiscriminatorColumn($columnDef) } } - /** @return array */ + /** + * @return array + * @psalm-return DiscriminatorColumnMapping + */ final public function getDiscriminatorColumn(): array { if ($this->discriminatorColumn === null) { diff --git a/lib/Doctrine/ORM/Tools/EntityGenerator.php b/lib/Doctrine/ORM/Tools/EntityGenerator.php index 34f4eba625..9ed093b00c 100644 --- a/lib/Doctrine/ORM/Tools/EntityGenerator.php +++ b/lib/Doctrine/ORM/Tools/EntityGenerator.php @@ -869,7 +869,7 @@ protected function parseTokensInEntityFile($src) } /** - * @param string $property + * @param non-empty-string $property * * @return bool */ diff --git a/psalm-baseline.xml b/psalm-baseline.xml index bca75126dc..f7926ec505 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + IterableResult @@ -19,11 +19,17 @@ \Doctrine\Common\Cache\Cache + + $queryCacheProfile->generateCacheKeys($sql, $parameters, $hints) + $alias $data $data + + array{string, string} + $this->_em->getConfiguration()->getResultCacheImpl() $this->_queryCacheProfile->getResultCacheDriver() @@ -404,6 +410,10 @@ + + $this->sortedNodeList + $this->sortedNodeList + $vertex->state !== self::VISITED $vertex->state !== self::VISITED @@ -599,6 +609,9 @@ ! class_exists($mapping['targetEntity']) $this->table + + $mapping['id'] + protected function _validateAndCompleteAssociationMapping(array $mapping) protected function _validateAndCompleteManyToManyMapping(array $mapping) @@ -609,8 +622,10 @@ ReflectionProperty getAssociationMappedByTargetField - + $definition + $this->identifier + $this->identifier $this->sqlResultSetMappings $this->subClasses @@ -620,10 +635,12 @@ getReflectionClass - + $cache $className $className + $columnNames + $quotedColumnNames $this->namespace . '\\' . $className @@ -634,9 +651,11 @@ _validateAndCompleteManyToManyMapping _validateAndCompleteOneToOneMapping - + array{usage: int, region: string|null} class-string|null + list<string> + list<string> $this->associationMappings[$fieldName]['mappedBy'] @@ -674,7 +693,11 @@ setValue setValue - + + $mapping['fieldName'] + $mapping['fieldName'] + $mapping['fieldName'] + $mapping['fieldName'] $mapping['originalClass'] $mapping['originalField'] $mapping['targetEntity'] @@ -690,7 +713,9 @@ $table $tableGeneratorDefinition - + + $columnDef + $identifier $this->associationMappings $this->associationMappings $this->entityListeners @@ -703,6 +728,9 @@ $this->table $this->table + + isset($mapping['id']) && $mapping['id'] === true + $mapping !== false $mapping !== false @@ -741,6 +769,12 @@ canEmulateSchemas canEmulateSchemas + + $quotedColumnNames + + + getIdentifierColumnNames + $class->associationMappings[$fieldName]['joinColumns'] @@ -800,14 +834,14 @@ $listenerClassName - + $metadata->getReflectionClass() + + + assert($cacheAttribute instanceof Mapping\Cache) assert($method instanceof ReflectionMethod) assert($method instanceof ReflectionMethod) assert($property instanceof ReflectionProperty) - - - assert($cacheAttribute instanceof Mapping\Cache) new ReflectionClass($metadata->name) @@ -817,15 +851,17 @@ $metadata instanceof ClassMetadata - + $this->namespace . $this->classNamesForTables[$tableName] $this->namespace . $this->inflector->classify(strtolower($tableName)) + array_keys($this->classToTableNames) $metadata - + class-string + getAllClassNames $this->tables[$tableName] @@ -1273,8 +1309,17 @@ getFieldForColumn getFieldForColumn - + + $association['joinTable'] + $association['joinTable'] + $association['joinTable'] + $association['joinTable'] + $mapping[$sourceRelationMode] + $mapping[$targetRelationMode] $mapping['joinTable'] + $mapping['joinTableColumns'] + $mapping['joinTableColumns'] + $mapping['relationToSourceKeyColumns'] @@ -1342,7 +1387,8 @@ loadOneToOneEntity - + + $newValue $postInsertIds [$params, $types] [$sqlParams, $sqlTypes] @@ -1350,10 +1396,11 @@ loadAll - + executeInserts expandCriteriaParameters expandParameters + list<mixed> $targetEntity @@ -1380,7 +1427,8 @@ getValue setValue - + + $assoc['inversedBy'] $assoc['joinColumns'] $assoc['joinColumns'] $assoc['relationToTargetKeyColumns'] @@ -1477,6 +1525,12 @@ $sqlParams + + $this->parse()->getSqlExecutor()->getSqlStatements() + + + list<string>|string + $this->getDQL() @@ -2092,6 +2146,9 @@ + + $this->parts + __toString @@ -2115,9 +2172,15 @@ + + $this->arguments + __toString + + list<mixed> + @@ -2351,15 +2414,11 @@ $token['type'] $token['type'] $token['type'] - $token['type'] $token['value'] $token['value'] $token['value'] $token['value'] - - getNumberOfRequiredParameters - $args @@ -2373,6 +2432,12 @@ + + new ArrayCollection($this->parameters) + + + ArrayCollection<int, mixed> + Comparison::EQ @@ -2452,7 +2517,8 @@ $expr - + + $assoc $condExpr $condTerm $factor @@ -2490,11 +2556,15 @@ dispatch - + + $assoc['joinColumns'] $assoc['joinColumns'] $assoc['joinColumns'] + $assoc['joinTable'] $assoc['sourceToTargetKeyColumns'] $assoc['targetToSourceKeyColumns'] + $assoc['type'] + $assoc['type'] $association['sourceToTargetKeyColumns'] $association['targetToSourceKeyColumns'] $owningAssoc['joinTable'] @@ -2544,7 +2614,11 @@ - + + $args + $args + $args + $args [$rootAlias => $join] [$rootAlias => $join] @@ -2558,9 +2632,20 @@ Parameter|null + + new ArrayCollection($parameters) + + + $aliases + $entities + __toString + + list<string> + list<string> + $spacePos $spacePos @@ -2636,7 +2721,7 @@ - $metadata + $fromPaths ClassMetadataExporter @@ -2651,6 +2736,9 @@ private $entityGenerator = null; private $metadataExporter = null; + + $metadata + configure @@ -2723,9 +2811,9 @@ - + $metadata->entityListeners - + getAllClassNames @@ -2747,11 +2835,20 @@ + + $metadatas + $metadatas + configure + + $metadatas + $metadatas + $metadatas + configure @@ -2782,6 +2879,11 @@ MetadataFilter + + + $column['type'] + + $entity @@ -2792,12 +2894,16 @@ - + + $fieldName $this->getClassToExtend() $this->getClassToExtend() ?: $metadata->name $this->getClassToExtend() ?: $metadata->name array_map('strlen', $paramTypes) + + $tokens[$i - 1] + $last strrpos($metadata->name, '\\') @@ -2805,13 +2911,17 @@ $variableType + + getTraits + $classToExtend (bool) $embeddablesImmutable - + + $reflClass !== false isset($metadata->lifecycleCallbacks) @@ -3007,6 +3117,9 @@ + + $classes + canEmulateSchemas @@ -3052,6 +3165,9 @@ + + $paths + new ClassLoader('Doctrine', $directory) new ClassLoader('Symfony\Component', $directory . '/Doctrine') @@ -3062,12 +3178,11 @@ - + $class $class $collectionToDelete $collectionToUpdate - $commitOrder[$i] ! is_object($object) @@ -3077,6 +3192,9 @@ $collectionToDelete $em->getMetadataFactory() + + $commitOrder[$i] + object