php/WP_CLI/Extractor.php
public static function copy_overwrite_files( $source, $dest ) {
		$iterator = new RecursiveIteratorIterator(
			new RecursiveDirectoryIterator( $source, RecursiveDirectoryIterator::SKIP_DOTS ),
			RecursiveIteratorIterator::SELF_FIRST
		);

		$error = 0;

		if ( ! is_dir( $dest ) ) {
			mkdir( $dest, 0777, true );
		}

		foreach ( $iterator as $item ) {

			$dest_path = $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName();

			if ( $item->isDir() ) {
				if ( ! is_dir( $dest_path ) ) {
					mkdir( $dest_path );
				}
			} else {
				if ( file_exists( $dest_path ) && is_writable( $dest_path ) ) {
					copy( $item, $dest_path );
				} elseif ( ! file_exists( $dest_path ) ) {
					copy( $item, $dest_path );
				} else {
					$error = 1;
					WP_CLI::warning( "Unable to copy '" . $iterator->getSubPathName() . "' to current directory." );
				}
			}
		}

		if ( $error ) {
			throw new \Exception( 'There was an error overwriting existing files.' );
		}
	}
public static function copy_overwrite_files( $source, $dest ) {
		$iterator = new RecursiveIteratorIterator(
			new RecursiveDirectoryIterator( $source, RecursiveDirectoryIterator::SKIP_DOTS ),
			RecursiveIteratorIterator::SELF_FIRST
		);

		$error = 0;

		if ( ! is_dir( $dest ) ) {
			mkdir( $dest, 0777, true );
		}

		foreach ( $iterator as $item ) {

			$dest_path = $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName();

			if ( $item->isDir() ) {
				if ( ! is_dir( $dest_path ) ) {
					mkdir( $dest_path );
				}
			} else {
				if ( file_exists( $dest_path ) && is_writable( $dest_path ) ) {
					copy( $item, $dest_path );
				} elseif ( ! file_exists( $dest_path ) ) {
					copy( $item, $dest_path );
				} else {
					$error = 1;
					WP_CLI::warning( "Unable to copy '" . $iterator->getSubPathName() . "' to current directory." );
				}
			}
		}

		if ( $error ) {
			throw new \Exception( 'There was an error overwriting existing files.' );
		}
	}
public static function copy_overwrite_files ( $ source , $ dest ) { $ iterator = new RecursiveIteratorIterator ( new RecursiveDirectoryIterator ( $ source , RecursiveDirectoryIterator :: SKIP_DOTS ) , RecursiveIteratorIterator :: SELF_FIRST ) ; $ error = 0 ; if ( ! is_dir ( $ dest ) ) { mkdir ( $ dest , 0777 , true ) ; } foreach ( $ iterator as $ item ) { $ dest_path = $ dest . DIRECTORY_SEPARATOR . $ iterator -> getSubPathName ( ) ; if ( $ item -> isDir ( ) ) { if ( ! is_dir ( $ dest_path ) ) { mkdir ( $ dest_path ) ; } } else { if ( file_exists ( $ dest_path ) && is_writable ( $ dest_path ) ) { copy ( $ item , $ dest_path ) ; } elseif ( ! file_exists ( $ dest_path ) ) { copy ( $ item , $ dest_path ) ; } else { $ error = 1 ; WP_CLI :: warning ( "Unable to copy '" . $ iterator -> getSubPathName ( ) . "' to current directory." ) ; } } } if ( $ error ) { throw new \ Exception ( 'There was an error overwriting existing files.' ) ; } }
Copy files from source directory to destination directory. Source directory must exist.

@param string $source
@param string $dest
Copy files from source directory to destination directory . Source directory must exist .