I've made a micro router which works with PSR 7 RequestServerInterface and ResponseInterface.
These 2 objects are injected during instantiation with something like this:
class Router {
public function __construct(
RequestServerInterface $req,
ResponseInterface $res)
{
// code...
}
}
So I want to provide a class which acts like a decorator for the Response object by extending the class which implements ResponseInterface but my problem is I don't know the name of that class.
I think Reflection is the solution because the class name will only be known at runtime. I've searched in PHP doc but don't find a way to do this...
Is there a way to extend a class at runtime in PHP?