@@ -430,27 +430,14 @@ private function printAvailableTypes(ConsoleStyle $io): void
430
430
{
431
431
$ allTypes = $ this ->getTypesMap ();
432
432
433
- if ('Hyper ' === getenv ('TERM_PROGRAM ' )) {
434
- $ wizard = 'wizard 🧙 ' ;
435
- } else {
436
- $ wizard = '\\' === \DIRECTORY_SEPARATOR ? 'wizard ' : 'wizard 🧙 ' ;
437
- }
438
-
439
433
$ typesTable = [
440
434
'main ' => [
441
- 'string ' => [],
435
+ 'string ' => [' ascii_string ' ],
442
436
'text ' => [],
443
437
'boolean ' => [],
444
438
'integer ' => ['smallint ' , 'bigint ' ],
445
439
'float ' => [],
446
440
],
447
- 'relation ' => [
448
- 'relation ' => 'a ' .$ wizard .' will help you build the relation ' ,
449
- EntityRelation::MANY_TO_ONE => [],
450
- EntityRelation::ONE_TO_MANY => [],
451
- EntityRelation::MANY_TO_MANY => [],
452
- EntityRelation::ONE_TO_ONE => [],
453
- ],
454
441
'array_object ' => [
455
442
'array ' => ['simple_array ' ],
456
443
'json ' => [],
@@ -469,19 +456,30 @@ private function printAvailableTypes(ConsoleStyle $io): void
469
456
470
457
$ printSection = static function (array $ sectionTypes ) use ($ io , &$ allTypes ) {
471
458
foreach ($ sectionTypes as $ mainType => $ subTypes ) {
459
+ if (!\array_key_exists ($ mainType , $ allTypes )) {
460
+ // The type is not a valid DBAL Type - don't show it as an option
461
+ continue ;
462
+ }
463
+
464
+ foreach ($ subTypes as $ key => $ potentialType ) {
465
+ if (!\array_key_exists ($ potentialType , $ allTypes )) {
466
+ // The type is not a valid DBAL Type - don't show it as an "or" option
467
+ unset($ subTypes [$ key ]);
468
+ }
469
+
470
+ // Remove type as not to show it again in "Other Types"
471
+ unset($ allTypes [$ potentialType ]);
472
+ }
473
+
474
+ // Remove type as not to show it again in "Other Types"
472
475
unset($ allTypes [$ mainType ]);
476
+
473
477
$ line = sprintf (' * <comment>%s</comment> ' , $ mainType );
474
478
475
- if (\is_string ($ subTypes ) && $ subTypes ) {
476
- $ line .= sprintf (' or %s ' , $ subTypes );
477
- } elseif (\is_array ($ subTypes ) && !empty ($ subTypes )) {
479
+ if (!empty ($ subTypes )) {
478
480
$ line .= sprintf (' or %s ' , implode (' or ' , array_map (
479
481
static fn ($ subType ) => sprintf ('<comment>%s</comment> ' , $ subType ), $ subTypes ))
480
482
);
481
-
482
- foreach ($ subTypes as $ subType ) {
483
- unset($ allTypes [$ subType ]);
484
- }
485
483
}
486
484
487
485
$ io ->writeln ($ line );
@@ -490,11 +488,30 @@ private function printAvailableTypes(ConsoleStyle $io): void
490
488
$ io ->writeln ('' );
491
489
};
492
490
491
+ $ printRelationsSection = static function () use ($ io ) {
492
+ if ('Hyper ' === getenv ('TERM_PROGRAM ' )) {
493
+ $ wizard = 'wizard 🧙 ' ;
494
+ } else {
495
+ $ wizard = '\\' === \DIRECTORY_SEPARATOR ? 'wizard ' : 'wizard 🧙 ' ;
496
+ }
497
+
498
+ $ io ->writeln (sprintf (' * <comment>relation</comment> a %s will help you build the relation ' , $ wizard ));
499
+
500
+ $ relations = [EntityRelation::MANY_TO_ONE , EntityRelation::ONE_TO_MANY , EntityRelation::MANY_TO_MANY , EntityRelation::ONE_TO_ONE ];
501
+ foreach ($ relations as $ relation ) {
502
+ $ line = sprintf (' * <comment>%s</comment> ' , $ relation );
503
+
504
+ $ io ->writeln ($ line );
505
+ }
506
+
507
+ $ io ->writeln ('' );
508
+ };
509
+
493
510
$ io ->writeln ('<info>Main Types</info> ' );
494
511
$ printSection ($ typesTable ['main ' ]);
495
512
496
513
$ io ->writeln ('<info>Relationships/Associations</info> ' );
497
- $ printSection ( $ typesTable [ ' relation ' ] );
514
+ $ printRelationsSection ( );
498
515
499
516
$ io ->writeln ('<info>Array/Object Types</info> ' );
500
517
$ printSection ($ typesTable ['array_object ' ]);
0 commit comments