php/WP_CLI/Extractor.php
public static function rmdir( $dir ) {
		$files = new RecursiveIteratorIterator(
			new RecursiveDirectoryIterator( $dir, RecursiveDirectoryIterator::SKIP_DOTS ),
			RecursiveIteratorIterator::CHILD_FIRST
		);

		foreach ( $files as $fileinfo ) {
			$todo = $fileinfo->isDir() ? 'rmdir' : 'unlink';
			$todo( $fileinfo->getRealPath() );
		}
		rmdir( $dir );
	}
public static function rmdir( $dir ) {
		$files = new RecursiveIteratorIterator(
			new RecursiveDirectoryIterator( $dir, RecursiveDirectoryIterator::SKIP_DOTS ),
			RecursiveIteratorIterator::CHILD_FIRST
		);

		foreach ( $files as $fileinfo ) {
			$todo = $fileinfo->isDir() ? 'rmdir' : 'unlink';
			$todo( $fileinfo->getRealPath() );
		}
		rmdir( $dir );
	}
public static function rmdir ( $ dir ) { $ files = new RecursiveIteratorIterator ( new RecursiveDirectoryIterator ( $ dir , RecursiveDirectoryIterator :: SKIP_DOTS ) , RecursiveIteratorIterator :: CHILD_FIRST ) ; foreach ( $ files as $ fileinfo ) { $ todo = $ fileinfo -> isDir ( ) ? 'rmdir' : 'unlink' ; $ todo ( $ fileinfo -> getRealPath ( ) ) ; } rmdir ( $ dir ) ; }
Delete all files and directories recursively from directory. Directory must exist.

@param string $dir
Delete all files and directories recursively from directory . Directory must exist .