diff --git a/src/Form/DataTransformer/ModelToIdPropertyTransformer.php b/src/Form/DataTransformer/ModelToIdPropertyTransformer.php index 23d7877e70..2b945b8192 100644 --- a/src/Form/DataTransformer/ModelToIdPropertyTransformer.php +++ b/src/Form/DataTransformer/ModelToIdPropertyTransformer.php @@ -81,7 +81,7 @@ public function __construct( } /** - * @param mixed[]|null $value + * @param mixed $value * * @return Collection|object|null * diff --git a/src/Form/DataTransformer/ModelsToArrayTransformer.php b/src/Form/DataTransformer/ModelsToArrayTransformer.php index c7027fa5fe..c8e87bbb47 100644 --- a/src/Form/DataTransformer/ModelsToArrayTransformer.php +++ b/src/Form/DataTransformer/ModelsToArrayTransformer.php @@ -158,10 +158,14 @@ public function transform($value) * * @phpstan-return Collection|null */ - public function reverseTransform($keys) + public function reverseTransform($value) { - if (!\is_array($keys)) { - throw new UnexpectedTypeException($keys, 'array'); + if (null === $value) { + return null; + } + + if (!\is_array($value)) { + throw new UnexpectedTypeException($value, 'array'); } /** @phpstan-var ArrayCollection $collection */ @@ -169,7 +173,7 @@ public function reverseTransform($keys) $notFound = []; // optimize this into a SELECT WHERE IN query - foreach ($keys as $key) { + foreach ($value as $key) { if ($model = $this->modelManager->find($this->class, $key)) { $collection->add($model); } else {