Crell/enum-comparison

from/has scalar in reflection

Closed this issue · 5 comments

From reflection it's currently not possible to get a case from a scalar. Reflection should probably be able to do that.

technically you can do $reflectionEnum->getMethod("has")->invoke(null, $someValue); … And practically $reflectionEnum->getName()::has($value);

@bwoebi Sure, but is that generally considered enough? Many things in PHP can be done without reflection ($foo->{$bar}) but they are generally also possible through reflection.

I don't care :-D I never use the reflection way unless I have access permission issues (which cannot happen here).

Crell commented

Honestly, I'm fine with these not being accessible through reflection directly. If you're in a reflection context you can always get from there to the actual case object and then call the appropriate methods. I'm also fine if Ilija wants to add it. I don't care much either way.

Well, let's leave it then 😆