Elevate warning to ValueError for invalid ZipArchive object

This commit is contained in:
Christoph M. Becker 2019-09-29 13:58:45 +02:00
parent 6902d14b81
commit 3c16606d46
3 changed files with 10 additions and 8 deletions

View File

@ -372,8 +372,8 @@ static int php_zip_parse_options(zval *options, zend_long *remove_all_path, char
ze_zip_object *obj = Z_ZIP_P(object); \
intern = obj->za; \
if (!intern) { \
php_error_docref(NULL, E_WARNING, "Invalid or uninitialized Zip object"); \
RETURN_FALSE; \
zend_value_error("Invalid or uninitialized Zip object"); \
return; \
} \
}
/* }}} */

View File

@ -66,10 +66,10 @@ class ZipArchive
/** @return bool */
public function close() {}
/** @return int|false */
/** @return int */
public function count() {}
/** @return string|false */
/** @return string */
public function getStatusString() {}
/** @return bool */

View File

@ -26,7 +26,11 @@ if (!$zip->open(__DIR__ . '/test.zip')) {
}
if ($zip->status == ZIPARCHIVE::ER_OK) {
var_dump($zip->close());
var_dump($zip->close());
try {
$zip->close();
} catch (ValueError $err) {
echo $err->getMessage(), PHP_EOL;
}
} else {
die("Failure");
}
@ -39,7 +43,5 @@ NULL
zip_close(): supplied resource is not a valid Zip Directory resource
Object
bool(true)
Warning: ZipArchive::close(): Invalid or uninitialized Zip object in %s on line %d
bool(false)
Invalid or uninitialized Zip object
Done