3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait T { public function self(): self { return $this; } public function parent(): parent { return $this; } public function static(): static { return $this; } } $selfType = (new ReflectionMethod(T::class, 'self'))->getReturnType(); var_dump($selfType::class, $selfType->getName()); $parentType = (new ReflectionMethod(T::class, 'parent'))->getReturnType(); var_dump($parentType::class, $parentType->getName()); $staticType = (new ReflectionMethod(T::class, 'static'))->getReturnType(); var_dump($staticType::class, $staticType->getName()); final class A { use T; } $selfType = (new ReflectionMethod(A::class, 'self'))->getReturnType(); var_dump($selfType::class, $selfType->getName()); $parentType = (new ReflectionMethod(A::class, 'parent'))->getReturnType(); var_dump($parentType::class, $parentType->getName()); $staticType = (new ReflectionMethod(A::class, 'static'))->getReturnType(); var_dump($staticType::class, $staticType->getName());
Output for git.master, git.master_jit, rfc.property-hooks
string(19) "ReflectionNamedType" string(4) "self" string(19) "ReflectionNamedType" string(6) "parent" string(19) "ReflectionNamedType" string(6) "static" string(19) "ReflectionNamedType" string(4) "self" string(19) "ReflectionNamedType" string(6) "parent" string(19) "ReflectionNamedType" string(6) "static"

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
29.53 ms | 406 KiB | 5 Q