]> Raphaël G. Git Repositories - airbundle/commitdiff
Update configureOptions and reverseTransform member function prototypes
authorRaphaël Gertz <git@rapsys.eu>
Tue, 27 Feb 2024 15:43:54 +0000 (16:43 +0100)
committerRaphaël Gertz <git@rapsys.eu>
Tue, 27 Feb 2024 15:43:54 +0000 (16:43 +0100)
Form/Extension/Type/HiddenEntityType.php

index 7521633c25b4ddb993b13436097eab101372a8db..f9b27d1447bd06c0e0b6b4a74c33a8ae42b2e9f0 100644 (file)
@@ -40,7 +40,7 @@ class HiddenEntityType extends HiddenType implements DataTransformerInterface {
         *
         * {@inheritdoc}
         */
         *
         * {@inheritdoc}
         */
-       public function configureOptions(OptionsResolver $resolver) {
+       public function configureOptions(OptionsResolver $resolver): void {
                //Call parent
                parent::configureOptions($resolver);
 
                //Call parent
                parent::configureOptions($resolver);
 
@@ -102,24 +102,24 @@ class HiddenEntityType extends HiddenType implements DataTransformerInterface {
        /**
         * Reverse transformation from string to data object
         *
        /**
         * Reverse transformation from string to data object
         *
-        * @param string $data The object id
+        * @param mixed $value The object id
         * @return mixed The data object
         */
         * @return mixed The data object
         */
-       public function reverseTransform($data) {
-               if (!$data) {
+       public function reverseTransform(mixed $value): mixed {
+               if (!$value) {
                        return null;
                }
 
                $res = null;
                try {
                        $rep = $this->dm->getRepository($this->class);
                        return null;
                }
 
                $res = null;
                try {
                        $rep = $this->dm->getRepository($this->class);
-                       $res = $rep->findOneById($data);
+                       $res = $rep->findOneById($value);
                } catch (\Exception $e) {
                        throw new TransformationFailedException($e->getMessage());
                }
 
                if ($res === null) {
                } catch (\Exception $e) {
                        throw new TransformationFailedException($e->getMessage());
                }
 
                if ($res === null) {
-                       throw new TransformationFailedException(sprintf('A %s with id %s does not exist!', $this->class, $data));
+                       throw new TransformationFailedException(sprintf('A %s with id %s does not exist!', $this->class, $value));
                }
 
                return $res;
                }
 
                return $res;