bug: AttributeDriver throws error for repeatable attributes #6752

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

Originally created by @ph-fritsche on GitHub (Jun 9, 2021).

Doctrine\ORM\Mapping\Driver\AttributeDriver extends Doctrine\Persistence\Mapping\Driver\AnnotationDriver.

AttributeDriver::isTransient resolves to AnnotationDriver::isTransient.

If a class has repeating attributes an error is thrown in AnnotationDriver:182 because $annot is an array.

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;

#[ORM\Index(columns: ['foo'])]
#[ORM\Index(columns: ['bar', 'baz'])]
#[ORM\Entity]
class Foo
{
 //...

Workaround: When the repeatable attributes trail non-repeatable ones of entityAnnotationClasses the method returns before the error occurs.

Originally created by @ph-fritsche on GitHub (Jun 9, 2021). [`Doctrine\ORM\Mapping\Driver\AttributeDriver`](https://github.com/doctrine/orm/blob/2.9.x/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php) extends [`Doctrine\Persistence\Mapping\Driver\AnnotationDriver`](https://github.com/doctrine/persistence/blob/2.2.x/lib/Doctrine/Persistence/Mapping/Driver/AnnotationDriver.php). `AttributeDriver::isTransient` resolves to `AnnotationDriver::isTransient`. If a class has repeating attributes an error is thrown in [AnnotationDriver:182](https://github.com/doctrine/persistence/blob/79e97bcb1dfe3b242961253d81b8357a04e96ca1/lib/Doctrine/Persistence/Mapping/Driver/AnnotationDriver.php#L179-L182) because `$annot` is an `array`. ```php namespace App\Entity; use Doctrine\ORM\Mapping as ORM; #[ORM\Index(columns: ['foo'])] #[ORM\Index(columns: ['bar', 'baz'])] #[ORM\Entity] class Foo { //... ``` Workaround: When the repeatable attributes trail non-repeatable ones of `entityAnnotationClasses` the method returns before the error occurs.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6752