3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ClassA {} class ClassB extends ClassA { public function methodA(self $self, parent $parent) {} } $c = new ReflectionClass('ClassB'); $m = $c->getMethod('methodA'); $t1 = $m->getParameters()[0]->getType()->getName(); $t2 = $m->getParameters()[1]->getType()->getName(); var_dump($t1, $t2, (string) $m);
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
string(4) "self" string(6) "parent" string(181) "Method [ <user> public method methodA ] { @@ /in/CDgSk 7 - 7 - Parameters [2] { Parameter #0 [ <required> self $self ] Parameter #1 [ <required> parent $parent ] } } "

preferences:
84.26 ms | 407 KiB | 5 Q