- Output for 8.1.16 - 8.1.30, 8.2.12 - 8.2.25, 8.3.0 - 8.3.14
- string(1) "b"
<?php
class B
{
public function __toString()
{
return 'b';
}
}
class A {
function getFoo(): ?string
{
return new B();
}
}
$a = new A();
var_dump($a->getFoo());