Skip to content

Commit

Permalink
Fixup EnumPropertyAccessor::toEnum
Browse files Browse the repository at this point in the history
  • Loading branch information
beberlei committed Nov 3, 2024
1 parent 3a1eb2e commit 149a952
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Mapping/PropertyAccessors/EnumPropertyAccessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,25 @@ private function fromEnum($enum)
}

/**
* @param int|string|int[]|string[] $value
* @param BackedEnum|BackedEnum[]|int|string|int[]|string[] $value
*
* @return ($value is int|string ? BackedEnum : BackedEnum[])
* @return ($value is int|string|BackedEnum ? BackedEnum : BackedEnum[])
*
* @psalm-suppress InvalidReturnStatement
* @psalm-suppress PossiblyInvalidArgument
*/
private function toEnum($value)

Check failure on line 65 in src/Mapping/PropertyAccessors/EnumPropertyAccessor.php

View workflow job for this annotation

GitHub Actions / coding-standards / Coding Standards (PHP: 8.3)

Method \Doctrine\ORM\Mapping\PropertyAccessors\EnumPropertyAccessor::toEnum() does not have native type hint for its parameter $value but it should be possible to add it based on @param annotation "BackedEnum|BackedEnum[]|int|string|int[]|string[]".
{
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);

Check warning on line 77 in src/Mapping/PropertyAccessors/EnumPropertyAccessor.php

View check run for this annotation

Codecov / codecov/patch

src/Mapping/PropertyAccessors/EnumPropertyAccessor.php#L77

Added line #L77 was not covered by tests
}

Expand Down

0 comments on commit 149a952

Please sign in to comment.