Skip to content

Commit

Permalink
Merge pull request #11408 from VincentLanglet/fix/fromMappingArray
Browse files Browse the repository at this point in the history
Fix fromMappingArray definition
  • Loading branch information
greg0ire committed Apr 3, 2024
2 parents cbb6c89 + 1464827 commit 93eb8a1
Show file tree
Hide file tree
Showing 13 changed files with 151 additions and 26 deletions.
4 changes: 0 additions & 4 deletions phpstan-dbal3.neon
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ parameters:
message: '~^Method Doctrine\\ORM\\Persisters\\Entity\\BasicEntityPersister\:\:getArrayBindingType\(\) never returns .* so it can be removed from the return type\.$~'
path: src/Persisters/Entity/BasicEntityPersister.php

-
message: '~^Unreachable statement \- code above always terminates\.$~'
path: src/Mapping/AssociationMapping.php

- '~^Class Doctrine\\DBAL\\Platforms\\SQLitePlatform not found\.$~'

# To be removed in 4.0
Expand Down
4 changes: 0 additions & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ parameters:
message: '~^Method Doctrine\\ORM\\Persisters\\Entity\\BasicEntityPersister\:\:getArrayBindingType\(\) never returns .* so it can be removed from the return type\.$~'
path: src/Persisters/Entity/BasicEntityPersister.php

-
message: '~^Unreachable statement \- code above always terminates\.$~'
path: src/Mapping/AssociationMapping.php

# Compatibility with DBAL 3
# See https://github.com/doctrine/dbal/pull/3480
-
Expand Down
4 changes: 4 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@
<code><![CDATA[$this->columnNames]]></code>
</DeprecatedProperty>
<InvalidArgument>
<code><![CDATA[$mapping]]></code>
<code><![CDATA[$mapping]]></code>
<code><![CDATA[$mapping]]></code>
<code><![CDATA[$mapping]]></code>
<code><![CDATA[$mapping]]></code>
<code><![CDATA[$mapping]]></code>
<code><![CDATA[$mapping]]></code>
Expand Down
17 changes: 15 additions & 2 deletions src/Mapping/AssociationMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ abstract class AssociationMapping implements ArrayAccess
/**
* The fetching strategy to use for the association, usually defaults to FETCH_LAZY.
*
* @var ClassMetadata::FETCH_*
* @var ClassMetadata::FETCH_*|null
*/
public int|null $fetch = null;

Expand Down Expand Up @@ -96,13 +96,26 @@ final public function __construct(
}

/**
* @param mixed[] $mappingArray
* @psalm-param array{
* fieldName: string,
* sourceEntity: class-string,
* targetEntity: class-string,
* cascade?: list<'persist'|'remove'|'detach'|'refresh'|'all'>,
* fetch?: ClassMetadata::FETCH_*|null,
* inherited?: class-string|null,
* declared?: class-string|null,
* cache?: array<mixed>|null,
* id?: bool|null,
* isOnDeleteCascade?: bool|null,
* originalClass?: class-string|null,
* originalField?: string|null,
* orphanRemoval?: bool,
* unique?: bool|null,
* joinTable?: mixed[]|null,
* type?: int,
* isOwningSide: bool, ...} $mappingArray
* isOwningSide: bool,
* } $mappingArray
*/
public static function fromMappingArray(array $mappingArray): static
{
Expand Down
2 changes: 1 addition & 1 deletion src/Mapping/ClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ private function validateAndCompleteTypedAssociationMapping(array $mapping): arr
* fieldName?: string,
* columnName?: string,
* id?: bool,
* generated?: int,
* generated?: self::GENERATED_*,
* enumType?: class-string,
* } $mapping The field mapping to validate & complete.
*
Expand Down
10 changes: 6 additions & 4 deletions src/Mapping/EmbeddedClassMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ public function __construct(public string $class)

/**
* @psalm-param array{
* class: class-string,
* columnPrefix?: false|string|null,
* declaredField?: string|null,
* originalField?: string|null
* class: class-string,
* columnPrefix?: false|string|null,
* declaredField?: string|null,
* originalField?: string|null,
* inherited?: class-string|null,
* declared?: class-string|null,
* } $mappingArray
*/
public static function fromMappingArray(array $mappingArray): self
Expand Down
31 changes: 29 additions & 2 deletions src/Mapping/FieldMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class FieldMapping implements ArrayAccess
public bool|null $notInsertable = null;
public bool|null $notUpdatable = null;
public string|null $columnDefinition = null;
/** @psalm-var ClassMetadata::GENERATED_* */
/** @psalm-var ClassMetadata::GENERATED_*|null */
public int|null $generated = null;
/** @var class-string<BackedEnum>|null */
public string|null $enumType = null;
Expand Down Expand Up @@ -83,7 +83,34 @@ public function __construct(
) {
}

/** @param array{type: string, fieldName: string, columnName: string} $mappingArray */
/**
* @param array<string, mixed> $mappingArray
* @psalm-param array{
* type: string,
* fieldName: string,
* columnName: string,
* length?: int|null,
* id?: bool|null,
* nullable?: bool|null,
* notInsertable?: bool|null,
* notUpdatable?: bool|null,
* columnDefinition?: string|null,
* generated?: ClassMetadata::GENERATED_*|null,
* enumType?: string|null,
* precision?: int|null,
* scale?: int|null,
* unique?: bool|null,
* inherited?: string|null,
* originalClass?: string|null,
* originalField?: string|null,
* quoted?: bool|null,
* declared?: string|null,
* declaredField?: string|null,
* options?: array<string, mixed>|null,
* version?: bool|null,
* default?: string|int|null,
* } $mappingArray
*/
public static function fromMappingArray(array $mappingArray): self
{
$mapping = new self(
Expand Down
12 changes: 11 additions & 1 deletion src/Mapping/JoinColumnMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,17 @@ public function __construct(

/**
* @param array<string, mixed> $mappingArray
* @psalm-param array{name: string, referencedColumnName: string, ...} $mappingArray
* @psalm-param array{
* name: string,
* referencedColumnName: string,
* unique?: bool|null,
* quoted?: bool|null,
* fieldName?: string|null,
* onDelete?: string|null,
* columnDefinition?: string|null,
* nullable?: bool|null,
* options?: array<string, mixed>|null,
* } $mappingArray
*/
public static function fromMappingArray(array $mappingArray): self
{
Expand Down
4 changes: 2 additions & 2 deletions src/Mapping/JoinTableMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public function __construct(public string $name)
* @param mixed[] $mappingArray
* @psalm-param array{
* name: string,
* quoted?: bool,
* quoted?: bool|null,
* joinColumns?: mixed[],
* inverseJoinColumns?: mixed[],
* schema?: string,
* schema?: string|null,
* options?: array<string, mixed>
* } $mappingArray
*/
Expand Down
14 changes: 13 additions & 1 deletion src/Mapping/ManyToManyOwningSideMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,21 @@ public function toArray(): array
* fieldName: string,
* sourceEntity: class-string,
* targetEntity: class-string,
* cascade?: list<'persist'|'remove'|'detach'|'refresh'|'all'>,
* fetch?: ClassMetadata::FETCH_*|null,
* inherited?: class-string|null,
* declared?: class-string|null,
* cache?: array<mixed>|null,
* id?: bool|null,
* isOnDeleteCascade?: bool|null,
* originalClass?: class-string|null,
* originalField?: string|null,
* orphanRemoval?: bool,
* unique?: bool|null,
* joinTable?: mixed[]|null,
* type?: int,
* isOwningSide: bool, ...} $mappingArray
* isOwningSide: bool,
* } $mappingArray
*/
public static function fromMappingArrayAndNamingStrategy(array $mappingArray, NamingStrategy $namingStrategy): self
{
Expand Down
28 changes: 26 additions & 2 deletions src/Mapping/OneToManyAssociationMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,21 @@ final class OneToManyAssociationMapping extends ToManyInverseSideMapping
* fieldName: string,
* sourceEntity: class-string,
* targetEntity: class-string,
* cascade?: list<'persist'|'remove'|'detach'|'refresh'|'all'>,
* fetch?: ClassMetadata::FETCH_*|null,
* inherited?: class-string|null,
* declared?: class-string|null,
* cache?: array<mixed>|null,
* id?: bool|null,
* isOnDeleteCascade?: bool|null,
* originalClass?: class-string|null,
* originalField?: string|null,
* orphanRemoval?: bool,
* unique?: bool|null,
* joinTable?: mixed[]|null,
* type?: int,
* isOwningSide: bool, ...} $mappingArray
* isOwningSide: bool,
* } $mappingArray
*/
public static function fromMappingArray(array $mappingArray): static
{
Expand All @@ -33,9 +45,21 @@ public static function fromMappingArray(array $mappingArray): static
* fieldName: string,
* sourceEntity: class-string,
* targetEntity: class-string,
* cascade?: list<'persist'|'remove'|'detach'|'refresh'|'all'>,
* fetch?: ClassMetadata::FETCH_*|null,
* inherited?: class-string|null,
* declared?: class-string|null,
* cache?: array<mixed>|null,
* id?: bool|null,
* isOnDeleteCascade?: bool|null,
* originalClass?: class-string|null,
* originalField?: string|null,
* orphanRemoval?: bool,
* unique?: bool|null,
* joinTable?: mixed[]|null,
* type?: int,
* isOwningSide: bool, ...} $mappingArray
* isOwningSide: bool,
* } $mappingArray
*/
public static function fromMappingArrayAndName(array $mappingArray, string $name): static
{
Expand Down
15 changes: 14 additions & 1 deletion src/Mapping/ToOneInverseSideMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,21 @@ abstract class ToOneInverseSideMapping extends InverseSideMapping
* fieldName: string,
* sourceEntity: class-string,
* targetEntity: class-string,
* cascade?: list<'persist'|'remove'|'detach'|'refresh'|'all'>,
* fetch?: ClassMetadata::FETCH_*|null,
* inherited?: class-string|null,
* declared?: class-string|null,
* cache?: array<mixed>|null,
* id?: bool|null,
* isOnDeleteCascade?: bool|null,
* originalClass?: class-string|null,
* originalField?: string|null,
* orphanRemoval?: bool,
* unique?: bool|null,
* joinTable?: mixed[]|null,
* type?: int,
* isOwningSide: bool,
* } $mappingArray
* } $mappingArray
*/
public static function fromMappingArrayAndName(
array $mappingArray,
Expand Down
32 changes: 30 additions & 2 deletions src/Mapping/ToOneOwningSideMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,22 @@ abstract class ToOneOwningSideMapping extends OwningSideMapping implements ToOne
* fieldName: string,
* sourceEntity: class-string,
* targetEntity: class-string,
* cascade?: list<'persist'|'remove'|'detach'|'refresh'|'all'>,
* fetch?: ClassMetadata::FETCH_*|null,
* inherited?: class-string|null,
* declared?: class-string|null,
* cache?: array<mixed>|null,
* id?: bool|null,
* isOnDeleteCascade?: bool|null,
* originalClass?: class-string|null,
* originalField?: string|null,
* orphanRemoval?: bool,
* unique?: bool|null,
* joinTable?: mixed[]|null,
* type?: int,
* isOwningSide: bool,
* joinColumns?: mixed[]|null,
* isOwningSide: bool, ...} $mappingArray
* } $mappingArray
*/
public static function fromMappingArray(array $mappingArray): static
{
Expand Down Expand Up @@ -64,8 +78,22 @@ public static function fromMappingArray(array $mappingArray): static
* fieldName: string,
* sourceEntity: class-string,
* targetEntity: class-string,
* cascade?: list<'persist'|'remove'|'detach'|'refresh'|'all'>,
* fetch?: ClassMetadata::FETCH_*|null,
* inherited?: class-string|null,
* declared?: class-string|null,
* cache?: array<mixed>|null,
* id?: bool|null,
* isOnDeleteCascade?: bool|null,
* originalClass?: class-string|null,
* originalField?: string|null,
* orphanRemoval?: bool,
* unique?: bool|null,
* joinTable?: mixed[]|null,
* type?: int,
* isOwningSide: bool,
* joinColumns?: mixed[]|null,
* isOwningSide: bool, ...} $mappingArray
* } $mappingArray
*/
public static function fromMappingArrayAndName(
array $mappingArray,
Expand Down

0 comments on commit 93eb8a1

Please sign in to comment.