Skip to content

Commit d27f24e

Browse files
committed
fix: Add parent constructor call in EnumReflectionProperty
1 parent 49132a5 commit d27f24e

File tree

3 files changed

+13
-50
lines changed

3 files changed

+13
-50
lines changed

phpstan-baseline.neon

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,6 @@ parameters:
55
count: 1
66
path: src/Persistence/Mapping/Driver/StaticPHPDriver.php
77

8-
-
9-
message: "#^Doctrine\\\\Persistence\\\\Reflection\\\\EnumReflectionProperty\\:\\:__construct\\(\\) does not call parent constructor from ReflectionProperty\\.$#"
10-
count: 1
11-
path: src/Persistence/Reflection/EnumReflectionProperty.php
12-
13-
-
14-
message: "#^Method Doctrine\\\\Persistence\\\\Reflection\\\\EnumReflectionProperty\\:\\:getDeclaringClass\\(\\) return type with generic class ReflectionClass does not specify its types\\: T$#"
15-
count: 1
16-
path: src/Persistence/Reflection/EnumReflectionProperty.php
17-
188
-
199
message: "#^Method Doctrine\\\\Persistence\\\\Reflection\\\\EnumReflectionProperty\\:\\:toEnum\\(\\) should return array\\<BackedEnum\\>\\|BackedEnum but returns array\\<BackedEnum\\|int\\|string\\>\\.$#"
2010
count: 1

src/Persistence/Reflection/EnumReflectionProperty.php

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
namespace Doctrine\Persistence\Reflection;
66

77
use BackedEnum;
8-
use ReflectionClass;
98
use ReflectionProperty;
10-
use ReflectionType;
119

1210
use function array_map;
1311
use function is_array;
@@ -21,29 +19,7 @@ class EnumReflectionProperty extends ReflectionProperty
2119
/** @param class-string<BackedEnum> $enumType */
2220
public function __construct(private readonly ReflectionProperty $originalReflectionProperty, private readonly string $enumType)
2321
{
24-
}
25-
26-
public function getDeclaringClass(): ReflectionClass
27-
{
28-
return $this->originalReflectionProperty->getDeclaringClass();
29-
}
30-
31-
public function getName(): string
32-
{
33-
return $this->originalReflectionProperty->getName();
34-
}
35-
36-
public function getType(): ReflectionType|null
37-
{
38-
return $this->originalReflectionProperty->getType();
39-
}
40-
41-
/**
42-
* {@inheritDoc}
43-
*/
44-
public function getAttributes(string|null $name = null, int $flags = 0): array
45-
{
46-
return $this->originalReflectionProperty->getAttributes($name, $flags);
22+
parent::__construct($originalReflectionProperty->class, $originalReflectionProperty->name);
4723
}
4824

4925
/**
@@ -120,19 +96,4 @@ private function toEnum(int|string|array|BackedEnum $value)
12096

12197
return $this->enumType::from($value);
12298
}
123-
124-
public function getModifiers(): int
125-
{
126-
return $this->originalReflectionProperty->getModifiers();
127-
}
128-
129-
public function getDocComment(): string|false
130-
{
131-
return $this->originalReflectionProperty->getDocComment();
132-
}
133-
134-
public function isPrivate(): bool
135-
{
136-
return $this->originalReflectionProperty->isPrivate();
137-
}
13899
}

tests/Persistence/Reflection/Reflection/EnumReflectionPropertyTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,18 @@ public function testIsPrivate(): void
135135
$reflProperty = new EnumReflectionProperty(new ReflectionProperty(TypedEnumClass::class, 'suit'), Suit::class);
136136
self::assertFalse($reflProperty->isPrivate());
137137
}
138+
139+
public function testIsPublic(): void
140+
{
141+
$reflProperty = new EnumReflectionProperty(new ReflectionProperty(TypedEnumClass::class, 'suit'), Suit::class);
142+
self::assertTrue($reflProperty->isPublic());
143+
}
144+
145+
public function testHasDefaultValue(): void
146+
{
147+
$reflProperty = new EnumReflectionProperty(new ReflectionProperty(TypedEnumClass::class, 'suit'), Suit::class);
148+
self::assertTrue($reflProperty->hasDefaultValue());
149+
}
138150
}
139151

140152
#[Attribute(Attribute::TARGET_PROPERTY)]

0 commit comments

Comments
 (0)