public static function removeDir(string $dir)
    {
        foreach (scandir($dir) as $file) {
            if ('.' === $file || '..' === $file) {
                continue;
            }
            if (is_dir($dir . '/' . $file)) {
                self::removeDir($dir . '/' . $file);
            } else {
                unlink($dir . '/' . $file);
            }
        }
        rmdir($dir);
    }
public static function removeDir(string $dir)
    {
        foreach (scandir($dir) as $file) {
            if ('.' === $file || '..' === $file) {
                continue;
            }
            if (is_dir($dir . '/' . $file)) {
                self::removeDir($dir . '/' . $file);
            } else {
                unlink($dir . '/' . $file);
            }
        }
        rmdir($dir);
    }
public static function removeDir ( string $ dir ) { foreach ( scandir ( $ dir ) as $ file ) { if ( '.' === $ file || '..' === $ file ) { continue ; } if ( is_dir ( $ dir . '/' . $ file ) ) { self :: removeDir ( $ dir . '/' . $ file ) ; } else { unlink ( $ dir . '/' . $ file ) ; } } rmdir ( $ dir ) ; }
Removes a directory that is not empty.

@param string $dir
Removes a directory that is not empty .