3v4l.org

run code in 500+ 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.0 - 8.5.7
Array ( [paramType] => Foo [returnTypeSelf] => Foo [returnTypeStatic] => static )
Output for 8.2.31, 8.3.0 - 8.3.31, 8.4.1 - 8.4.22
Array ( [paramType] => self [returnTypeSelf] => self [returnTypeStatic] => static )

preferences:
54.54 ms | 733 KiB | 4 Q