private function writeTable($file, $value, $indentation, $fallback = true)
    {
        if (!\is_array($value) && !$value instanceof \Traversable) {
            throw new UnexpectedTypeException($value, 'array or \Traversable');
        }

        if (!$fallback) {
            fwrite($file, ':table(nofallback)');
        }

        fwrite($file, "{\n");

        foreach ($value as $key => $entry) {
            fwrite($file, str_repeat('    ', $indentation + 1));

            // escape colons, otherwise they are interpreted as resource types
            if (false !== strpos($key, ':') || false !== strpos($key, ' ')) {
                $key = '"'.$key.'"';
            }

            fwrite($file, $key);

            $this->writeResource($file, $entry, $indentation + 1);

            fwrite($file, "\n");
        }

        fprintf($file, '%s}', str_repeat('    ', $indentation));
    }