private function buildArrayLiteral(array $value, array $requiredSizes): string
    {
        $requiredCount = array_shift($requiredSizes);
        if ($requiredCount !== count($value)) {
            throw TypeConversionException::unexpectedValue(
                $this,
                'output',
                "array with {$requiredCount} value(s)",
                $value
            );
        }

        $parts = [];
        if (empty($requiredSizes)) {
            foreach ($value as $v) {
                $item    = $this->itemConverter->output($v);
                $parts[] = ($item === null) ? 'NULL' : '"' . addcslashes($item, "\"\\") . '"';
            }

        } else {
            foreach ($value as $v) {
                if (!is_array($v)) {
                    throw TypeConversionException::unexpectedValue($this, 'output', 'array', $v);
                }
                $parts[] = $this->buildArrayLiteral($v, $requiredSizes);
            }
        }

        return '{' . implode(',', $parts) . '}';
    }