src/Filesystem/Directory.php
public static function remove(string $dir = '', bool $emptyOnly = false): bool
    {
        $ret = true;
        $dir = static::normalizePath($dir);

        if (static::exists($dir)) {
            if ($handle = @\opendir($dir)) {
                while (false !== ($item = @\readdir($handle))) {
                    if ($item !== '.' && $item !== '..') {
                        $item = $dir.DIRECTORY_SEPARATOR.$item;
                        \is_dir($item) ? static::remove($item) : @\unlink($item);
                    }
                }
                @\closedir($handle);
            }
            if ($emptyOnly === false) {
                @\rmdir($dir);
            }
            return true;
        }
        return $ret;
    }
public static function remove(string $dir = '', bool $emptyOnly = false): bool
    {
        $ret = true;
        $dir = static::normalizePath($dir);

        if (static::exists($dir)) {
            if ($handle = @\opendir($dir)) {
                while (false !== ($item = @\readdir($handle))) {
                    if ($item !== '.' && $item !== '..') {
                        $item = $dir.DIRECTORY_SEPARATOR.$item;
                        \is_dir($item) ? static::remove($item) : @\unlink($item);
                    }
                }
                @\closedir($handle);
            }
            if ($emptyOnly === false) {
                @\rmdir($dir);
            }
            return true;
        }
        return $ret;
    }
public static function remove ( string $ dir = '' , bool $ emptyOnly = false ) : bool { $ ret = true ; $ dir = static :: normalizePath ( $ dir ) ; if ( static :: exists ( $ dir ) ) { if ( $ handle = @ \ opendir ( $ dir ) ) { while ( false !== ( $ item = @ \ readdir ( $ handle ) ) ) { if ( $ item !== '.' && $ item !== '..' ) { $ item = $ dir . DIRECTORY_SEPARATOR . $ item ; \ is_dir ( $ item ) ? static :: remove ( $ item ) : @ \ unlink ( $ item ) ; } } @ \ closedir ( $ handle ) ; } if ( $ emptyOnly === false ) { @ \ rmdir ( $ dir ) ; } return true ; } return $ ret ; }
Removes a directory with all subdirectories, files and symbolic links inside.

@param string $dir
@param bool   $emptyOnly
@return bool
Removes a directory with all subdirectories files and symbolic links inside .