Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5277680

Browse files
author
Samaël Tomas
committed
Refactor enum handling in EntityColumnRule to improve type resolution
1 parent eeff198 commit 5277680

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

‎src/Rules/Doctrine/ORM/EntityColumnRule.php‎

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -105,26 +105,6 @@ public function processNode(Node $node, Scope $scope): array
105105
$writableToPropertyType = $descriptor->getWritableToPropertyType();
106106
$writableToDatabaseType = $descriptor->getWritableToDatabaseType();
107107

108-
if ($fieldMapping['type'] === 'enum') {
109-
$values = $fieldMapping['options']['values'] ?? null;
110-
if (is_array($values)) {
111-
$enumTypes = [];
112-
foreach ($values as $value) {
113-
if (!is_string($value)) {
114-
$enumTypes = [];
115-
break;
116-
}
117-
118-
$enumTypes[] = new ConstantStringType($value);
119-
}
120-
121-
if (count($enumTypes) > 0) {
122-
$writableToPropertyType = new UnionType($enumTypes);
123-
$writableToDatabaseType = new UnionType($enumTypes);
124-
}
125-
}
126-
}
127-
128108
$enumTypeString = $fieldMapping['enumType'] ?? null;
129109
if ($enumTypeString !== null) {
130110
if ($writableToDatabaseType->isArray()->no() && $writableToPropertyType->isArray()->no()) {
@@ -179,6 +159,24 @@ public function processNode(Node $node, Scope $scope): array
179159
), ...TypeUtils::getAccessoryTypes($writableToDatabaseType));
180160

181161
}
162+
} elseif ($fieldMapping['type'] === 'enum') {
163+
$values = $fieldMapping['options']['values'] ?? null;
164+
if (is_array($values)) {
165+
$enumTypes = [];
166+
foreach ($values as $value) {
167+
if (!is_string($value)) {
168+
$enumTypes = [];
169+
break;
170+
}
171+
172+
$enumTypes[] = new ConstantStringType($value);
173+
}
174+
175+
if (count($enumTypes) > 0) {num
176+
$writableToPropertyType = new UnionType($enumTypes);
177+
$writableToDatabaseType = new UnionType($enumTypes);
178+
}
179+
}
182180
}
183181

184182
$identifiers = [];

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /