37
37
use Symfony \UX \LiveComponent \Metadata \LiveComponentMetadataFactory ;
38
38
use Symfony \UX \LiveComponent \Metadata \LivePropMetadata ;
39
39
use Symfony \UX \LiveComponent \Util \DehydratedProps ;
40
+ use Symfony \UX \LiveComponent \Util \TypeHelper ;
40
41
use Symfony \UX \TwigComponent \ComponentAttributes ;
41
42
use Twig \Environment ;
42
43
use Twig \Runtime \EscaperRuntime ;
@@ -314,7 +315,7 @@ public function hydrateValue(mixed $value, LivePropMetadata|LegacyLivePropMetada
314
315
}
315
316
316
317
$ isCollection = false ;
317
- foreach ($ type -> traverse () as $ t ) {
318
+ foreach (TypeHelper:: traverse ($ type ) as $ t ) {
318
319
if ($ isCollection = $ type instanceof CollectionType) {
319
320
$ isCollection = true ;
320
321
$ type = $ type ->getCollectionValueType ();
@@ -363,7 +364,7 @@ public function hydrateValue(mixed $value, LivePropMetadata|LegacyLivePropMetada
363
364
return $ this ->hydrateObjectValue ($ value , $ propMetadata ->getType (), $ propMetadata ->allowsNull (), $ propMetadata ->getFormat (), $ parentObject ::class, $ propMetadata ->getName (), $ parentObject );
364
365
} else {
365
366
$ collectionValueType = null ;
366
- foreach ($ type -> traverse () as $ t ) {
367
+ foreach (TypeHelper:: traverse ($ type ) as $ t ) {
367
368
if ($ t instanceof CollectionType) {
368
369
$ collectionValueType = $ t ->getCollectionValueType ();
369
370
@@ -372,7 +373,7 @@ public function hydrateValue(mixed $value, LivePropMetadata|LegacyLivePropMetada
372
373
}
373
374
374
375
if ($ collectionValueType ) {
375
- foreach ($ collectionValueType -> traverse () as $ t ) {
376
+ foreach (TypeHelper:: traverse ($ collectionValueType ) as $ t ) {
376
377
if ($ t instanceof ObjectType) {
377
378
foreach ($ value as $ key => $ objectItem ) {
378
379
$ value [$ key ] = $ this ->hydrateObjectValue ($ objectItem , $ t ->getClassName (), true , $ propMetadata ->getFormat (), $ parentObject ::class, \sprintf ('%s.%s ' , $ propMetadata ->getName (), $ key ), $ parentObject );
@@ -387,7 +388,7 @@ public function hydrateValue(mixed $value, LivePropMetadata|LegacyLivePropMetada
387
388
return self ::coerceStringValue ($ value , $ type , $ type ->isNullable ());
388
389
}
389
390
390
- foreach ($ type -> traverse () as $ t ) {
391
+ foreach (TypeHelper:: traverse ($ type ) as $ t ) {
391
392
if ($ t instanceof ObjectType) {
392
393
return $ this ->hydrateObjectValue ($ value , $ t ->getClassName (), $ type ->isNullable (), $ propMetadata ->getFormat (), $ parentObject ::class, $ propMetadata ->getName (), $ parentObject );
393
394
}
@@ -573,15 +574,15 @@ private function dehydrateValue(mixed $value, LivePropMetadata|LegacyLivePropMet
573
574
} else {
574
575
$ collectionValueType = null ;
575
576
576
- foreach ($ propMetadata ->getType ()?->traverse() ?? [] as $ t ) {
577
+ foreach ($ propMetadata ->getType () ? TypeHelper:: traverse ( $ propMetadata -> getType ()) : [] as $ t ) {
577
578
if ($ t instanceof CollectionType) {
578
579
$ collectionValueType = $ t ->getCollectionValueType ();
579
580
580
581
break ;
581
582
}
582
583
}
583
584
584
- foreach ($ collectionValueType?-> traverse() ?? [] as $ t ) {
585
+ foreach ($ collectionValueType ? TypeHelper:: traverse ($ collectionValueType ) : [] as $ t ) {
585
586
if ($ t instanceof ObjectType) {
586
587
foreach ($ value as $ key => $ objectItem ) {
587
588
if (!$ t ->accepts ($ objectItem )) {
@@ -618,7 +619,7 @@ private function dehydrateValue(mixed $value, LivePropMetadata|LegacyLivePropMet
618
619
619
620
return $ this ->dehydrateObjectValue ($ value , $ propMetadata ->getType (), $ propMetadata ->getFormat (), $ parentObject );
620
621
} else {
621
- foreach ($ propMetadata ->getType ()?->traverse() ?? [] as $ t ) {
622
+ foreach ($ propMetadata ->getType () ? TypeHelper:: traverse ( $ propMetadata -> getType ()) : [] as $ t ) {
622
623
if ($ t instanceof ObjectType) {
623
624
return $ this ->dehydrateObjectValue ($ value , $ t ->getClassName (), $ propMetadata ->getFormat (), $ parentObject );
624
625
}
0 commit comments