public static function rmdir($files)
    {
        if ($files instanceof \Traversable) {
            $files = \iterator_to_array($files, false);
        } elseif (!\is_array($files)) {
            $files = [$files];
        }
        $files = \array_reverse($files);
        foreach ($files as $file) {
            if (\is_link($file)) {
                // See https://bugs.php.net/52176
                \unlink($file);

                if ('\\' !== \DIRECTORY_SEPARATOR || \file_exists($file)) {
                    throw new \Exception(\sprintf('Failed to remove symlink "%s"', $file));
                }
            } elseif (\is_dir($file)) {
                self::rmdir(new \FilesystemIterator($file, \FilesystemIterator::CURRENT_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS));
                \rmdir($file);

                if (\file_exists($file)) {
                    throw new \Exception(\sprintf('Failed to remove directory "%s"', $file));
                }
            } else {
                \unlink($file);

                if (\file_exists($file)) {
                    throw new \Exception(\sprintf('Failed to remove file "%s"', $file));
                }
            }
        }
    }