Q:

How to get the class from a callable

In this situation:
$callable1 = "\somenamespace\someclass::somefunction";
$callable2 = array('someclass', 'somefunction');
$callable3 = 'somefunction';
$callable4 = array($someInstance, 'somefunction');

Is there a way I can reliably extract the namespace and class (if any) from a callable, no matter the format in which it is defined?

A:

The following class seems to do exactly what you need:
CallableReflection.php
It looks like the namespace extraction is missing. You can add it yourself with PHP's reflection:
ReflectionClass::getNamespaceName

