-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -570,7 +570,7 @@ public function __construct(public string $name, NamingStrategy|null $namingStra | |
* Gets the ReflectionProperties of the mapped class. | ||
* | ||
* @return LegacyReflectionFields|ReflectionProperty[] An array of ReflectionProperty instances. | ||
* @psalm-return LegacyReflectionFields|array<ReflectionProperty> | ||
* @psalm-return LegacyReflectionFields|array<string, ReflectionProperty> | ||
Check failure on line 573 in src/Mapping/ClassMetadata.php GitHub Actions / Static Analysis with Psalm (3.8.2)MismatchingDocblockReturnType
Check failure on line 573 in src/Mapping/ClassMetadata.php GitHub Actions / Static Analysis with Psalm (default)MismatchingDocblockReturnType
|
||
*/ | ||
public function getReflectionProperties(): array | ||
Check failure on line 575 in src/Mapping/ClassMetadata.php GitHub Actions / Static Analysis with PHPStan (3.8.2, phpstan-dbal3.neon)
Check failure on line 575 in src/Mapping/ClassMetadata.php GitHub Actions / Static Analysis with PHPStan (default, phpstan.neon)
|
||
{ | ||
|
@@ -600,9 +600,7 @@ public function getPropertyAccessor(string $name): PropertyAccessor|null | |
return $this->propertyAccessors[$name] ?? null; | ||
} | ||
|
||
/** | ||
* @throws BadMethodCallException If the class has a composite identifier. | ||
*/ | ||
/** @throws BadMethodCallException If the class has a composite identifier. */ | ||
public function getSingleIdReflectionProperty(): ReflectionProperty|null | ||
{ | ||
if ($this->isIdentifierComposite) { | ||
|
@@ -612,9 +610,7 @@ public function getSingleIdReflectionProperty(): ReflectionProperty|null | |
return $this->reflFields[$this->identifier[0]]; | ||
} | ||
|
||
/** | ||
* @throws BadMethodCallException If the class has a composite identifier. | ||
*/ | ||
/** @throws BadMethodCallException If the class has a composite identifier. */ | ||
public function getSingleIdPropertyAccessor(): PropertyAccessor|null | ||
{ | ||
if ($this->isIdentifierComposite) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
/** @internal */ | ||
class EnumPropertyAccessor implements PropertyAccessor | ||
{ | ||
/** @param class-string<BackedEnum> $enumType */ | ||
public function __construct(private PropertyAccessor $parent, private string $enumType) | ||
{ | ||
} | ||
|
@@ -37,7 +38,12 @@ public function getValue(object $object): mixed | |
return $this->fromEnum($enum); | ||
} | ||
|
||
private function fromEnum(array|BackedEnum $enum): int|string|array | ||
/** | ||
* @param BackedEnum|BackedEnum[] $enum | ||
* | ||
* @return ($enum is BackedEnum ? (string|int) : (string[]|int[])) | ||
*/ | ||
private function fromEnum($enum) | ||
Check failure on line 46 in src/Mapping/PropertyAccessors/EnumPropertyAccessor.php GitHub Actions / coding-standards / Coding Standards (PHP: 8.3)
|
||
{ | ||
if (is_array($enum)) { | ||
return array_map(static function (BackedEnum $enum) { | ||
|
@@ -49,22 +55,13 @@ private function fromEnum(array|BackedEnum $enum): int|string|array | |
} | ||
|
||
/** | ||
* @param int|string|int[]|string[]|BackedEnum|BackedEnum[] $value | ||
* @param int|string|int[]|string[] $value | ||
* | ||
* @return ($value is int|string|BackedEnum ? BackedEnum : BackedEnum[]) | ||
* @return ($value is int|string ? BackedEnum : BackedEnum[]) | ||
*/ | ||
private function toEnum(int|string|array|BackedEnum $value) | ||
private function toEnum($value) | ||
Check failure on line 62 in src/Mapping/PropertyAccessors/EnumPropertyAccessor.php GitHub Actions / coding-standards / Coding Standards (PHP: 8.3)
|
||
{ | ||
if ($value instanceof BackedEnum) { | ||
return $value; | ||
} | ||
|
||
if (is_array($value)) { | ||
$v = reset($value); | ||
if ($v instanceof BackedEnum) { | ||
return $value; | ||
} | ||
|
||
return array_map([$this->enumType, 'from'], $value); | ||
} | ||
|
||
|