3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Bar { } class Foo extends Bar { function getSelf (self $a): self { } function getStatic (): static { } } $refMethodSelf = new ReflectionMethod('Foo', 'getSelf'); $refMethodStatic = new ReflectionMethod('Foo', 'getStatic'); $refParam = $refMethodSelf->getParameters()[0]; print_r(array( 'paramType' => $refParam->getType()->getName(), 'returnTypeSelf' => $refMethodSelf->getReturnType()->getName(), 'returnTypeStatic' => $refMethodStatic->getReturnType()->getName(), ));
Output for 8.5.0 - 8.5.9
Array ( [paramType] => Foo [returnTypeSelf] => Foo [returnTypeStatic] => static )
Output for 8.2.31 - 8.2.32, 8.3.5 - 8.3.33, 8.4.9 - 8.4.24
Array ( [paramType] => self [returnTypeSelf] => self [returnTypeStatic] => static )

preferences:
53.02 ms | 585 KiB | 4 Q