Doctrine\Common\Proxy\ProxyGenerator::formatType PHP Method

formatType() private method

private formatType ( ReflectionType $type, ReflectionMethod $method, ReflectionParameter $parameter = null ) : string
$type ReflectionType
$method ReflectionMethod
$parameter ReflectionParameter
return string
    private function formatType(\ReflectionType $type, \ReflectionMethod $method, \ReflectionParameter $parameter = null)
    {
        $name = method_exists($type, 'getName') ? $type->getName() : (string) $type;
        $nameLower = strtolower($name);
        if ('self' === $nameLower) {
            $name = $method->getDeclaringClass()->getName();
        }
        if ('parent' === $nameLower) {
            $name = $method->getDeclaringClass()->getParentClass()->getName();
        }
        if (!$type->isBuiltin() && !class_exists($name) && !interface_exists($name)) {
            if (null !== $parameter) {
                throw UnexpectedValueException::invalidParameterTypeHint($method->getDeclaringClass()->getName(), $method->getName(), $parameter->getName());
            }
            throw UnexpectedValueException::invalidReturnTypeHint($method->getDeclaringClass()->getName(), $method->getName());
        }
        if (!$type->isBuiltin()) {
            $name = '\\' . $name;
        }
        if ($type->allowsNull() && (null === $parameter || !$parameter->isOptional() || null !== $parameter->getDefaultValue())) {
            $name = '?' . $name;
        }
        return $name;
    }