Skip to content

Commit

Permalink
bug #991 Check if json_array type exists before unsetting it (HypeMC)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 1.0-dev branch.

Discussion
----------

Check if json_array type exists before unsetting it

Fixes #987

Commits
-------

e0ffa99 Fix composer package names
8b1806d Check if json_array type exists before unsetting it
  • Loading branch information
weaverryan committed Oct 13, 2021
2 parents fd758db + e0ffa99 commit c9ae401
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
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

0 comments on commit c9ae401

Please sign in to comment.