3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyMethod extends \ReflectionMethod { public function hasPrototype() { try { parent::getPrototype(); return true; } catch (\ReflectionException $e) { return false; } } public function getPrototype() { return $this->hasPrototype() ? parent::getPrototype() : "Method {$this->getName()} does not have a prototype"; } } trait TestTrait { public function getKernel() { } } class BaseTest { public function getKernel() { } } class Test extends BaseTest { use TestTrait; } $refl = new MyMethod('Test'); var_dump($refl->getMethod('getKernel')->getPrototype()); var_dump($refl->getMethod('getKernel')->getPrototype()->getPrototype()->getPrototype()->getPrototype()->getPrototype()->getPrototype()->getPrototype()->getPrototype()->getPrototype()->getPrototype()->getPrototype());

preferences:
37.02 ms | 402 KiB | 5 Q