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

Clean-up code after PR10288 merge #10305

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/Doctrine/ORM/Mapping/DiscriminatorColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Doctrine\ORM\Mapping;

use Attribute;
use BackedEnum;

#[Attribute(Attribute::TARGET_CLASS)]
final class DiscriminatorColumn implements MappingAttribute
Expand All @@ -14,6 +15,7 @@ public function __construct(
public readonly string|null $type = null,
public readonly int|null $length = null,
public readonly string|null $columnDefinition = null,
/** @var class-string<BackedEnum>|null */
public readonly string|null $enumType = null,
) {
}
Expand Down
11 changes: 6 additions & 5 deletions lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,15 @@ public function loadMetadataForClass(string $className, PersistenceClassMetadata
// Evaluate DiscriminatorColumn attribute
if (isset($classAttributes[Mapping\DiscriminatorColumn::class])) {
$discrColumnAttribute = $classAttributes[Mapping\DiscriminatorColumn::class];
assert($discrColumnAttribute instanceof Mapping\DiscriminatorColumn);

$metadata->setDiscriminatorColumn(
[
'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,
'enumType' => isset($discrColumnAttribute->enumType) ? (string) $discrColumnAttribute->enumType : null,
'name' => $discrColumnAttribute->name,
'type' => $discrColumnAttribute->type ?? 'string',
'length' => $discrColumnAttribute->length ?? 255,
'columnDefinition' => $discrColumnAttribute->columnDefinition,
'enumType' => $discrColumnAttribute->enumType,
],
);
} else {
Expand Down
2 changes: 1 addition & 1 deletion psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@
</PossiblyUndefinedArrayOffset>
</file>
<file src="lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php">
<InvalidArgument occurrences="2"/>
<InvalidArgument occurrences="1"/>
<InvalidArrayAccess occurrences="4">
<code>$value[0]</code>
<code>$value[0]</code>
Expand Down