Skip to content

Commit

Permalink
Add phpdoc for discriminatorColumn
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Aug 8, 2022
1 parent 35c44a5 commit 2fda625
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ class ClassMetadataInfo implements ClassMetadata
* READ-ONLY: The definition of the discriminator column used in JOINED and SINGLE_TABLE
* inheritance mappings.
*
* @psalm-var array<string, mixed>|null
* @psalm-var array{name: string, fieldName: string, type: string, length?: int, columnDefinition?: string|null}|null
*/
public $discriminatorColumn;

Expand Down Expand Up @@ -3215,7 +3215,7 @@ public function addEntityListener($eventName, $class, $method)
* @see getDiscriminatorColumn()
*
* @param mixed[]|null $columnDef
* @psalm-param array<string, mixed>|null $columnDef
* @psalm-param array{name: string|null, fieldName?: string, type?: string, length?: int, columnDefinition?: string|null}|null $columnDef
*
* @return void
*
Expand Down
8 changes: 4 additions & 4 deletions lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,10 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad

$metadata->setDiscriminatorColumn(
[
'name' => $discrColumnAttribute->name,
'type' => $discrColumnAttribute->type ?: 'string',
'length' => $discrColumnAttribute->length ?: 255,
'columnDefinition' => $discrColumnAttribute->columnDefinition,
'name' => isset($discrColumnAttribute->name) ? (string) $discrColumnAttribute->name : null,
'type' => isset($discrColumnAttribute->type) ? (string) $discrColumnAttribute->type : 'string',
'length' => isset($discrColumnAttribute->length) ? (int) $discrColumnAttribute->length : 255,
'columnDefinition' => isset($discrColumnAttribute->columnDefinition) ? (string) $discrColumnAttribute->columnDefinition : null,
]
);
} else {
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad
[
'name' => isset($discrColumn['name']) ? (string) $discrColumn['name'] : null,
'type' => isset($discrColumn['type']) ? (string) $discrColumn['type'] : 'string',
'length' => isset($discrColumn['length']) ? (string) $discrColumn['length'] : 255,
'length' => isset($discrColumn['length']) ? (int) $discrColumn['length'] : 255,
'columnDefinition' => isset($discrColumn['columnDefinition']) ? (string) $discrColumn['columnDefinition'] : null,
]
);
Expand Down
7 changes: 4 additions & 3 deletions lib/Doctrine/ORM/Tools/EntityGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -1145,9 +1145,10 @@ protected function generateDiscriminatorColumnAnnotation(ClassMetadataInfo $meta
return '';
}

$columnDefinition = 'name="' . $discrColumn['name']
. '", type="' . $discrColumn['type']
. '", length=' . $discrColumn['length'];
$columnDefinition = sprintf('name="%s", type="%s"', $discrColumn['name'], $discrColumn['type']);
if (isset($discrColumn['length'])) {
$columnDefinition .= ', length=' . $discrColumn['length'];
}

return '@' . $this->annotationsPrefix . 'DiscriminatorColumn(' . $columnDefinition . ')';
}
Expand Down

0 comments on commit 2fda625

Please sign in to comment.