protected function cleanType(?string $type): ?string
    {
        if (!$type || in_array(strtolower($type), ['null', 'mixed']) || strpos($type, '|')) {
            return null;
        }
        $lowerType = strtolower($type);
        if (in_array(ltrim($lowerType, '?'), [
            'array', 'int', 'integer', 'bool', 'boolean', 'float', 'double', 
            'real', 'string', 'object', 'unset', 'callback'
        ])) {
            return $lowerType;
        }
        return '\\' . ltrim($type, '\\');
    }