Get rid of EnumTrait::fromString()

it's better to just implement this for stuff where there's explicitly designated aliases, otherwise we could end up with unexpected BC breaks (e.g. hardcoding POSTWORLD in plugin.yml would suddenly break if the core enum was changed, even though it remained valid).
This commit is contained in:
Dylan K. Taylor
2021-06-27 20:52:56 +01:00
parent 902ea515f7
commit 3dd33cd35e
3 changed files with 61 additions and 23 deletions

View File

@ -56,19 +56,6 @@ trait EnumTrait{
return $result;
}
/**
* Returns the enum member matching the given name.
* This is overridden to change the return typehint.
*
* @throws \InvalidArgumentException if no member matches.
*/
public static function fromString(string $name) : self{
//phpstan doesn't support generic traits yet :(
/** @var self $result */
$result = self::_registryFromString($name);
return $result;
}
/** @var int|null */
private static $nextId = null;