interface IFoo { public function __construct(string $foo); public function doSomething(): void; } final class FooImpl implements IFoo { public function __construct(string $foo) { // ... } public function doSomething(): void { // ... } } function instantiate(class $class, string $foo): T { return new $class($foo); } function test(): void { $foo = instantiate::(FooImpl::class, 'bar'); $foo->doSomething(); }