From aa9d0bda6ca7ad6ca333bc1d0a46c45afba565df Mon Sep 17 00:00:00 2001 From: BrunoKingbee <100942201+BrunoKingbee@users.noreply.github.com> Date: Fri, 29 Dec 2023 16:11:43 +0100 Subject: [PATCH 1/4] add return types for interface EntitiesToPropertyTransformer.php --- Form/DataTransformer/EntitiesToPropertyTransformer.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Form/DataTransformer/EntitiesToPropertyTransformer.php b/Form/DataTransformer/EntitiesToPropertyTransformer.php index d6a9fd8..be46105 100644 --- a/Form/DataTransformer/EntitiesToPropertyTransformer.php +++ b/Form/DataTransformer/EntitiesToPropertyTransformer.php @@ -52,18 +52,18 @@ public function __construct(ObjectManager $em, $class, $textProperty = null, $pr /** * Transform initial entities to array * - * @param mixed $entities + * @param mixed $value * @return array */ - public function transform($entities) + public function transform(mixed $value): mixed { - if (empty($entities)) { + if (empty($value)) { return array(); } $data = array(); - foreach ($entities as $entity) { + foreach ($value as $entity) { $text = is_null($this->textProperty) ? (string) $entity : $this->accessor->getValue($entity, $this->textProperty); @@ -87,7 +87,7 @@ public function transform($entities) * @param array $values * @return array */ - public function reverseTransform($values) + public function reverseTransform(mixed $values): mixed { if (!is_array($values) || empty($values)) { return array(); From 1b0231e38a9a732f302e04a3ce80ce91f20f50be Mon Sep 17 00:00:00 2001 From: BrunoKingbee <100942201+BrunoKingbee@users.noreply.github.com> Date: Fri, 29 Dec 2023 16:12:10 +0100 Subject: [PATCH 2/4] add return types for interface used in EntityToPropertyTransformer.php --- .../EntityToPropertyTransformer.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Form/DataTransformer/EntityToPropertyTransformer.php b/Form/DataTransformer/EntityToPropertyTransformer.php index 72a30a9..36993d5 100644 --- a/Form/DataTransformer/EntityToPropertyTransformer.php +++ b/Form/DataTransformer/EntityToPropertyTransformer.php @@ -53,22 +53,22 @@ public function __construct(ObjectManager $em, $class, $textProperty = null, $pr /** * Transform entity to array * - * @param mixed $entity + * @param mixed $value * @return array */ - public function transform($entity) + public function transform(mixed $value): mixed { $data = array(); - if (empty($entity)) { + if (empty($value)) { return $data; } $text = is_null($this->textProperty) - ? (string) $entity - : $this->accessor->getValue($entity, $this->textProperty); + ? (string) $value + : $this->accessor->getValue($value, $this->textProperty); - if ($this->em->contains($entity)) { - $value = (string) $this->accessor->getValue($entity, $this->primaryKey); + if ($this->em->contains($value)) { + $value = (string) $this->accessor->getValue($value, $this->primaryKey); } else { $value = $this->newTagPrefix . $text; $text = $text.$this->newTagText; @@ -85,7 +85,7 @@ public function transform($entity) * @param string $value * @return mixed|null|object */ - public function reverseTransform($value) + public function reverseTransform(mixed $value): mixed { if (empty($value)) { return null; From de43a963fb56339119eef3bd0f3d96ed1ce58abc Mon Sep 17 00:00:00 2001 From: BrunoKingbee <100942201+BrunoKingbee@users.noreply.github.com> Date: Fri, 29 Dec 2023 16:20:15 +0100 Subject: [PATCH 3/4] change back variable names EntitiesToPropertyTransformer transform --- Form/DataTransformer/EntitiesToPropertyTransformer.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Form/DataTransformer/EntitiesToPropertyTransformer.php b/Form/DataTransformer/EntitiesToPropertyTransformer.php index be46105..ad24962 100644 --- a/Form/DataTransformer/EntitiesToPropertyTransformer.php +++ b/Form/DataTransformer/EntitiesToPropertyTransformer.php @@ -52,18 +52,18 @@ public function __construct(ObjectManager $em, $class, $textProperty = null, $pr /** * Transform initial entities to array * - * @param mixed $value + * @param mixed $entities * @return array */ - public function transform(mixed $value): mixed + public function transform(mixed $entities): mixed { - if (empty($value)) { + if (empty($entities)) { return array(); } $data = array(); - foreach ($value as $entity) { + foreach ($entities as $entity) { $text = is_null($this->textProperty) ? (string) $entity : $this->accessor->getValue($entity, $this->textProperty); From facfa7812883175844c9c4400d2437879807baaa Mon Sep 17 00:00:00 2001 From: BrunoKingbee <100942201+BrunoKingbee@users.noreply.github.com> Date: Fri, 29 Dec 2023 16:23:31 +0100 Subject: [PATCH 4/4] revert change renaming param --- .../EntityToPropertyTransformer.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Form/DataTransformer/EntityToPropertyTransformer.php b/Form/DataTransformer/EntityToPropertyTransformer.php index 36993d5..2b7bb16 100644 --- a/Form/DataTransformer/EntityToPropertyTransformer.php +++ b/Form/DataTransformer/EntityToPropertyTransformer.php @@ -53,22 +53,22 @@ public function __construct(ObjectManager $em, $class, $textProperty = null, $pr /** * Transform entity to array * - * @param mixed $value + * @param mixed $entity * @return array */ - public function transform(mixed $value): mixed + public function transform(mixed $entity): mixed { $data = array(); - if (empty($value)) { + if (empty($entity)) { return $data; } $text = is_null($this->textProperty) - ? (string) $value - : $this->accessor->getValue($value, $this->textProperty); + ? (string) $entity + : $this->accessor->getValue($entity, $this->textProperty); - if ($this->em->contains($value)) { - $value = (string) $this->accessor->getValue($value, $this->primaryKey); + if ($this->em->contains($entity)) { + $value = (string) $this->accessor->getValue($entity, $this->primaryKey); } else { $value = $this->newTagPrefix . $text; $text = $text.$this->newTagText;