<?php class A {} class B {} class X { private function create(string $class): object { return new $class(); } public function createA(): A { return $this->create('A'); } public function createB(): B { return $this->create('B'); } } $test = new X; $new = $test->createB(); var_export($new);
You have javascript disabled. You will not be able to edit any code.