public function addTypeLinks($code)
{
if (preg_match('/(.*?)::([^(]+)/', $code, $matches)) {
$class = $matches[1];
$method = $matches[2];
$text = $this->htmlEncode($class) . '::' . $this->htmlEncode($method);
} else {
$class = $code;
$method = null;
$text = $this->htmlEncode($class);
}
$url = null;
$shouldGenerateLink = true;
if ($method !== null) {
$reflection = new \ReflectionMethod($class, $method);
$shouldGenerateLink = $reflection->isPublic() || $reflection->isProtected();
}
if ($shouldGenerateLink) {
$url = $this->getTypeUrl($class, $method);
}
if ($url === null) {
return $text;
}
return '<a href="' . $url . '" target="_blank">' . $text . '</a>';
}