WP_CLI\Utils

extract_from_phar()WP-CLI 1.0

Files that need to be read by external programs have to be extracted from the Phar archive.

No Hooks.

Return

null. Nothing (null).

Usage

extract_from_phar( $path );
$path (required)
-

extract_from_phar() code WP-CLI 2.8.0-alpha

function extract_from_phar( $path ) {
	if ( ! inside_phar() ) {
		return $path;
	}

	$fname = basename( $path );

	$tmp_path = get_temp_dir() . uniqid( 'wp-cli-extract-from-phar-', true ) . "-$fname";

	copy( $path, $tmp_path );

	register_shutdown_function(
		function() use ( $tmp_path ) {
			if ( file_exists( $tmp_path ) ) {
				unlink( $tmp_path );
			}
		}
	);

	return $tmp_path;
}