Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add phpdoc for ClassMetadataInfo::discriminatorColumn property #9983

Merged
merged 1 commit into from
Sep 21, 2022
Merged

Add phpdoc for ClassMetadataInfo::discriminatorColumn property #9983

merged 1 commit into from
Sep 21, 2022

Conversation

VincentLanglet
Copy link
Contributor

No description provided.

@@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at the setDiscriminatorColumn and all the usage of this property in the orm code to find the possible values.

'type' => $discrColumnAttribute->type ?: 'string',
'length' => $discrColumnAttribute->length ?: 255,
'columnDefinition' => $discrColumnAttribute->columnDefinition,
'name' => isset($discrColumnAttribute->name) ? (string) $discrColumnAttribute->name : null,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to cast this in order to avoid an ArgumentTypeCoercion error from psalm.

@@ -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,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cast was wrong

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

length might not be defined.
I assume this was always used with string so no error was reporter.

@VincentLanglet
Copy link
Contributor Author

If you have time to take a look @greg0ire :)

@VincentLanglet
Copy link
Contributor Author

Maybe do you have time to review this @derrabus ?

@derrabus
Copy link
Member

Not right now, no.

@greg0ire greg0ire merged commit 6dd07e4 into doctrine:2.13.x Sep 21, 2022
@greg0ire greg0ire added this to the 2.13.2 milestone Sep 21, 2022
@greg0ire
Copy link
Member

greg0ire commented Sep 21, 2022

Thanks @VincentLanglet !

@VincentLanglet VincentLanglet deleted the discriminatorColumn branch September 21, 2022 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants