@@ -224,9 +224,17 @@ public function denormalize(mixed $data, string $class, ?string $format = null,
224224 try {
225225 return $ this ->iriConverter ->getResourceFromIri ($ data , $ context + ['fetch_data ' => true ]);
226226 } catch (ItemNotFoundException $ e ) {
227- throw new UnexpectedValueException ($ e ->getMessage (), $ e ->getCode (), $ e );
227+ if (!isset ($ context ['not_normalizable_value_exceptions ' ])) {
228+ throw new UnexpectedValueException ($ e ->getMessage (), $ e ->getCode (), $ e );
229+ }
230+
231+ throw NotNormalizableValueException::createForUnexpectedDataType (\sprintf ('The type of the "%s" resource "string" (IRI), "%s" given. ' , $ resourceClass , \gettype ($ data )), $ data , [$ resourceClass ], $ context ['deserialization_path ' ] ?? null , true , $ e ->getCode (), $ e );
228232 } catch (InvalidArgumentException $ e ) {
229- throw new UnexpectedValueException (\sprintf ('Invalid IRI "%s". ' , $ data ), $ e ->getCode (), $ e );
233+ if (!isset ($ context ['not_normalizable_value_exceptions ' ])) {
234+ throw new UnexpectedValueException (\sprintf ('Invalid IRI "%s". ' , $ data ), $ e ->getCode (), $ e );
235+ }
236+
237+ throw NotNormalizableValueException::createForUnexpectedDataType (\sprintf ('The type of the "%s" resource "string" (IRI), "%s" given. ' , $ resourceClass , \gettype ($ data )), $ data , [$ resourceClass ], $ context ['deserialization_path ' ] ?? null , true , $ e ->getCode (), $ e );
230238 }
231239 }
232240
@@ -577,32 +585,14 @@ protected function denormalizeRelation(string $attributeName, ApiProperty $prope
577585 if (!isset ($ context ['not_normalizable_value_exceptions ' ])) {
578586 throw new UnexpectedValueException ($ e ->getMessage (), $ e ->getCode (), $ e );
579587 }
580- $ context ['not_normalizable_value_exceptions ' ][] = NotNormalizableValueException::createForUnexpectedDataType (
581- $ e ->getMessage (),
582- $ value ,
583- [$ className ],
584- $ context ['deserialization_path ' ] ?? null ,
585- true ,
586- $ e ->getCode (),
587- $ e
588- );
589-
590- return null ;
588+
589+ throw NotNormalizableValueException::createForUnexpectedDataType ($ e ->getMessage (), $ value , [$ className ], $ context ['deserialization_path ' ] ?? null , true , $ e ->getCode (), $ e );
591590 } catch (InvalidArgumentException $ e ) {
592591 if (!isset ($ context ['not_normalizable_value_exceptions ' ])) {
593592 throw new UnexpectedValueException (\sprintf ('Invalid IRI "%s". ' , $ value ), $ e ->getCode (), $ e );
594593 }
595- $ context ['not_normalizable_value_exceptions ' ][] = NotNormalizableValueException::createForUnexpectedDataType (
596- $ e ->getMessage (),
597- $ value ,
598- [$ className ],
599- $ context ['deserialization_path ' ] ?? null ,
600- true ,
601- $ e ->getCode (),
602- $ e
603- );
604-
605- return null ;
594+
595+ throw NotNormalizableValueException::createForUnexpectedDataType ($ e ->getMessage (), $ value , [$ className ], $ context ['deserialization_path ' ] ?? null , true , $ e ->getCode (), $ e );
606596 }
607597 }
608598
0 commit comments