- Output for 8.1.16 - 8.1.31, 8.2.12 - 8.2.27, 8.3.0 - 8.3.15, 8.4.1 - 8.4.2
- 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());