3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Test; class Foo { public function bar(): static { return $this; } public function baz(): self { return $this; } } foreach (['bar', 'baz'] as $method) { echo "$method:\n"; $rClass = new \ReflectionClass(Foo::class); $rMethod = $rClass->getMethod($method); var_export($rMethod->getReturnType()->isBuiltin()); echo "\n"; echo $rMethod->getReturnType()->getName(); echo "\n\n"; }
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
bar: false static baz: false self
Output for 7.4.0 - 7.4.33
Parse error: syntax error, unexpected 'static' (T_STATIC) in /in/U3JtZ on line 6
Process exited with code 255.

preferences:
92.74 ms | 401 KiB | 123 Q