Skip to content

Commit be98aae

Browse files
committed
Promote newly introduced warnings to TypeError in case of strict_types
1 parent c6529b2 commit be98aae

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

ext/zip/php_zip.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,11 @@ static bool php_zip_parse_options(HashTable *options, zip_options *opts)
350350

351351
if ((option = zend_hash_str_find(options, "remove_all_path", sizeof("remove_all_path") - 1)) != NULL) {
352352
if (Z_TYPE_P(option) != IS_FALSE && Z_TYPE_P(option) != IS_TRUE) {
353+
if (ZEND_CALL_USES_STRICT_TYPES(EG(current_execute_data))) {
354+
zend_type_error("Option \"comp_method\" must be of type bool, %s given",
355+
zend_zval_type_name(option));
356+
return false;
357+
}
353358
php_error_docref(NULL, E_WARNING, "Option \"remove_all_path\" must be of type bool, %s given",
354359
zend_zval_type_name(option));
355360
}
@@ -358,13 +363,23 @@ static bool php_zip_parse_options(HashTable *options, zip_options *opts)
358363

359364
if ((option = zend_hash_str_find(options, "comp_method", sizeof("comp_method") - 1)) != NULL) {
360365
if (Z_TYPE_P(option) != IS_LONG) {
366+
if (ZEND_CALL_USES_STRICT_TYPES(EG(current_execute_data))) {
367+
zend_type_error("Option \"comp_method\" must be of type int, %s given",
368+
zend_zval_type_name(option));
369+
return false;
370+
}
361371
php_error_docref(NULL, E_WARNING, "Option \"comp_method\" must be of type int, %s given",
362372
zend_zval_type_name(option));
363373
}
364374
opts->comp_method = zval_get_long(option);
365375

366376
if ((option = zend_hash_str_find(options, "comp_flags", sizeof("comp_flags") - 1)) != NULL) {
367377
if (Z_TYPE_P(option) != IS_LONG) {
378+
if (ZEND_CALL_USES_STRICT_TYPES(EG(current_execute_data))) {
379+
zend_type_error("Option \"comp_flags\" must be of type int, %s given",
380+
zend_zval_type_name(option));
381+
return false;
382+
}
368383
php_error_docref(NULL, E_WARNING, "Option \"comp_flags\" must be of type int, %s given",
369384
zend_zval_type_name(option));
370385
}
@@ -375,6 +390,11 @@ static bool php_zip_parse_options(HashTable *options, zip_options *opts)
375390
#ifdef HAVE_ENCRYPTION
376391
if ((option = zend_hash_str_find(options, "enc_method", sizeof("enc_method") - 1)) != NULL) {
377392
if (Z_TYPE_P(option) != IS_LONG) {
393+
if (ZEND_CALL_USES_STRICT_TYPES(EG(current_execute_data))) {
394+
zend_type_error("Option \"enc_method\" must be of type int, %s given",
395+
zend_zval_type_name(option));
396+
return false;
397+
}
378398
php_error_docref(NULL, E_WARNING, "Option \"enc_method\" must be of type int, %s given",
379399
zend_zval_type_name(option));
380400
}

0 commit comments

Comments
 (0)