[Psalm] Resolve LessSpecificReturnStatement

This commit is contained in:
2019-05-12 19:00:46 +03:00
parent f1de370a0f
commit 59a42835de
2 changed files with 10 additions and 2 deletions

View File

@@ -24,7 +24,6 @@
<InvalidStringClass errorLevel="info"/>
<LessSpecificImplementedReturnType errorLevel="info"/>
<LessSpecificReturnStatement errorLevel="info"/>
<MissingClosureReturnType errorLevel="info"/>
<MissingConstructor errorLevel="info"/>

View File

@@ -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;
}
/**