-
-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow using enums as a token type #77
Conversation
e7d0960
to
2ac5077
Compare
2ac5077
to
d92982b
Compare
if ($token instanceof UnitEnum) { | ||
$className = get_class($token); | ||
} else { | ||
$className = static::class; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ($token instanceof UnitEnum) { | |
$className = get_class($token); | |
} else { | |
$className = static::class; | |
} | |
if ($token instanceof UnitEnum) { | |
return $token::class . '::' . $token->name; | |
} | |
$className = static::class; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dynamic class names are not allowed in compile-time ::class fetch
This is about return $token::class . '::' . $token->name;
, I will revert to using get_class
.
Pausing this as I discovered a BC-break that affects ORM and possibly more… I think I have to make the switch from array to |
Enums allow to avoid having to come up with values to assign for each name (unless you use a backed enum), and will provide more type safety.
Enums allow to avoid having to come up with values to assign for each name (unless you use a backed enum), and will provide more type safety.
There is a small performance impact: