How to call something like this:
$instance = new ($b->method($id))();
where method(int $id): string returns class name?
The construct above gives me a syntax error, but this is ok:
$className = $b->method($id);
$instance = new $className();
I'm just wondering if and how it can be done.
I was surprised that brackets could not say that content of brackets $b->method($id) should be executed first and resulting string used to object instantiating.
I probably will not use it in production code, but I'm still interested.