Skip to content

Commit 146b465

Browse files
authored
Merge pull request #9198 from laryjulien/fix-fieldmapping-definition
Add a psalm type for field mapping
2 parents a663dda + 5aba762 commit 146b465

File tree

2 files changed

+23
-53
lines changed

2 files changed

+23
-53
lines changed

lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,26 @@
7070
*
7171
* @template-covariant T of object
7272
* @template-implements ClassMetadata<T>
73+
* @psalm-type FieldMapping = array{
74+
* type: string,
75+
* fieldName: string,
76+
* columnName?: string,
77+
* length?: int,
78+
* id?: bool,
79+
* nullable?: bool,
80+
* columnDefinition?: string,
81+
* precision?: int,
82+
* scale?: int,
83+
* unique?: string,
84+
* inherited?: class-string,
85+
* originalClass?: class-string,
86+
* originalField?: string,
87+
* quoted?: bool,
88+
* requireSQLConversion?: bool,
89+
* declared?: class-string,
90+
* declaredField?: string,
91+
* options?: array<string, mixed>
92+
* }
7393
*/
7494
class ClassMetadataInfo implements ClassMetadata
7595
{
@@ -427,26 +447,7 @@ class ClassMetadataInfo implements ClassMetadata
427447
* Whether a unique constraint should be generated for the column.
428448
*
429449
* @var mixed[]
430-
* @psalm-var array<string, array{
431-
* type: string,
432-
* fieldName: string,
433-
* columnName?: string,
434-
* length?: int,
435-
* id?: bool,
436-
* nullable?: bool,
437-
* columnDefinition?: string,
438-
* precision?: int,
439-
* scale?: int,
440-
* unique?: string,
441-
* inherited?: class-string,
442-
* originalClass?: class-string,
443-
* originalField?: string,
444-
* quoted?: bool,
445-
* requireSQLConversion?: bool,
446-
* declared?: class-string,
447-
* declaredField?: string,
448-
* options: array<mixed>
449-
* }>
450+
* @psalm-var array<string, FieldMapping>
450451
*/
451452
public $fieldMappings = [];
452453

@@ -1285,18 +1286,7 @@ public function getColumnName($fieldName)
12851286
* @param string $fieldName The field name.
12861287
*
12871288
* @return mixed[] The field mapping.
1288-
* @psalm-return array{
1289-
* type: string,
1290-
* fieldName: string,
1291-
* columnName?: string,
1292-
* inherited?: class-string,
1293-
* nullable?: bool,
1294-
* originalClass?: class-string,
1295-
* originalField?: string,
1296-
* scale?: int,
1297-
* precision?: int,
1298-
* length?: int
1299-
* }
1289+
* @psalm-return FieldMapping
13001290
*
13011291
* @throws MappingException
13021292
*/

phpstan-baseline.neon

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -575,21 +575,11 @@ parameters:
575575
count: 1
576576
path: lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
577577

578-
-
579-
message: "#^Offset 'unique' on array\\{type\\: string, fieldName\\: string, columnName\\?\\: string, inherited\\?\\: class\\-string, nullable\\?\\: bool, originalClass\\?\\: class\\-string, originalField\\?\\: string, scale\\?\\: int, \\.\\.\\.\\} in isset\\(\\) does not exist\\.$#"
580-
count: 1
581-
path: lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
582-
583578
-
584579
message: "#^Parameter \\#2 \\$type of static method Doctrine\\\\ORM\\\\Mapping\\\\MappingException\\:\\:invalidInheritanceType\\(\\) expects string, int given\\.$#"
585580
count: 1
586581
path: lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
587582

588-
-
589-
message: "#^Result of && is always false\\.$#"
590-
count: 2
591-
path: lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
592-
593583
-
594584
message: "#^Array \\(array\\<class\\-string, object\\>\\) does not accept key string\\.$#"
595585
count: 1
@@ -2211,11 +2201,6 @@ parameters:
22112201
count: 1
22122202
path: lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php
22132203

2214-
-
2215-
message: "#^Offset 'options' on array\\{type\\: string, fieldName\\: string, columnName\\?\\: string, length\\?\\: int, id\\?\\: bool, nullable\\?\\: bool, columnDefinition\\?\\: string, precision\\?\\: int, \\.\\.\\.\\} in isset\\(\\) always exists and is not nullable\\.$#"
2216-
count: 1
2217-
path: lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php
2218-
22192204
-
22202205
message: "#^Offset 'schema' on array\\{name\\: string, schema\\: string, indexes\\: array, uniqueConstraints\\: array, options\\: array\\<string, mixed\\>, quoted\\?\\: bool\\} in isset\\(\\) always exists and is not nullable\\.$#"
22212206
count: 1
@@ -2227,7 +2212,7 @@ parameters:
22272212
path: lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php
22282213

22292214
-
2230-
message: "#^Offset 'version' on array\\{type\\: string, fieldName\\: string, options\\: array, columnName\\?\\: string, length\\?\\: int, id\\?\\: bool, nullable\\?\\: bool, columnDefinition\\?\\: string, \\.\\.\\.\\} in isset\\(\\) does not exist\\.$#"
2215+
message: "#^Offset 'version' on array\\{type\\: string, fieldName\\: string, columnName\\?\\: string, length\\?\\: int, id\\?\\: bool, nullable\\?\\: bool, columnDefinition\\?\\: string, precision\\?\\: int, \\.\\.\\.\\} in isset\\(\\) does not exist\\.$#"
22312216
count: 1
22322217
path: lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php
22332218

@@ -2316,11 +2301,6 @@ parameters:
23162301
count: 1
23172302
path: lib/Doctrine/ORM/Tools/SchemaTool.php
23182303

2319-
-
2320-
message: "#^Offset 'columnDefinition' on array\\{type\\: string, fieldName\\: string, columnName\\?\\: string, inherited\\?\\: class\\-string, nullable\\?\\: bool, originalClass\\?\\: class\\-string, originalField\\?\\: string, scale\\?\\: int, \\.\\.\\.\\} in isset\\(\\) does not exist\\.$#"
2321-
count: 1
2322-
path: lib/Doctrine/ORM/Tools/SchemaTool.php
2323-
23242304
-
23252305
message: "#^Offset 'indexes' on array\\{name\\: string, schema\\: string, indexes\\: array, uniqueConstraints\\: array, options\\: array\\<string, mixed\\>, quoted\\?\\: bool\\} in isset\\(\\) always exists and is not nullable\\.$#"
23262306
count: 1

0 commit comments

Comments
 (0)