Is there a one-line (yes, I love them) to create a new instance of the class based on the returned function string?
$obj = new {functionThatReturnsAStringValue()}();
I understand what you want, but I think you can do it this way:
$obj = ($class = functionThatReturnsAStringValue()) ? new $class() : null;
function getObject() { return 'DateTime'; } $datetime = call_user_func(function ($obj) { return new $obj; }, getObject());