Pagekit\Installer\SelfUpdater::doCleanup PHP Method

doCleanup() protected method

protected doCleanup ( $fileList, $dir, $path ) : array
$fileList
$dir
$path
return array
    protected function doCleanup($fileList, $dir, $path)
    {
        $errorList = [];
        foreach (array_diff(@scandir($path . '/' . $dir) ?: [], ['..', '.']) as $file) {
            $file = ($dir ? $dir . '/' : '') . $file;
            $realPath = $path . '/' . $file;
            if (is_dir($realPath)) {
                array_merge($errorList, $this->doCleanup($fileList, $file, $path));
                if (!in_array($file, $fileList)) {
                    @rmdir($realPath);
                }
            } else {
                if (!in_array($file, $fileList) && !unlink($realPath)) {
                    $errorList[] = $file;
                }
            }
        }
        return $errorList;
    }