Skip to content

Commit

Permalink
Check if json_array type exists before unsetting it
Browse files Browse the repository at this point in the history
  • Loading branch information
HypeMC committed Oct 11, 2021
1 parent c1ead85 commit 8b1806d
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/Maker/MakeEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,7 @@ private function askForNextField(ConsoleStyle $io, array $fields, string $entity
}

$type = null;
$types = Type::getTypesMap();
// remove deprecated json_array
unset($types[Type::JSON_ARRAY]);
$types = $this->getTypesMap();

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

private function printAvailableTypes(ConsoleStyle $io)
{
$allTypes = Type::getTypesMap();
// remove deprecated json_array
unset($allTypes[Type::JSON_ARRAY]);
$allTypes = $this->getTypesMap();

if ('Hyper' === getenv('TERM_PROGRAM')) {
$wizard = 'wizard 🧙';
Expand Down Expand Up @@ -885,4 +881,16 @@ private function getEntityNamespace(): string
{
return $this->doctrineHelper->getEntityNamespace();
}

private function getTypesMap(): array
{
$types = Type::getTypesMap();

// remove deprecated json_array if it exists
if (\defined(sprintf('%s::JSON_ARRAY', Type::class))) {
unset($types[Type::JSON_ARRAY]);
}

return $types;
}
}

0 comments on commit 8b1806d

Please sign in to comment.