Skip to content

Commit 8b1806d

Browse files
committed
Check if json_array type exists before unsetting it
1 parent c1ead85 commit 8b1806d

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/Maker/MakeEntity.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,7 @@ private function askForNextField(ConsoleStyle $io, array $fields, string $entity
374374
}
375375

376376
$type = null;
377-
$types = Type::getTypesMap();
378-
// remove deprecated json_array
379-
unset($types[Type::JSON_ARRAY]);
377+
$types = $this->getTypesMap();
380378

381379
$allValidTypes = array_merge(
382380
array_keys($types),
@@ -428,9 +426,7 @@ private function askForNextField(ConsoleStyle $io, array $fields, string $entity
428426

429427
private function printAvailableTypes(ConsoleStyle $io)
430428
{
431-
$allTypes = Type::getTypesMap();
432-
// remove deprecated json_array
433-
unset($allTypes[Type::JSON_ARRAY]);
429+
$allTypes = $this->getTypesMap();
434430

435431
if ('Hyper' === getenv('TERM_PROGRAM')) {
436432
$wizard = 'wizard 🧙';
@@ -885,4 +881,16 @@ private function getEntityNamespace(): string
885881
{
886882
return $this->doctrineHelper->getEntityNamespace();
887883
}
884+
885+
private function getTypesMap(): array
886+
{
887+
$types = Type::getTypesMap();
888+
889+
// remove deprecated json_array if it exists
890+
if (\defined(sprintf('%s::JSON_ARRAY', Type::class))) {
891+
unset($types[Type::JSON_ARRAY]);
892+
}
893+
894+
return $types;
895+
}
888896
}

0 commit comments

Comments
 (0)