@@ -495,14 +495,19 @@ protected function denormalizeCollection(string $attribute, ApiProperty $propert
495495
496496 $ collectionKeyType = $ type ->getCollectionKeyTypes ()[0 ] ?? null ;
497497 $ collectionKeyBuiltinType = $ collectionKeyType ?->getBuiltinType();
498+ $ childContext = $ this ->createChildContext (['resource_class ' => $ className ] + $ context , $ attribute , $ format );
499+ unset($ childContext ['uri_variables ' ]);
500+ if ($ this ->resourceMetadataCollectionFactory ) {
501+ $ childContext ['operation ' ] = $ this ->resourceMetadataCollectionFactory ->create ($ className )->getOperation ();
502+ }
498503
499504 $ values = [];
500505 foreach ($ value as $ index => $ obj ) {
501506 if (null !== $ collectionKeyBuiltinType && !\call_user_func ('is_ ' .$ collectionKeyBuiltinType , $ index )) {
502507 throw NotNormalizableValueException::createForUnexpectedDataType (sprintf ('The type of the key "%s" must be "%s", "%s" given. ' , $ index , $ collectionKeyBuiltinType , \gettype ($ index )), $ index , [$ collectionKeyBuiltinType ], ($ context ['deserialization_path ' ] ?? false ) ? sprintf ('key(%s) ' , $ context ['deserialization_path ' ]) : null , true );
503508 }
504509
505- $ values [$ index ] = $ this ->denormalizeRelation ($ attribute , $ propertyMetadata , $ className , $ obj , $ format , $ this -> createChildContext ( $ context , $ attribute , $ format ) );
510+ $ values [$ index ] = $ this ->denormalizeRelation ($ attribute , $ propertyMetadata , $ className , $ obj , $ format , $ childContext );
506511 }
507512
508513 return $ values ;
@@ -753,7 +758,7 @@ private function createAndValidateAttributeValue(string $attribute, mixed $value
753758 return $ value ;
754759 }
755760
756- if (null === $ value && ( $ type ->isNullable () || ($ context [static ::DISABLE_TYPE_ENFORCEMENT ] ?? false ) )) {
761+ if (null === $ value && $ type ->isNullable () || ($ context [static ::DISABLE_TYPE_ENFORCEMENT ] ?? false )) {
757762 return $ value ;
758763 }
759764
@@ -773,7 +778,6 @@ private function createAndValidateAttributeValue(string $attribute, mixed $value
773778 && $ this ->resourceClassResolver ->isResourceClass ($ className )
774779 ) {
775780 $ resourceClass = $ this ->resourceClassResolver ->getResourceClass (null , $ className );
776- $ context ['resource_class ' ] = $ resourceClass ;
777781
778782 return $ this ->denormalizeCollection ($ attribute , $ propertyMetadata , $ type , $ resourceClass , $ value , $ format , $ context );
779783 }
@@ -785,6 +789,7 @@ private function createAndValidateAttributeValue(string $attribute, mixed $value
785789 $ resourceClass = $ this ->resourceClassResolver ->getResourceClass (null , $ className );
786790 $ childContext = $ this ->createChildContext ($ context , $ attribute , $ format );
787791 $ childContext ['resource_class ' ] = $ resourceClass ;
792+ unset($ childContext ['uri_variables ' ]);
788793 if ($ this ->resourceMetadataCollectionFactory ) {
789794 $ childContext ['operation ' ] = $ this ->resourceMetadataCollectionFactory ->create ($ resourceClass )->getOperation ();
790795 }
@@ -857,7 +862,7 @@ private function createAndValidateAttributeValue(string $attribute, mixed $value
857862 }
858863 }
859864
860- if ($ context [static ::DISABLE_TYPE_ENFORCEMENT ] ?? false ) {
865+ if ($ context [static ::DISABLE_TYPE_ENFORCEMENT ] ?? false ) { // @phpstan-ignore-line
861866 return $ value ;
862867 }
863868
0 commit comments