[Psalm] Resolve LessSpecificReturnStatement
This commit is contained in:
@@ -24,7 +24,6 @@
|
||||
<InvalidStringClass errorLevel="info"/>
|
||||
|
||||
<LessSpecificImplementedReturnType errorLevel="info"/>
|
||||
<LessSpecificReturnStatement errorLevel="info"/>
|
||||
|
||||
<MissingClosureReturnType errorLevel="info"/>
|
||||
<MissingConstructor errorLevel="info"/>
|
||||
|
||||
@@ -40,7 +40,16 @@ abstract class EnumType extends Type
|
||||
throw ConversionException::conversionFailed($value, $this->getName());
|
||||
}
|
||||
|
||||
return new $class($id);
|
||||
if (false === \class_exists($class)) {
|
||||
throw ConversionException::conversionFailed($value, $this->getName());
|
||||
}
|
||||
|
||||
$enum = new $class($id);
|
||||
if (!$enum instanceof Enum) {
|
||||
throw ConversionException::conversionFailed($value, $this->getName());
|
||||
}
|
||||
|
||||
return $enum;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user