/**
* @param ServiceDefinition
* @return string|null
*/
protected static function detectClass(ServiceDefinition $def)
{
if ($def->getClass()) {
return $def->getClass();
} elseif ($interface = $def->getImplement()) {
$rc = Reflection\ClassType::from($interface);
$method = $rc->hasMethod('create') ? 'create' : ($rc->hasMethod('get') ? 'get' : NULL);
if ($method === NULL) {
return NULL;
}
if (!($returnType = $rc->getMethod($method)->getAnnotation('return'))) {
return NULL;
}
return Reflection\AnnotationsParser::expandClassName(preg_replace('#[|\\s].*#', '', $returnType), $rc);
}
return NULL;
}