3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public function foo(): ?int { return 1; } public function baz() { return 2; } } $foo = new ReflectionMethod((new A), "foo"); $baz = new ReflectionMethod((new A), "baz"); echo "foo: " . $foo->getReturnType(); echo "baz: " . $foo->getReturnType();
Output for 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
foo: ?intbaz: ?int

preferences:
54.26 ms | 406 KiB | 5 Q