Skip to content

Commit

Permalink
add proxy methods to EnumReflectionProperty
Browse files Browse the repository at this point in the history
  • Loading branch information
yunicot committed Mar 11, 2024
1 parent b6fd1f1 commit e712777
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Persistence/Reflection/EnumReflectionProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,24 @@ private function toEnum($value)

return $this->enumType::from($value);
}

/**
* {@inheritDoc}
*
* @psalm-external-mutation-free
*/
public function getModifiers(): int
{

Check warning on line 158 in src/Persistence/Reflection/EnumReflectionProperty.php

View check run for this annotation

Codecov / codecov/patch

src/Persistence/Reflection/EnumReflectionProperty.php#L158

Added line #L158 was not covered by tests
return $this->originalReflectionProperty->getModifiers();
}

Check warning on line 160 in src/Persistence/Reflection/EnumReflectionProperty.php

View check run for this annotation

Codecov / codecov/patch

src/Persistence/Reflection/EnumReflectionProperty.php#L160

Added line #L160 was not covered by tests

/**
* {@inheritDoc}
*
* @psalm-external-mutation-free
*/
public function getDocComment(): string|false
{

Check warning on line 168 in src/Persistence/Reflection/EnumReflectionProperty.php

View check run for this annotation

Codecov / codecov/patch

src/Persistence/Reflection/EnumReflectionProperty.php#L168

Added line #L168 was not covered by tests
return $this->originalReflectionProperty->getDocComment();
}

Check warning on line 170 in src/Persistence/Reflection/EnumReflectionProperty.php

View check run for this annotation

Codecov / codecov/patch

src/Persistence/Reflection/EnumReflectionProperty.php#L170

Added line #L170 was not covered by tests
}
13 changes: 13 additions & 0 deletions tests_php81/Persistence/Reflection/EnumReflectionPropertyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@ public function testSetEnumArray(): void

self::assertSame([Suit::Hearts, Suit::Diamonds], $object->suits);
}

public function testGetModifiers(): void
{
$reflProperty = new EnumReflectionProperty(new ReflectionProperty(TypedEnumClass::class, 'suit'), Suit::class);
self::assertSame(ReflectionProperty::IS_PUBLIC, $reflProperty->getModifiers());
}

public function testGetDocComment(): void
{
$reflProperty = new EnumReflectionProperty(new ReflectionProperty(TypedEnumClass::class, 'suit'), Suit::class);
self::assertStringContainsString('@MyDoc', $reflProperty->getDocComment());
}
}

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

class TypedEnumClass
{
/** @MyDoc */
#[MyAttribute]
public ?Suit $suit = null;

Expand Down

0 comments on commit e712777

Please sign in to comment.