On 11 December 2017 at 08:58, Marco Pivetta <ocramius@gmail.com> wrote:
> What's the use-case for creating a userland `ReflectionType` instance,
> besides mocking the reflection API itself?
> Consider that the subclassing in userland already provides an easy way to
> perform these operations (although ugly):
> https://github.com/Roave/BetterReflection/blob/2.0.1/src/Reflection/Adapter/ReflectionType.php
You are right.
And it does not even need BetterReflection library, it only needs one
single class which can also be defined locally.
It only needs $this->name, $this->allowsNull and $this->isBuiltin as
private properties.
(nothing against the library, just in case someone only needs this one feature)
Still, I think having a documented native constructor and/or static
factories would make this API more complete.
Without this, it seems like someone walked away from a construction site.
Also, inheriting from core reflection classes, I imagine always
carries some baggage.
(as opposed to implementing an interface)