Skip to content

Commit 2e28889

Browse files
committed
TASK: Adjust breaking tests and fix stan annotations
1 parent a1fc7e3 commit 2e28889

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

Neos.Flow/Classes/Property/TypeConverter/ScalarTypeToBackedEnumConverter.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@ class ScalarTypeToBackedEnumConverter extends AbstractTypeConverter
2424

2525
public function canConvertFrom($source, $targetType): bool
2626
{
27-
$backingType = (new \ReflectionEnum($targetType))->getBackingType()?->getName();
28-
return (
29-
is_int($source) && $backingType === 'int'
30-
|| is_string($source) && $backingType === 'string'
31-
) && $targetType::tryFrom($source) instanceof $targetType;
27+
if (is_a($targetType, \BackedEnum::class, true)) {
28+
$backingType = (new \ReflectionEnum($targetType))->getBackingType()?->getName();
29+
return (
30+
is_int($source) && $backingType === 'int'
31+
|| is_string($source) && $backingType === 'string'
32+
) && $targetType::tryFrom($source) instanceof $targetType;
33+
}
34+
return false;
3235
}
3336

3437
public function convertFrom(

0 commit comments

Comments
 (0)