/**
 * returns doc comment for given reflector
 *
 * @internal
 * @param   \Reflector  $reflector
 * @return  string
 * @throws  \ReflectionException
 * @since   5.3.0
 */
function docComment(\Reflector $reflector) : string
{
    if ($reflector instanceof \ReflectionClass || $reflector instanceof \ReflectionFunctionAbstract || $reflector instanceof \ReflectionProperty) {
        $docComment = $reflector->getDocComment();
        return false !== $docComment ? $docComment : '';
    }
    if ($reflector instanceof \ReflectionParameter) {
        return docComment($reflector->getDeclaringFunction());
    }
    throw new \ReflectionException('Can not retrieve doc comment for ' . get_class($reflector));
}