3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Controller { public function testAction() { } public static function staticAction() { } public function __call($method, $arguments) { } } $calls = array( array('Controller', 'testAction'), array('Controller', 'staticAction'), array('Controller', 'fooAction'), array(new Controller, 'testAction'), array(new Controller, 'staticAction'), array(new Controller, 'fooAction'), ); foreach($calls as $controller) { $data = array(); try { $r = new ReflectionMethod($controller[0], $controller[1]); $data['controller'] = array( 'class' => is_object($controller[0]) ? get_class($controller[0]) : $controller[0], 'method' => $controller[1], 'file' => $r->getFilename(), 'line' => $r->getStartLine(), ); } catch (ReflectionException $re) { if (is_callable($controller) || method_exists($controller[0], '__call')) { $r = new ReflectionClass($controller[0]); // using __call magic $data['controller'] = array( 'class' => is_object($controller[0]) ? get_class($controller[0]) : $controller[0], 'method' => $controller[1], 'file' => $r->getFilename(), 'line' => $r->getMethod('__call')->getStartLine(), ); } } var_dump($data); }

preferences:
22.33 ms | 402 KiB | 5 Q