<?php class B { public function __toString() { return 'b'; } } class A { function getFoo(): ?string { return new B(); } } $a = new A(); var_dump($a->getFoo());
You have javascript disabled. You will not be able to edit any code.