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

Check if json_array type exists before unsetting it #991

Merged
merged 2 commits into from
Oct 13, 2021
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: 1 addition & 1 deletion src/Maker/MakeCrud.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public function configureDependencies(DependencyBuilder $dependencies)

$dependencies->addClassDependency(
DoctrineBundle::class,
'orm-pack'
'orm'
);

$dependencies->addClassDependency(
Expand Down
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;
}
}
2 changes: 1 addition & 1 deletion src/Maker/MakeRegistrationForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ public function configureDependencies(DependencyBuilder $dependencies): void

$dependencies->addClassDependency(
DoctrineBundle::class,
'orm-pack'
'orm'
);

$dependencies->addClassDependency(
Expand Down
4 changes: 2 additions & 2 deletions tests/Maker/MakeEntityLegacyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ public function getTestDetails()
'',
])
->setRequiredPhpVersion(70200)
->addExtraDependencies('ux-turbo-mercure')
->addExtraDependencies('symfony/ux-turbo-mercure')
->configureDatabase()
->addReplacement(
'.env',
Expand Down Expand Up @@ -546,7 +546,7 @@ public function getTestDetails()
])
->setRequiredPhpVersion(70200)
->addExtraDependencies('api')
->addExtraDependencies('ux-turbo-mercure')
->addExtraDependencies('symfony/ux-turbo-mercure')
->setFixtureFilesPath(__DIR__.'/../fixtures/legacy/MakeEntity/MakeEntity')
->configureDatabase()
->updateSchemaAfterCommand()
Expand Down
4 changes: 2 additions & 2 deletions tests/Maker/MakeEntityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ public function getTestDetails()
])
->setRequiredPhpVersion(80000)
->useDoctrineAttributeMapping()
->addExtraDependencies('ux-turbo-mercure')
->addExtraDependencies('symfony/ux-turbo-mercure')
->configureDatabase()
->addReplacement(
'.env',
Expand Down Expand Up @@ -657,7 +657,7 @@ public function getTestDetails()
->setRequiredPhpVersion(80000)
->useDoctrineAttributeMapping()
->addExtraDependencies('api')
->addExtraDependencies('ux-turbo-mercure')
->addExtraDependencies('symfony/ux-turbo-mercure')
->setFixtureFilesPath(__DIR__.'/../fixtures/MakeEntity')
->configureDatabase()
->updateSchemaAfterCommand()
Expand Down