Error retrieving entity with a "Simple array of Enum type" property #7415

Open
opened 2026-01-22 15:51:26 +01:00 by admin · 0 comments
Owner

Originally created by @Legendary4226 on GitHub (Sep 11, 2024).

Bug Report

Q A
BC Break no
Version 3.2.2

Summary

An error while retrieving entities from the database in the case of a multiple enum property created with the Symfony maker.
Error
App\Constant\Enum\MyIntEnum::from(): Argument #1 ($value) must be of type int, string given

Current behavior

TypeError:
App\Constant\Enum\MyIntEnum::from(): Argument #1 ($value) must be of type int, string given

  at C:\path\to\project\vendor\doctrine\orm\src\Internal\Hydration\AbstractHydrator.php:549
  at App\Constant\Enum\MyIntEnum::from('1')
     (C:\path\to\project\vendor\doctrine\orm\src\Internal\Hydration\AbstractHydrator.php:549)
  at Doctrine\ORM\Internal\Hydration\AbstractHydrator::Doctrine\ORM\Internal\Hydration\{closure}('1')
  at array_map(object(Closure), array('1', '2'))
     (C:\path\to\project\vendor\doctrine\orm\src\Internal\Hydration\AbstractHydrator.php:548)
  at Doctrine\ORM\Internal\Hydration\AbstractHydrator->buildEnum(array('1', '2'), 'App\\Constant\\Enum\\MyIntEnum')
     (C:\path\to\project\vendor\doctrine\orm\src\Internal\Hydration\SimpleObjectHydrator.php:143)
  at Doctrine\ORM\Internal\Hydration\SimpleObjectHydrator->hydrateRowData(array('title_1' => 'title', 'content_2' => 'content', 'illustration_3' => binary string, 'links_4' => 'links', 'category_5' => '1,2', 'id_6' => 1, 'uuid_7' => 'ab767b62-b9cf-48eb-9402-0cb304825fbc', 'created_at_8' => '2024-09-11 09:08:48.289139', 'updated_at_9' => '2024-09-11 09:08:48.289130'), array())
     (C:\path\to\project\vendor\doctrine\orm\src\Internal\Hydration\SimpleObjectHydrator.php:59)
  at Doctrine\ORM\Internal\Hydration\SimpleObjectHydrator->hydrateAllData()
     (C:\path\to\project\vendor\doctrine\orm\src\Internal\Hydration\AbstractHydrator.php:168)
  at Doctrine\ORM\Internal\Hydration\AbstractHydrator->hydrateAll(object(Result), object(ResultSetMapping), array('deferEagerLoad' => true))
     (C:\path\to\project\vendor\doctrine\orm\src\Persisters\Entity\BasicEntityPersister.php:937)
  at Doctrine\ORM\Persisters\Entity\BasicEntityPersister->loadAll(array(), null, null, null)
     (C:\path\to\project\vendor\doctrine\orm\src\EntityRepository.php:110)
  at Doctrine\ORM\EntityRepository->findBy(array(), null, null, null)
     (C:\path\to\project\vendor\doctrine\doctrine-bundle\src\Repository\ServiceEntityRepositoryProxy.php:72)
  at Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepositoryProxy->findBy(array())
     (C:\path\to\project\vendor\doctrine\orm\src\EntityRepository.php:96)
  at Doctrine\ORM\EntityRepository->findAll()
     (C:\path\to\project\src\Controller\SuperAdmin\SuperAdminNewsController.php:26)
  at App\Controller\SuperAdmin\SuperAdminNewsController->index(object(NewsRepository))
     (C:\path\to\project\vendor\symfony\http-kernel\HttpKernel.php:183)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (C:\path\to\project\vendor\symfony\http-kernel\HttpKernel.php:76)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (C:\path\to\project\vendor\symfony\http-kernel\Kernel.php:182)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (C:\path\to\project\vendor\symfony\runtime\Runner\Symfony\HttpKernelRunner.php:35)
  at Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run()
     (C:\path\to\project\vendor\autoload_runtime.php:29)
  at require_once('C:\\Users\\Admin\\Documents\\vigidomaine\\vendor\\autoload_runtime.php')
     (C:\path\to\project\public\index.php:5)

How to reproduce

The property inside of my entity (generated via the Symfony maker):

#[ORM\Column(type: Types::SIMPLE_ARRAY, enumType: MyIntEnum::class)]
private array $enums = [];

My Enum :

enum MyIntEnum: int
{
   case ONE = 1;
   case TWO = 2;
}

Expected behavior

No errors, the entity is loaded properly with the $enums property as an array of "array<MyIntEnum>"

Originally created by @Legendary4226 on GitHub (Sep 11, 2024). ### Bug Report <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |------------ | ------ | BC Break | no | Version | 3.2.2 #### Summary An error while retrieving entities from the database in the case of a multiple enum property created with the Symfony maker. Error `App\Constant\Enum\MyIntEnum::from(): Argument #1 ($value) must be of type int, string given` #### Current behavior <!-- What is the current (buggy) behavior? --> ``` TypeError: App\Constant\Enum\MyIntEnum::from(): Argument #1 ($value) must be of type int, string given at C:\path\to\project\vendor\doctrine\orm\src\Internal\Hydration\AbstractHydrator.php:549 at App\Constant\Enum\MyIntEnum::from('1') (C:\path\to\project\vendor\doctrine\orm\src\Internal\Hydration\AbstractHydrator.php:549) at Doctrine\ORM\Internal\Hydration\AbstractHydrator::Doctrine\ORM\Internal\Hydration\{closure}('1') at array_map(object(Closure), array('1', '2')) (C:\path\to\project\vendor\doctrine\orm\src\Internal\Hydration\AbstractHydrator.php:548) at Doctrine\ORM\Internal\Hydration\AbstractHydrator->buildEnum(array('1', '2'), 'App\\Constant\\Enum\\MyIntEnum') (C:\path\to\project\vendor\doctrine\orm\src\Internal\Hydration\SimpleObjectHydrator.php:143) at Doctrine\ORM\Internal\Hydration\SimpleObjectHydrator->hydrateRowData(array('title_1' => 'title', 'content_2' => 'content', 'illustration_3' => binary string, 'links_4' => 'links', 'category_5' => '1,2', 'id_6' => 1, 'uuid_7' => 'ab767b62-b9cf-48eb-9402-0cb304825fbc', 'created_at_8' => '2024-09-11 09:08:48.289139', 'updated_at_9' => '2024-09-11 09:08:48.289130'), array()) (C:\path\to\project\vendor\doctrine\orm\src\Internal\Hydration\SimpleObjectHydrator.php:59) at Doctrine\ORM\Internal\Hydration\SimpleObjectHydrator->hydrateAllData() (C:\path\to\project\vendor\doctrine\orm\src\Internal\Hydration\AbstractHydrator.php:168) at Doctrine\ORM\Internal\Hydration\AbstractHydrator->hydrateAll(object(Result), object(ResultSetMapping), array('deferEagerLoad' => true)) (C:\path\to\project\vendor\doctrine\orm\src\Persisters\Entity\BasicEntityPersister.php:937) at Doctrine\ORM\Persisters\Entity\BasicEntityPersister->loadAll(array(), null, null, null) (C:\path\to\project\vendor\doctrine\orm\src\EntityRepository.php:110) at Doctrine\ORM\EntityRepository->findBy(array(), null, null, null) (C:\path\to\project\vendor\doctrine\doctrine-bundle\src\Repository\ServiceEntityRepositoryProxy.php:72) at Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepositoryProxy->findBy(array()) (C:\path\to\project\vendor\doctrine\orm\src\EntityRepository.php:96) at Doctrine\ORM\EntityRepository->findAll() (C:\path\to\project\src\Controller\SuperAdmin\SuperAdminNewsController.php:26) at App\Controller\SuperAdmin\SuperAdminNewsController->index(object(NewsRepository)) (C:\path\to\project\vendor\symfony\http-kernel\HttpKernel.php:183) at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1) (C:\path\to\project\vendor\symfony\http-kernel\HttpKernel.php:76) at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true) (C:\path\to\project\vendor\symfony\http-kernel\Kernel.php:182) at Symfony\Component\HttpKernel\Kernel->handle(object(Request)) (C:\path\to\project\vendor\symfony\runtime\Runner\Symfony\HttpKernelRunner.php:35) at Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run() (C:\path\to\project\vendor\autoload_runtime.php:29) at require_once('C:\\Users\\Admin\\Documents\\vigidomaine\\vendor\\autoload_runtime.php') (C:\path\to\project\public\index.php:5) ``` #### How to reproduce The property inside of my entity (generated via the Symfony maker): ```php #[ORM\Column(type: Types::SIMPLE_ARRAY, enumType: MyIntEnum::class)] private array $enums = []; ``` My Enum : ```php enum MyIntEnum: int { case ONE = 1; case TWO = 2; } ``` #### Expected behavior <!-- What was the expected (correct) behavior? --> No errors, the entity is loaded properly with the $enums property as an array of "array\<MyIntEnum\>"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7415