3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Bar { } class Foo extends Bar { function getSelf (self $a): self { } function getStatic (): static { } } $foo = new Foo(); $refObj = new ReflectionObject($foo); $refMethodSelf = $refObj->getMethod('getSelf'); $refMethodStatic = $refObj->getMethod('getStatic'); $refParam = $refMethodSelf->getParameters()[0]; print_r(array( 'paramType' => $refParam->getType()->getName(), 'returnTypeSelf' => $refMethodSelf->getReturnType()->getName(), 'returnTypeStatic' => $refMethodStatic->getReturnType()->getName(), ));
Output for 8.5.2 - 8.5.3
Array ( [paramType] => Foo [returnTypeSelf] => Foo [returnTypeStatic] => static )
Output for 8.3.5 - 8.3.30, 8.4.9 - 8.4.18
Array ( [paramType] => self [returnTypeSelf] => self [returnTypeStatic] => static )

preferences:
52.88 ms | 407 KiB | 5 Q