Skip to content

Commit 477da35

Browse files
authored
Merge pull request #351 from yunicot/bugfix-enum-failed-reflection
add proxy methods to EnumReflectionProperty
2 parents b6fd1f1 + e712777 commit 477da35

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

src/Persistence/Reflection/EnumReflectionProperty.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,24 @@ private function toEnum($value)
148148

149149
return $this->enumType::from($value);
150150
}
151+
152+
/**
153+
* {@inheritDoc}
154+
*
155+
* @psalm-external-mutation-free
156+
*/
157+
public function getModifiers(): int
158+
{
159+
return $this->originalReflectionProperty->getModifiers();
160+
}
161+
162+
/**
163+
* {@inheritDoc}
164+
*
165+
* @psalm-external-mutation-free
166+
*/
167+
public function getDocComment(): string|false
168+
{
169+
return $this->originalReflectionProperty->getDocComment();
170+
}
151171
}

tests_php81/Persistence/Reflection/EnumReflectionPropertyTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,18 @@ public function testSetEnumArray(): void
113113

114114
self::assertSame([Suit::Hearts, Suit::Diamonds], $object->suits);
115115
}
116+
117+
public function testGetModifiers(): void
118+
{
119+
$reflProperty = new EnumReflectionProperty(new ReflectionProperty(TypedEnumClass::class, 'suit'), Suit::class);
120+
self::assertSame(ReflectionProperty::IS_PUBLIC, $reflProperty->getModifiers());
121+
}
122+
123+
public function testGetDocComment(): void
124+
{
125+
$reflProperty = new EnumReflectionProperty(new ReflectionProperty(TypedEnumClass::class, 'suit'), Suit::class);
126+
self::assertStringContainsString('@MyDoc', $reflProperty->getDocComment());
127+
}
116128
}
117129

118130
#[Attribute(Attribute::TARGET_PROPERTY)]
@@ -122,6 +134,7 @@ class MyAttribute
122134

123135
class TypedEnumClass
124136
{
137+
/** @MyDoc */
125138
#[MyAttribute]
126139
public ?Suit $suit = null;
127140

0 commit comments

Comments
 (0)