3737use Symfony \UX \LiveComponent \Metadata \LiveComponentMetadataFactory ;
3838use Symfony \UX \LiveComponent \Metadata \LivePropMetadata ;
3939use Symfony \UX \LiveComponent \Util \DehydratedProps ;
40+ use Symfony \UX \LiveComponent \Util \TypeHelper ;
4041use Symfony \UX \TwigComponent \ComponentAttributes ;
4142use Twig \Environment ;
4243use Twig \Runtime \EscaperRuntime ;
@@ -314,7 +315,7 @@ public function hydrateValue(mixed $value, LivePropMetadata|LegacyLivePropMetada
314315 }
315316
316317 $ isCollection = false ;
317- foreach ($ type -> traverse () as $ t ) {
318+ foreach (TypeHelper:: traverse ($ type ) as $ t ) {
318319 if ($ isCollection = $ type instanceof CollectionType) {
319320 $ isCollection = true ;
320321 $ type = $ type ->getCollectionValueType ();
@@ -363,7 +364,7 @@ public function hydrateValue(mixed $value, LivePropMetadata|LegacyLivePropMetada
363364 return $ this ->hydrateObjectValue ($ value , $ propMetadata ->getType (), $ propMetadata ->allowsNull (), $ propMetadata ->getFormat (), $ parentObject ::class, $ propMetadata ->getName (), $ parentObject );
364365 } else {
365366 $ collectionValueType = null ;
366- foreach ($ type -> traverse () as $ t ) {
367+ foreach (TypeHelper:: traverse ($ type ) as $ t ) {
367368 if ($ t instanceof CollectionType) {
368369 $ collectionValueType = $ t ->getCollectionValueType ();
369370
@@ -372,7 +373,7 @@ public function hydrateValue(mixed $value, LivePropMetadata|LegacyLivePropMetada
372373 }
373374
374375 if ($ collectionValueType ) {
375- foreach ($ collectionValueType -> traverse () as $ t ) {
376+ foreach (TypeHelper:: traverse ($ collectionValueType ) as $ t ) {
376377 if ($ t instanceof ObjectType) {
377378 foreach ($ value as $ key => $ objectItem ) {
378379 $ 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
387388 return self ::coerceStringValue ($ value , $ type , $ type ->isNullable ());
388389 }
389390
390- foreach ($ type -> traverse () as $ t ) {
391+ foreach (TypeHelper:: traverse ($ type ) as $ t ) {
391392 if ($ t instanceof ObjectType) {
392393 return $ this ->hydrateObjectValue ($ value , $ t ->getClassName (), $ type ->isNullable (), $ propMetadata ->getFormat (), $ parentObject ::class, $ propMetadata ->getName (), $ parentObject );
393394 }
@@ -573,15 +574,15 @@ private function dehydrateValue(mixed $value, LivePropMetadata|LegacyLivePropMet
573574 } else {
574575 $ collectionValueType = null ;
575576
576- foreach ($ propMetadata ->getType ()?->traverse() ?? [] as $ t ) {
577+ foreach ($ propMetadata ->getType () ? TypeHelper:: traverse ( $ propMetadata -> getType ()) : [] as $ t ) {
577578 if ($ t instanceof CollectionType) {
578579 $ collectionValueType = $ t ->getCollectionValueType ();
579580
580581 break ;
581582 }
582583 }
583584
584- foreach ($ collectionValueType?-> traverse() ?? [] as $ t ) {
585+ foreach ($ collectionValueType ? TypeHelper:: traverse ($ collectionValueType ) : [] as $ t ) {
585586 if ($ t instanceof ObjectType) {
586587 foreach ($ value as $ key => $ objectItem ) {
587588 if (!$ t ->accepts ($ objectItem )) {
@@ -618,7 +619,7 @@ private function dehydrateValue(mixed $value, LivePropMetadata|LegacyLivePropMet
618619
619620 return $ this ->dehydrateObjectValue ($ value , $ propMetadata ->getType (), $ propMetadata ->getFormat (), $ parentObject );
620621 } else {
621- foreach ($ propMetadata ->getType ()?->traverse() ?? [] as $ t ) {
622+ foreach ($ propMetadata ->getType () ? TypeHelper:: traverse ( $ propMetadata -> getType ()) : [] as $ t ) {
622623 if ($ t instanceof ObjectType) {
623624 return $ this ->dehydrateObjectValue ($ value , $ t ->getClassName (), $ propMetadata ->getFormat (), $ parentObject );
624625 }
0 commit comments