WP_CLI

Extractor::zip_error_msg()public staticWP-CLI 1.0

Return formatted ZipArchive error message from error code.

Метод класса: Extractor{}

Хуков нет.

Возвращает

Строку|int. The error message corresponding to the specified code, if found; Other wise the same error code, unmodified.

Использование

$result = Extractor::zip_error_msg( $error_code );
$error_code(int) (обязательный)
-

Код Extractor::zip_error_msg() WP-CLI 2.8.0-alpha

public static function zip_error_msg( $error_code ) {
	// From https://github.com/php/php-src/blob/php-5.3.0/ext/zip/php_zip.c#L2623-L2646.
	static $zip_err_msgs = [
		ZipArchive::ER_OK          => 'No error',
		ZipArchive::ER_MULTIDISK   => 'Multi-disk zip archives not supported',
		ZipArchive::ER_RENAME      => 'Renaming temporary file failed',
		ZipArchive::ER_CLOSE       => 'Closing zip archive failed',
		ZipArchive::ER_SEEK        => 'Seek error',
		ZipArchive::ER_READ        => 'Read error',
		ZipArchive::ER_WRITE       => 'Write error',
		ZipArchive::ER_CRC         => 'CRC error',
		ZipArchive::ER_ZIPCLOSED   => 'Containing zip archive was closed',
		ZipArchive::ER_NOENT       => 'No such file',
		ZipArchive::ER_EXISTS      => 'File already exists',
		ZipArchive::ER_OPEN        => 'Can\'t open file',
		ZipArchive::ER_TMPOPEN     => 'Failure to create temporary file',
		ZipArchive::ER_ZLIB        => 'Zlib error',
		ZipArchive::ER_MEMORY      => 'Malloc failure',
		ZipArchive::ER_CHANGED     => 'Entry has been changed',
		ZipArchive::ER_COMPNOTSUPP => 'Compression method not supported',
		ZipArchive::ER_EOF         => 'Premature EOF',
		ZipArchive::ER_INVAL       => 'Invalid argument',
		ZipArchive::ER_NOZIP       => 'Not a zip archive',
		ZipArchive::ER_INTERNAL    => 'Internal error',
		ZipArchive::ER_INCONS      => 'Zip archive inconsistent',
		ZipArchive::ER_REMOVE      => 'Can\'t remove file',
		ZipArchive::ER_DELETED     => 'Entry has been deleted',
	];

	if ( isset( $zip_err_msgs[ $error_code ] ) ) {
		return sprintf(
			'%s (%d)',
			$zip_err_msgs[ $error_code ],
			$error_code
		);
	}
	return $error_code;
}