Repository: doctrine/orm (php)
Issue: ReflectionEnumProperty throws error on AttributeReader::getPropertyAnnotations()
### Bug Report

|    Q        |   A
|------------ | ------
| BC Break    | no
| Version     | 2.11.0

#### Summary

An Error "Internal error: Failed to retrieve the reflection object" is thrown when calling `AttributeReader::getPropertyAnotations` because the inherited function `ReflectionProperty::getAttributes()` is not called on the original reflection property in the `ReflectionEnumProperty` class. 
In my specific case I 'm using custom annotations I have to read for custom behaviour. When trying to retrieve the custom annotations the error occurs. 

#### Current behavior
When trying to fetch all or a specific annotation of an entity property, the call fails with an error "Internal error: Failed to retrieve the reflection object".

#### How to reproduce

```
enum Suit: string {
    case Hearts = 'H';
    case Diamonds = 'D';
    case Clubs = 'C';
    case Spades = 'S';
}

#[Entity]
class Card
{
    /** ... */

    #[Column(type: 'string', enumType: Suit::class)]
    #[AnyCustomAnnotation(param: 'bla')]
    public $suit;
}

/** ... */

// @var \Doctrine\ORM\EntityManager
$metadata = $objectManager->getClassMetadata(Card::class);

foreach ($metadata->fieldMappings as $field => $mapping) {
    $property = $metadata->getReflectionProperty($field);
    // @var Doctrine\ORM\Mapping\Driver\AttributeReader
    $isCustom = $reader->getPropertyAnnotation($property, AnyCustomAnnotation::class);
    /** ... */
}

```

#### Expected behavior

The expected behaviour should return the property attributes like `ReflectionProperty::getAttributes()` is supposed to. A possible solution could be extending the `ReflectionEnumProperty` class with an inherited `getAttributes` method, that will return the attributes from the original reflection property.

```
class ReflectionEnumProperty extends ReflectionProperty
{
    ...
    /**
     * {@inheritDoc}
     */
     public function getAttributes(?string $name = null, int $flags = 0): array
     {
         return $this->originalReflectionProperty->getAttributes();
     }
}
```


Pull request description: [GH-9380] Bugfix: Delegate ReflectionEnumProperty::getAttributes().
Fixes #9380 

Patch:
diff --git a/lib/Doctrine/ORM/Mapping/ReflectionEnumProperty.php b/lib/Doctrine/ORM/Mapping/ReflectionEnumProperty.php
index f88063da5..032ebdf3e 100644
--- a/lib/Doctrine/ORM/Mapping/ReflectionEnumProperty.php
+++ b/lib/Doctrine/ORM/Mapping/ReflectionEnumProperty.php
@@ -29,6 +29,11 @@ class ReflectionEnumProperty extends ReflectionProperty
     {
         $this->originalReflectionProperty = $originalReflectionProperty;
         $this->enumType                   = $enumType;
+
+        parent::__construct(
+            $originalReflectionProperty->getDeclaringClass()->getName(),
+            $originalReflectionProperty->getName()
+        );
     }
 
     /**


Test patch:
diff --git a/tests/Doctrine/Tests/ORM/Functional/EnumTest.php b/tests/Doctrine/Tests/ORM/Functional/EnumTest.php
index dff8bf6a4..d96fef047 100644
--- a/tests/Doctrine/Tests/ORM/Functional/EnumTest.php
+++ b/tests/Doctrine/Tests/ORM/Functional/EnumTest.php
@@ -4,6 +4,7 @@ declare(strict_types=1);
 
 namespace Doctrine\Tests\ORM\Functional;
 
+use Doctrine\ORM\Mapping\Column;
 use Doctrine\ORM\Mapping\Driver\AttributeDriver;
 use Doctrine\ORM\Mapping\MappingException;
 use Doctrine\ORM\Tools\SchemaTool;
@@ -22,11 +23,11 @@ class EnumTest extends OrmFunctionalTestCase
 {
     public function setUp(): void
     {
+        parent::setUp();
+
         $this->_em         = $this->getEntityManager(null, new AttributeDriver([dirname(__DIR__, 2) . '/Models/Enums']));
         $this->_schemaTool = new SchemaTool($this->_em);
 
-        parent::setUp();
-
         if ($this->isSecondLevelCacheEnabled) {
             $this->markTestSkipped();
         }
@@ -101,4 +102,15 @@ EXCEPTION
             TypedCard::class => [TypedCard::class],
         ];
     }
+
+    public function testItAllowsReadingAttributes(): void
+    {
+        $metadata = $this->_em->getClassMetadata(Card::class);
+        $property = $metadata->getReflectionProperty('suit');
+
+        $attributes = $property->getAttributes();
+
+        $this->assertCount(1, $attributes);
+        $this->assertEquals(Column::class, $attributes[0]->getName());
+    }
 }