3v4l.org

run code in 300+ 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.3
Array ( [paramType] => Foo [returnTypeSelf] => Foo [returnTypeStatic] => static )
Output for 8.4.18
Array ( [paramType] => self [returnTypeSelf] => self [returnTypeStatic] => static )

preferences:
43.22 ms | 406 KiB | 5 Q