diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index f522d52ba6c4..6fb4f264a2a9 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -37,8 +37,7 @@ static zend_class_entry *phar_ce_entry; #define PHAR_ARCHIVE_OBJECT() \ phar_archive_object *phar_obj = PHAR_FETCH_INTERNAL(); \ if (!phar_obj->archive) { \ - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, \ - "Cannot call method on an uninitialized Phar object"); \ + zend_throw_error(NULL, "Phar object is uninitialized"); \ RETURN_THROWS(); \ } @@ -719,8 +718,8 @@ PHP_METHOD(Phar, webPhar) phar_do_403(); goto cleanup_skip_entry; default: + zend_type_error("Rewrite callback return value must be of type string|false, %s returned", zend_zval_value_name(&retval)); zval_ptr_dtor(&retval); - zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: rewrite callback must return a string or false"); goto cleanup_skip_entry; } } @@ -810,7 +809,7 @@ PHP_METHOD(Phar, webPhar) mime_type = ""; code = Z_LVAL_P(val); } else { - zend_throw_exception_ex(phar_ce_PharException, 0, "Unknown mime type specifier used, only Phar::PHP, Phar::PHPS and a mime type string are allowed"); + zend_argument_value_error(4, "mime type specifier must be one of Phar::PHP or Phar::PHPS"); goto cleanup; } break; @@ -819,7 +818,7 @@ PHP_METHOD(Phar, webPhar) code = PHAR_MIME_OTHER; break; default: - zend_throw_exception_ex(phar_ce_PharException, 0, "Unknown mime type specifier used (not a string or int), only Phar::PHP, Phar::PHPS and a mime type string are allowed"); + zend_argument_type_error(4, "mime type specifier must be of type string|int, %s given", zend_zval_value_name(val)); goto cleanup; } } @@ -867,12 +866,12 @@ PHP_METHOD(Phar, mungServer) } if (!zend_hash_num_elements(Z_ARRVAL_P(mungvalues))) { - zend_throw_exception_ex(phar_ce_PharException, 0, "No values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME"); + zend_argument_must_not_be_empty_error(1); RETURN_THROWS(); } if (zend_hash_num_elements(Z_ARRVAL_P(mungvalues)) > 4) { - zend_throw_exception_ex(phar_ce_PharException, 0, "Too many values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME"); + zend_argument_value_error(1, "must have at most 4 elements"); RETURN_THROWS(); } @@ -881,7 +880,7 @@ PHP_METHOD(Phar, mungServer) ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(mungvalues), data) { ZVAL_DEREF(data); if (Z_TYPE_P(data) != IS_STRING) { - zend_throw_exception_ex(phar_ce_PharException, 0, "Non-string value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME"); + zend_argument_type_error(1, "must be an array of string types, %s given", zend_zval_value_name(data)); RETURN_THROWS(); } @@ -894,7 +893,7 @@ PHP_METHOD(Phar, mungServer) } else if (zend_string_equals_literal(Z_STR_P(data), "SCRIPT_FILENAME")) { PHAR_G(phar_SERVER_mung_list) |= PHAR_MUNG_SCRIPT_FILENAME; } else { - zend_throw_exception_ex(phar_ce_PharException, 0, "Invalid value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME"); + zend_argument_value_error(1, "must only contain elements with the following values \"PHP_SELF\", \"REQUEST_URI\", \"SCRIPT_FILENAME\", or \"SCRIPT_NAME\""); RETURN_THROWS(); } } ZEND_HASH_FOREACH_END(); @@ -1103,7 +1102,7 @@ PHP_METHOD(Phar, __construct) } if (phar_obj->archive) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot call constructor twice"); + zend_throw_error(NULL, "Cannot call constructor twice"); RETURN_THROWS(); } @@ -1270,7 +1269,7 @@ PHP_METHOD(Phar, unlinkArchive) } if (!fname_len) { - zend_throw_exception_ex(phar_ce_PharException, 0, "Unknown phar archive \"\""); + zend_argument_must_not_be_empty_error(1); RETURN_THROWS(); } @@ -1408,7 +1407,8 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ if (!value) { /* failure in get_current_data */ - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %s returned no value", ZSTR_VAL(ce->name)); + /* This should never happen without an exception */ + zend_throw_error(NULL, "Iterator %s returned no value", ZSTR_VAL(ce->name)); return ZEND_HASH_APPLY_STOP; } @@ -1419,7 +1419,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ php_stream_from_zval_no_verify(fp, value); if (!fp) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Iterator %s returned an invalid stream handle", ZSTR_VAL(ce->name)); + zend_type_error("Iterator %s return value must be a valid stream handle", ZSTR_VAL(ce->name)); return ZEND_HASH_APPLY_STOP; } @@ -1433,7 +1433,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ if (Z_TYPE(key) != IS_STRING) { zval_ptr_dtor(&key); - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %s returned an invalid key (must return a string)", ZSTR_VAL(ce->name)); + zend_type_error("Iterator %s must return a key of type string, %s returned", ZSTR_VAL(ce->name), zend_zval_value_name(&key)); return ZEND_HASH_APPLY_STOP; } @@ -1443,7 +1443,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ save = str_key; zval_ptr_dtor_str(&key); } else { - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %s returned an invalid key (must return a string)", ZSTR_VAL(ce->name)); + zend_type_error("Iterator %s must return a key of type string, none returned", ZSTR_VAL(ce->name)); return ZEND_HASH_APPLY_STOP; } @@ -1468,7 +1468,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ phar_call_method_with_unwrap(Z_OBJ_P(value), "getPathname", &rv); if (UNEXPECTED(Z_TYPE(rv) != IS_STRING)) { - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "getPathname() must return a string"); + zend_type_error("%s::getPathname(): Return value must be of type string, %s returned", ZSTR_VAL(Z_OBJCE_P(value)->name), zend_zval_value_name(&rv)); return ZEND_HASH_APPLY_STOP; } tmp_dir_str = Z_STR(rv); @@ -1515,7 +1515,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ } ZEND_FALLTHROUGH; default: - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %s returned an invalid value (must return a string, a stream, or an SplFileInfo object)", ZSTR_VAL(ce->name)); + zend_type_error("Iterator %s return value must be of type string|object|resource, %s returned", ZSTR_VAL(ce->name), zend_zval_value_name(value)); return ZEND_HASH_APPLY_STOP; } @@ -1574,8 +1574,8 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ } if (Z_TYPE(key) != IS_STRING) { + zend_type_error("Iterator %s must return a key of type string, %s returned", ZSTR_VAL(ce->name), zend_zval_value_name(&key)); zval_ptr_dtor(&key); - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %s returned an invalid key (must return a string)", ZSTR_VAL(ce->name)); return ZEND_HASH_APPLY_STOP; } @@ -1585,7 +1585,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ save = str_key; zval_ptr_dtor_str(&key); } else { - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %s returned an invalid key (must return a string)", ZSTR_VAL(ce->name)); + zend_type_error("Iterator %s must return a key of type string, none returned", ZSTR_VAL(ce->name)); return ZEND_HASH_APPLY_STOP; } } @@ -1911,7 +1911,7 @@ PHP_METHOD(Phar, isFileFormat) case PHAR_FORMAT_PHAR: RETURN_BOOL(!phar_obj->archive->is_tar && !phar_obj->archive->is_zip); default: - zend_throw_exception_ex(phar_ce_PharException, 0, "Unknown file format specified"); + zend_argument_value_error(1, "must be one of Phar::PHAR, Phar::TAR, or Phar::ZIP"); } } /* }}} */ @@ -2374,8 +2374,7 @@ PHP_METHOD(Phar, convertToExecutable) case PHAR_FORMAT_ZIP: break; default: - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, - "Unknown file format specified, please pass one of Phar::PHAR, Phar::TAR or Phar::ZIP"); + zend_argument_value_error(1, "must be one of Phar::PHAR, Phar::TAR, or Phar::ZIP"); RETURN_THROWS(); } @@ -2386,13 +2385,12 @@ PHP_METHOD(Phar, convertToExecutable) case 9021976: /* Retained for BC */ flags = phar_obj->archive->flags & PHAR_FILE_COMPRESSION_MASK; break; - case 0: + case PHAR_ENT_COMPRESSED_NONE: flags = PHAR_FILE_COMPRESSED_NONE; break; case PHAR_ENT_COMPRESSED_GZ: if (format == PHAR_FORMAT_ZIP) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, - "Cannot compress entire archive with gzip, zip archives do not support whole-archive compression"); + zend_argument_value_error(2, "must not be Phar::GZ when argument #1 is Phar::ZIP, as ZIP archives do not support whole-archive compression"); RETURN_THROWS(); } @@ -2406,8 +2404,7 @@ PHP_METHOD(Phar, convertToExecutable) break; case PHAR_ENT_COMPRESSED_BZ2: if (format == PHAR_FORMAT_ZIP) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, - "Cannot compress entire archive with bz2, zip archives do not support whole-archive compression"); + zend_argument_value_error(2, "must not be Phar::BZ2 when argument #1 is Phar::ZIP, as ZIP archives do not support whole-archive compression"); RETURN_THROWS(); } @@ -2420,8 +2417,7 @@ PHP_METHOD(Phar, convertToExecutable) flags = PHAR_FILE_COMPRESSED_BZ2; break; default: - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, - "Unknown compression specified, please pass one of Phar::GZ or Phar::BZ2"); + zend_argument_value_error(2, "must be one of Phar::NONE, Phar::GZ, or Phar::BZ2"); RETURN_THROWS(); } } @@ -2483,8 +2479,7 @@ PHP_METHOD(Phar, convertToData) case PHAR_FORMAT_ZIP: break; default: - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, - "Unknown file format specified, please pass one of Phar::TAR or Phar::ZIP"); + zend_argument_value_error(1, "must be one of Phar::TAR or Phar::ZIP"); RETURN_THROWS(); } @@ -2495,13 +2490,12 @@ PHP_METHOD(Phar, convertToData) case 9021976: /* Retained for BC */ flags = phar_obj->archive->flags & PHAR_FILE_COMPRESSION_MASK; break; - case 0: + case PHAR_ENT_COMPRESSED_NONE: flags = PHAR_FILE_COMPRESSED_NONE; break; case PHAR_ENT_COMPRESSED_GZ: if (format == PHAR_FORMAT_ZIP) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, - "Cannot compress entire archive with gzip, zip archives do not support whole-archive compression"); + zend_argument_value_error(2, "must not be Phar::GZ when argument #1 is Phar::ZIP, as ZIP archives do not support whole-archive compression"); RETURN_THROWS(); } @@ -2515,8 +2509,7 @@ PHP_METHOD(Phar, convertToData) break; case PHAR_ENT_COMPRESSED_BZ2: if (format == PHAR_FORMAT_ZIP) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, - "Cannot compress entire archive with bz2, zip archives do not support whole-archive compression"); + zend_argument_value_error(2, "must not be Phar::BZ2 when argument #1 is Phar::ZIP, as ZIP archives do not support whole-archive compression"); RETURN_THROWS(); } @@ -2529,8 +2522,7 @@ PHP_METHOD(Phar, convertToData) flags = PHAR_FILE_COMPRESSED_BZ2; break; default: - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, - "Unknown compression specified, please pass one of Phar::GZ or Phar::BZ2"); + zend_argument_value_error(2, "must be one of Phar::NONE, Phar::GZ, or Phar::BZ2"); RETURN_THROWS(); } } @@ -2944,7 +2936,7 @@ PHP_METHOD(Phar, setDefaultStub) } if ((index || webindex) && (phar_obj->archive->is_tar || phar_obj->archive->is_zip)) { - zend_argument_value_error(index ? 1 : 2, "must be null for a tar- or zip-based phar stub, string given"); + zend_argument_type_error(index ? 1 : 2, "must be null for a tar- or zip-based phar stub, string given"); RETURN_THROWS(); } @@ -3037,8 +3029,7 @@ PHP_METHOD(Phar, setSignatureAlgorithm) } break; default: - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, - "Unknown signature algorithm specified"); + zend_argument_value_error(1, "must be one of Phar::SHA256, Phar::SHA512, Phar::SHA1, Phar::MD5, Phar::OPENSSL, Phar::OPENSSL_SHA256, or Phar::OPENSSL_SHA512"); } } /* }}} */ @@ -3189,7 +3180,7 @@ PHP_METHOD(Phar, compress) } switch (method) { - case 0: + case PHAR_ENT_COMPRESSED_NONE: flags = PHAR_FILE_COMPRESSED_NONE; break; case PHAR_ENT_COMPRESSED_GZ: @@ -3210,8 +3201,7 @@ PHP_METHOD(Phar, compress) flags = PHAR_FILE_COMPRESSED_BZ2; break; default: - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, - "Unknown compression specified, please pass one of Phar::GZ or Phar::BZ2"); + zend_argument_value_error(1, "must be one of Phar::NONE, Phar::GZ, or Phar::BZ2"); RETURN_THROWS(); } @@ -3309,8 +3299,7 @@ PHP_METHOD(Phar, compressFiles) flags = PHAR_ENT_COMPRESSED_BZ2; break; default: - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, - "Unknown compression specified, please pass one of Phar::GZ or Phar::BZ2"); + zend_argument_value_error(2, "must be one of Phar::GZ or Phar::BZ2"); RETURN_THROWS(); } @@ -3531,17 +3520,17 @@ PHP_METHOD(Phar, offsetGet) zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Entry %s does not exist%s%s", ZSTR_VAL(file_name), error?", ":"", error?error:""); } else { if (zend_string_equals_literal(file_name, ".phar/stub.php")) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot get stub \".phar/stub.php\" directly in phar \"%s\", use getStub", phar_obj->archive->fname); + zend_argument_value_error(1, "must not be \".phar/stub.php\", use Phar::getStub() instead"); RETURN_THROWS(); } if (zend_string_equals_literal(file_name, ".phar/alias.txt")) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot get alias \".phar/alias.txt\" directly in phar \"%s\", use getAlias", phar_obj->archive->fname); + zend_argument_value_error(1, "must not be \".phar/alias.txt\", use Phar::getAlias() instead"); RETURN_THROWS(); } if (zend_string_starts_with_literal(file_name, ".phar")) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot directly get any files or directories in magic \".phar\" directory"); + zend_argument_value_error(1, "must not start with \".phar\""); RETURN_THROWS(); } @@ -3583,6 +3572,7 @@ static void phar_add_file(phar_archive_data **pphar, zend_string *file_name, con size_t prefix_len = (ZSTR_VAL(file_name)[0] == '/') + sizeof(".phar")-1; char next_char = ZSTR_VAL(file_name)[prefix_len]; if (next_char == '/' || next_char == '\\' || next_char == '\0') { + /* TODO: handle this on call sites? */ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot create any files in magic \".phar\" directory"); return; } @@ -3721,17 +3711,17 @@ PHP_METHOD(Phar, offsetSet) } if (zend_string_equals_literal(file_name, ".phar/stub.php")) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot set stub \".phar/stub.php\" directly in phar \"%s\", use setStub", phar_obj->archive->fname); + zend_argument_value_error(1, "must not be \".phar/stub.php\", use Phar::setStub() instead"); RETURN_THROWS(); } if (zend_string_equals_literal(file_name, ".phar/alias.txt")) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot set alias \".phar/alias.txt\" directly in phar \"%s\", use setAlias", phar_obj->archive->fname); + zend_argument_value_error(1, "must not be \".phar/alias.txt\", use Phar::setAlias() instead"); RETURN_THROWS(); } if (zend_string_starts_with_literal(file_name, ".phar")) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot set any files or directories in magic \".phar\" directory"); + zend_argument_value_error(1, "must not start with \".phar\""); RETURN_THROWS(); } @@ -3798,7 +3788,7 @@ PHP_METHOD(Phar, addEmptyDir) PHAR_ARCHIVE_OBJECT(); if (zend_string_starts_with_literal(dir_name, ".phar")) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot create a directory in magic \".phar\" directory"); + zend_argument_value_error(1, "must not start with \".phar\""); RETURN_THROWS(); } @@ -4311,26 +4301,32 @@ PHP_METHOD(Phar, extractTo) PHAR_ARCHIVE_OBJECT(); - fp = php_stream_open_wrapper(phar_obj->archive->fname, "rb", IGNORE_URL|STREAM_MUST_SEEK, NULL); + if (UNEXPECTED(ZSTR_LEN(path_to) == 0)) { + zend_argument_must_not_be_empty_error(1); + RETURN_THROWS(); + } - if (!fp) { - zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, - "Invalid argument, %s cannot be found", phar_obj->archive->fname); + if (UNEXPECTED(ZSTR_LEN(path_to) >= MAXPATHLEN)) { + zend_argument_value_error(1, "must be less than %d bytes", MAXPATHLEN); RETURN_THROWS(); } - php_stream_close(fp); + if (files_ht && UNEXPECTED(zend_hash_num_elements(files_ht) == 0)) { + zend_argument_must_not_be_empty_error(2); + } else if (filename && UNEXPECTED(ZSTR_LEN(filename) == 0)) { + zend_argument_must_not_be_empty_error(2); + } + + fp = php_stream_open_wrapper(phar_obj->archive->fname, "rb", IGNORE_URL|STREAM_MUST_SEEK, NULL); - if (ZSTR_LEN(path_to) == 0) { + if (!fp) { + /* TODO: This error message is nonsensical */ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, - "Invalid argument, extraction path must be non-zero length"); + "Invalid argument, %s cannot be found", phar_obj->archive->fname); RETURN_THROWS(); } - if (ZSTR_LEN(path_to) >= MAXPATHLEN) { - zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "Cannot extract to \"%.50s...\", destination directory is too long for filesystem", ZSTR_VAL(path_to)); - RETURN_THROWS(); - } + php_stream_close(fp); if (php_stream_stat_path(ZSTR_VAL(path_to), &ssb) < 0) { ret = php_stream_mkdir(ZSTR_VAL(path_to), 0777, PHP_STREAM_MKDIR_RECURSIVE, NULL); @@ -4346,15 +4342,10 @@ PHP_METHOD(Phar, extractTo) } if (files_ht) { - if (zend_hash_num_elements(files_ht) == 0) { - RETURN_FALSE; - } - ZEND_HASH_FOREACH_VAL(files_ht, zval_file) { ZVAL_DEREF(zval_file); if (IS_STRING != Z_TYPE_P(zval_file)) { - zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, - "Invalid argument, array of filenames to extract contains non-string value"); + zend_argument_type_error(2, "must be an array of string elements, %s given", zend_zval_value_name(zval_file)); RETURN_THROWS(); } switch (extract_helper(phar_obj->archive, Z_STR_P(zval_file), path_to, overwrite, &error)) { @@ -4407,11 +4398,12 @@ PHP_METHOD(PharFileInfo, __construct) entry_obj = PHAR_FETCH_INTERNAL(); if (entry_obj->entry) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot call constructor twice"); + zend_throw_error(NULL, "Cannot call constructor twice"); RETURN_THROWS(); } if (fname_len < 7 || memcmp(fname, "phar://", 7) || phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0) == FAILURE) { + /* TODO Transform this into a ValueError after wording has been figured out */ zend_throw_exception_ex(spl_ce_RuntimeException, 0, "'%s' is not a valid phar archive URL (must have at least phar://filename.phar)", fname); RETURN_THROWS(); @@ -4463,8 +4455,7 @@ PHP_METHOD(PharFileInfo, __construct) phar_entry_object *entry_obj = PHAR_FETCH_INTERNAL(); \ if (!entry_obj->entry) { \ if (throw) { \ - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, \ - "Cannot call method on an uninitialized PharFileInfo object"); \ + zend_throw_error(NULL, "PharFileInfo object is uninitialized"); \ } \ return; \ } @@ -4533,7 +4524,7 @@ PHP_METHOD(PharFileInfo, isCompressed) case PHAR_ENT_COMPRESSED_BZ2: RETURN_BOOL(entry_obj->entry->flags & PHAR_ENT_COMPRESSED_BZ2); default: - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unknown compression type specified"); + zend_argument_value_error(1, "must be one of Phar::GZ or Phar::BZ2"); RETURN_THROWS(); } } @@ -4934,7 +4925,7 @@ PHP_METHOD(PharFileInfo, compress) entry_obj->entry->flags |= PHAR_ENT_COMPRESSED_BZ2; break; default: - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unknown compression type specified"); + zend_argument_value_error(1, "must be one of Phar::GZ or Phar::BZ2"); RETURN_THROWS(); } @@ -5014,6 +5005,7 @@ PHP_METHOD(PharFileInfo, decompress) compression_type = "bz2"; break; default: + /* TODO This should be impossible */ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot decompress file compressed with unknown compression type"); RETURN_THROWS(); diff --git a/ext/phar/phar_object.stub.php b/ext/phar/phar_object.stub.php index ae5bd69c32f4..717a5456b010 100644 --- a/ext/phar/phar_object.stub.php +++ b/ext/phar/phar_object.stub.php @@ -123,7 +123,7 @@ public function delete(string $localName): true {} public function delMetadata(): true {} /** @tentative-return-type */ - public function extractTo(string $directory, array|string|null $files = null, bool $overwrite = false): bool {} + public function extractTo(string $directory, array|string|null $files = null, bool $overwrite = false): true {} /** @tentative-return-type */ public function getAlias(): ?string {} @@ -345,7 +345,7 @@ public function delMetadata(): true {} * @tentative-return-type * @implementation-alias Phar::extractTo */ - public function extractTo(string $directory, array|string|null $files = null, bool $overwrite = false): bool {} + public function extractTo(string $directory, array|string|null $files = null, bool $overwrite = false): true {} /** * @tentative-return-type diff --git a/ext/phar/phar_object_arginfo.h b/ext/phar/phar_object_arginfo.h index bca9f0112eaa..1824d5ad40fd 100644 --- a/ext/phar/phar_object_arginfo.h +++ b/ext/phar/phar_object_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit phar_object.stub.php instead. - * Stub hash: 031dc8f07d2d9bac4a5f82f4ac2c5b3da5995405 */ + * Stub hash: 2e8cb4e6309c2edf7b0d931c3bc2612e68e256e1 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar___construct, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) @@ -77,7 +77,7 @@ ZEND_END_ARG_INFO() #define arginfo_class_Phar_delMetadata arginfo_class_Phar_decompressFiles -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Phar_extractTo, 0, 1, _IS_BOOL, 0) +ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Phar_extractTo, 0, 1, IS_TRUE, 0) ZEND_ARG_TYPE_INFO(0, directory, IS_STRING, 0) ZEND_ARG_TYPE_MASK(0, files, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, overwrite, _IS_BOOL, 0, "false") diff --git a/ext/phar/tests/030.phpt b/ext/phar/tests/030.phpt index e558261df89c..735b69808ea6 100644 --- a/ext/phar/tests/030.phpt +++ b/ext/phar/tests/030.phpt @@ -27,9 +27,9 @@ require $pname . '/a.php'; $p = new Phar($fname); var_dump(isset($p['.phar/test'])); try { -$p['.phar/test']; -} catch (Exception $e) { -echo $e->getMessage(),"\n"; + $p['.phar/test']; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } ?> --CLEAN-- @@ -43,4 +43,4 @@ This is b/c This is b/d This is e bool(false) -Cannot directly get any files or directories in magic ".phar" directory +ValueError: Phar::offsetGet(): Argument #1 ($localName) must not start with ".phar" diff --git a/ext/phar/tests/bug54289.phpt b/ext/phar/tests/bug54289.phpt index dd1d00ada06b..65414428033d 100644 --- a/ext/phar/tests/bug54289.phpt +++ b/ext/phar/tests/bug54289.phpt @@ -26,14 +26,16 @@ var_dump(is_dir($outDir.DIRECTORY_SEPARATOR.'dirAB')); try { $pharB->extractTo($outDir, 'dirX/', true); echo 'failed to throw expected exception'; -} catch (PharException $ex) { +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } // should also not be able to pull out /, because paths are not "rooted" that way try { $pharB->extractTo($outDir, '/', true); echo 'failed to throw expected exception'; -} catch (PharException $ex) { +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } // should be able to do by array, too @@ -45,7 +47,8 @@ try { $pharB = new Phar($phar); $pharB->extractTo($outDir, [ 'dirA/', 'dirX/' ], true); echo 'failed to throw expected exception'; -} catch (PharException $ex) { +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } echo 'done'; @@ -63,8 +66,11 @@ foreach ($iter as $value) { $value->isFile() ? unlink($value) : rmdir($value); } ?> ---EXPECT-- +--EXPECTF-- bool(true) bool(true) bool(false) +PharException: phar error: attempted to extract non-existent file or directory "dirX/" from phar "%sbug54289/test.phar" +PharException: phar error: attempted to extract non-existent file or directory "/" from phar "%sbug54289/test.phar" +PharException: phar error: attempted to extract non-existent file or directory "dirX/" from phar "%sbug54289/test.phar" done diff --git a/ext/phar/tests/buildFromIterator_user_overrides/getPathname_exception.phpt b/ext/phar/tests/buildFromIterator_user_overrides/getPathname_exception.phpt index 86b66050a973..fedb99e19fbc 100644 --- a/ext/phar/tests/buildFromIterator_user_overrides/getPathname_exception.phpt +++ b/ext/phar/tests/buildFromIterator_user_overrides/getPathname_exception.phpt @@ -59,5 +59,5 @@ $workdir = __DIR__.'/getPathname_exception'; [ Found: %shello.txt ] [getPathname] string(%d) "%shello.txt" -getPathname() must return a string +MyGlobIterator::getPathname(): Return value must be of type string, null returned Previous: exception in getPathname() diff --git a/ext/phar/tests/buildFromIterator_user_overrides/getPathname_wrong_type.phpt b/ext/phar/tests/buildFromIterator_user_overrides/getPathname_wrong_type.phpt index dfb3fb5f2c55..379894b6ccb1 100644 --- a/ext/phar/tests/buildFromIterator_user_overrides/getPathname_wrong_type.phpt +++ b/ext/phar/tests/buildFromIterator_user_overrides/getPathname_wrong_type.phpt @@ -55,4 +55,4 @@ $workdir = __DIR__.'/getPathname_wrong_type'; --EXPECTF-- [ Found: %scontent%chello.txt ] [getPathname] -getPathname() must return a string +MyGlobIterator::getPathname(): Return value must be of type string, int returned diff --git a/ext/phar/tests/cache_list/files/frontcontroller10.phar b/ext/phar/tests/cache_list/files/frontcontroller10.phar index 078ce75b2c7b..93dcc1c0d771 100644 Binary files a/ext/phar/tests/cache_list/files/frontcontroller10.phar and b/ext/phar/tests/cache_list/files/frontcontroller10.phar differ diff --git a/ext/phar/tests/cache_list/files/frontcontroller10.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller10.phar.inc index 4c139db58bd6..02097c5c3e59 100644 --- a/ext/phar/tests/cache_list/files/frontcontroller10.phar.inc +++ b/ext/phar/tests/cache_list/files/frontcontroller10.phar.inc @@ -12,8 +12,12 @@ var_dump($_SERVER["PHAR_SCRIPT_FILENAME"]); var_dump($_SERVER["PHAR_REQUEST_URI"]); '; $a->setStub('getMessage() . "\n"); +} echo "oops did not run\n"; var_dump($_ENV, $_SERVER); __HALT_COMPILER();'); diff --git a/ext/phar/tests/cache_list/files/frontcontroller11.phar b/ext/phar/tests/cache_list/files/frontcontroller11.phar index 61ea84322214..ff76743349e9 100644 Binary files a/ext/phar/tests/cache_list/files/frontcontroller11.phar and b/ext/phar/tests/cache_list/files/frontcontroller11.phar differ diff --git a/ext/phar/tests/cache_list/files/frontcontroller11.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller11.phar.inc index 086350800b97..6eaef06e3920 100644 --- a/ext/phar/tests/cache_list/files/frontcontroller11.phar.inc +++ b/ext/phar/tests/cache_list/files/frontcontroller11.phar.inc @@ -12,8 +12,12 @@ var_dump($_SERVER["PHAR_SCRIPT_FILENAME"]); var_dump($_SERVER["PHAR_REQUEST_URI"]); '; $a->setStub('getMessage() . "\n"); +} echo "oops did not run\n"; var_dump($_ENV, $_SERVER); __HALT_COMPILER();'); diff --git a/ext/phar/tests/cache_list/files/frontcontroller12.phar b/ext/phar/tests/cache_list/files/frontcontroller12.phar index beebf034cbc8..0b4e90a58779 100644 Binary files a/ext/phar/tests/cache_list/files/frontcontroller12.phar and b/ext/phar/tests/cache_list/files/frontcontroller12.phar differ diff --git a/ext/phar/tests/cache_list/files/frontcontroller12.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller12.phar.inc index ba17df37e17f..728c007d2c46 100644 --- a/ext/phar/tests/cache_list/files/frontcontroller12.phar.inc +++ b/ext/phar/tests/cache_list/files/frontcontroller12.phar.inc @@ -12,8 +12,12 @@ var_dump($_SERVER["PHAR_SCRIPT_FILENAME"]); var_dump($_SERVER["PHAR_REQUEST_URI"]); '; $a->setStub('getMessage() . "\n"); +} echo "oops did not run\n"; var_dump($_ENV, $_SERVER); __HALT_COMPILER();'); diff --git a/ext/phar/tests/cache_list/files/frontcontroller14.phar b/ext/phar/tests/cache_list/files/frontcontroller14.phar index 31b4cb92d641..6c6df2ae3eed 100644 Binary files a/ext/phar/tests/cache_list/files/frontcontroller14.phar and b/ext/phar/tests/cache_list/files/frontcontroller14.phar differ diff --git a/ext/phar/tests/cache_list/files/frontcontroller14.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller14.phar.inc index d0ebd9a45a76..ed026867ba03 100644 --- a/ext/phar/tests/cache_list/files/frontcontroller14.phar.inc +++ b/ext/phar/tests/cache_list/files/frontcontroller14.phar.inc @@ -10,9 +10,13 @@ function s($a) { return "/html/index.php"; } -Phar::interceptFileFuncs(); -Phar::mungServer(array("PHP_SELF", "REQUEST_URI")); -Phar::webPhar("whatever", "/html/index.php", null, array(), "s"); +try { + Phar::interceptFileFuncs(); + Phar::mungServer(array("PHP_SELF", "REQUEST_URI")); + Phar::webPhar("whatever", "/html/index.php", null, array(), "s"); +} catch (Throwable $e) { + die($e::class . ": " . $e->getMessage() . "\n"); +} echo "oops did not run\n"; var_dump($_ENV, $_SERVER); __HALT_COMPILER();'); diff --git a/ext/phar/tests/cache_list/files/frontcontroller16.phar b/ext/phar/tests/cache_list/files/frontcontroller16.phar index cce5db5bb5bc..ae0bf7667d7d 100644 Binary files a/ext/phar/tests/cache_list/files/frontcontroller16.phar and b/ext/phar/tests/cache_list/files/frontcontroller16.phar differ diff --git a/ext/phar/tests/cache_list/files/frontcontroller16.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller16.phar.inc index 442f1fb18f67..db0ee111b4ca 100644 --- a/ext/phar/tests/cache_list/files/frontcontroller16.phar.inc +++ b/ext/phar/tests/cache_list/files/frontcontroller16.phar.inc @@ -6,9 +6,9 @@ echo "hi"; '; $a->setStub('getMessage() . "\n"); + Phar::webPhar("test.phar", "/index.php", null, array(), array("fail", "here")); +} catch (Throwable $e) { + die($e::class . ": " . $e->getMessage() . "\n"); } echo "oops did not run\n"; var_dump($_ENV, $_SERVER); diff --git a/ext/phar/tests/cache_list/files/frontcontroller17.phar b/ext/phar/tests/cache_list/files/frontcontroller17.phar index d9b8330e63fb..79530005a6f5 100644 Binary files a/ext/phar/tests/cache_list/files/frontcontroller17.phar and b/ext/phar/tests/cache_list/files/frontcontroller17.phar differ diff --git a/ext/phar/tests/cache_list/files/frontcontroller17.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller17.phar.inc index 715479552a2b..54c19af1296a 100644 --- a/ext/phar/tests/cache_list/files/frontcontroller17.phar.inc +++ b/ext/phar/tests/cache_list/files/frontcontroller17.phar.inc @@ -6,9 +6,9 @@ echo "hi"; '; $a->setStub('getMessage() . "\n"); + Phar::webPhar("test.phar", "/index.php", null, array(), function() { throw new Exception; }); +} catch (Throwable $e) { + die($e::class . ": " . $e->getMessage() . "\n"); } echo "oops did not run\n"; var_dump($_ENV, $_SERVER); diff --git a/ext/phar/tests/cache_list/files/frontcontroller18.phar b/ext/phar/tests/cache_list/files/frontcontroller18.phar index c447f397ac54..09ffc73d9673 100644 Binary files a/ext/phar/tests/cache_list/files/frontcontroller18.phar and b/ext/phar/tests/cache_list/files/frontcontroller18.phar differ diff --git a/ext/phar/tests/cache_list/files/frontcontroller18.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller18.phar.inc index 847a713ba38b..4c816518ac7a 100644 --- a/ext/phar/tests/cache_list/files/frontcontroller18.phar.inc +++ b/ext/phar/tests/cache_list/files/frontcontroller18.phar.inc @@ -9,9 +9,9 @@ function s($a) { } try { -Phar::webPhar("test.phar", "/index.php", null, array(), "s"); -} catch (Exception $e) { -die($e->getMessage() . "\n"); + Phar::webPhar("test.phar", "/index.php", null, array(), "s"); +} catch (Throwable $e) { + die($e::class . ": " . $e->getMessage() . "\n"); } echo "oops did not run\n"; var_dump($_ENV, $_SERVER); diff --git a/ext/phar/tests/cache_list/files/frontcontroller19.phar b/ext/phar/tests/cache_list/files/frontcontroller19.phar index bdf8ee13c20c..e4c8df2d4643 100644 Binary files a/ext/phar/tests/cache_list/files/frontcontroller19.phar and b/ext/phar/tests/cache_list/files/frontcontroller19.phar differ diff --git a/ext/phar/tests/cache_list/files/frontcontroller19.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller19.phar.inc index ba84ac410a31..e573869e098b 100644 --- a/ext/phar/tests/cache_list/files/frontcontroller19.phar.inc +++ b/ext/phar/tests/cache_list/files/frontcontroller19.phar.inc @@ -15,9 +15,9 @@ echo "another.php\n"; $a->setStub('getMessage() . "\n"); + Phar::webPhar("test.phar", "/start/index.php"); +} catch (Throwable $e) { + die($e::class . ": " . $e->getMessage() . "\n"); } echo "oops did not run\n"; var_dump($_ENV, $_SERVER); diff --git a/ext/phar/tests/cache_list/files/frontcontroller3.phar b/ext/phar/tests/cache_list/files/frontcontroller3.phar index 04a7ae7b9550..60cf28160037 100644 Binary files a/ext/phar/tests/cache_list/files/frontcontroller3.phar and b/ext/phar/tests/cache_list/files/frontcontroller3.phar differ diff --git a/ext/phar/tests/cache_list/files/frontcontroller3.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller3.phar.inc index 2759d9ee45a7..cca0a8f3202e 100644 --- a/ext/phar/tests/cache_list/files/frontcontroller3.phar.inc +++ b/ext/phar/tests/cache_list/files/frontcontroller3.phar.inc @@ -11,7 +11,11 @@ function s($a) if (isset($b[$a])) return $b[$a]; return $a; } -Phar::webPhar("whatever", "/index.php", null, array(), "s"); +try { + Phar::webPhar("whatever", "/index.php", null, array(), "s"); +} catch (Throwable $e) { + die($e::class . ": " . $e->getMessage() . "\n"); +} echo "oops did not run\n"; var_dump($_ENV, $_SERVER); __HALT_COMPILER();'); diff --git a/ext/phar/tests/cache_list/files/frontcontroller4.phar b/ext/phar/tests/cache_list/files/frontcontroller4.phar index 439f74479dfc..d11870401781 100644 Binary files a/ext/phar/tests/cache_list/files/frontcontroller4.phar and b/ext/phar/tests/cache_list/files/frontcontroller4.phar differ diff --git a/ext/phar/tests/cache_list/files/frontcontroller4.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller4.phar.inc index 5c6a43f9546c..86c7f83ce65f 100644 --- a/ext/phar/tests/cache_list/files/frontcontroller4.phar.inc +++ b/ext/phar/tests/cache_list/files/frontcontroller4.phar.inc @@ -11,7 +11,11 @@ function s($a) if (isset($b[$a])) return $b[$a]; return $a; } -Phar::webPhar("whatever", "index.php", null, array(), "s"); +try { + Phar::webPhar("whatever", "index.php", null, array(), "s"); +} catch (Throwable $e) { + die($e::class . ": " . $e->getMessage() . "\n"); +} echo "oops did not run\n"; var_dump($_ENV, $_SERVER); __HALT_COMPILER();'); diff --git a/ext/phar/tests/cache_list/files/frontcontroller5.phar b/ext/phar/tests/cache_list/files/frontcontroller5.phar index f206b5996d7b..048e930fa514 100644 Binary files a/ext/phar/tests/cache_list/files/frontcontroller5.phar and b/ext/phar/tests/cache_list/files/frontcontroller5.phar differ diff --git a/ext/phar/tests/cache_list/files/frontcontroller5.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller5.phar.inc index d2d810c36762..43b0caf0f986 100644 --- a/ext/phar/tests/cache_list/files/frontcontroller5.phar.inc +++ b/ext/phar/tests/cache_list/files/frontcontroller5.phar.inc @@ -5,7 +5,11 @@ $a['a.php'] = 'hio'; $a['a.jpg'] = 'hio'; $a['a.phps'] = 'setStub(' "oops")); +try { + Phar::webPhar("whatever", "index.php", null, array(0 => "oops")); +} catch (Throwable $e) { + die($e::class . ": " . $e->getMessage() . "\n"); +} echo "oops did not run\n"; var_dump($_ENV, $_SERVER); __HALT_COMPILER();'); diff --git a/ext/phar/tests/cache_list/files/frontcontroller6.phar b/ext/phar/tests/cache_list/files/frontcontroller6.phar index f4a8265b1609..214e09d51080 100644 Binary files a/ext/phar/tests/cache_list/files/frontcontroller6.phar and b/ext/phar/tests/cache_list/files/frontcontroller6.phar differ diff --git a/ext/phar/tests/cache_list/files/frontcontroller6.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller6.phar.inc index 5c900eb603c3..d9131d10c61f 100644 --- a/ext/phar/tests/cache_list/files/frontcontroller6.phar.inc +++ b/ext/phar/tests/cache_list/files/frontcontroller6.phar.inc @@ -5,8 +5,12 @@ $a['a.php'] = 'hio'; $a['a.jpg'] = 'hio'; $a['a.phps'] = 'setStub(' 100)); +try { + Phar::webPhar("whatever", "index.php", null, array("php" => 100)); +} catch (Throwable $e) { + die($e::class . ": " . $e->getMessage() . "\n"); +} echo "oops did not run\n"; var_dump($_ENV, $_SERVER); __HALT_COMPILER();'); -?> +?> \ No newline at end of file diff --git a/ext/phar/tests/cache_list/files/frontcontroller7.phar b/ext/phar/tests/cache_list/files/frontcontroller7.phar index 07884b22bc29..ef8bbcb52f9b 100644 Binary files a/ext/phar/tests/cache_list/files/frontcontroller7.phar and b/ext/phar/tests/cache_list/files/frontcontroller7.phar differ diff --git a/ext/phar/tests/cache_list/files/frontcontroller7.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller7.phar.inc index 684970263e59..41ae2213367c 100644 --- a/ext/phar/tests/cache_list/files/frontcontroller7.phar.inc +++ b/ext/phar/tests/cache_list/files/frontcontroller7.phar.inc @@ -5,7 +5,11 @@ $a['a.php'] = 'hio'; $a['a.jpg'] = 'hio'; $a['a.phps'] = 'setStub(' null)); +try { + Phar::webPhar("whatever", "index.php", null, array("php" => null)); +} catch (Throwable $e) { + die($e::class . ": " . $e->getMessage() . "\n"); +} echo "oops did not run\n"; var_dump($_ENV, $_SERVER); __HALT_COMPILER();'); diff --git a/ext/phar/tests/cache_list/files/frontcontroller8.phar b/ext/phar/tests/cache_list/files/frontcontroller8.phar index fe133dfba177..c7e32d5200a1 100644 Binary files a/ext/phar/tests/cache_list/files/frontcontroller8.phar and b/ext/phar/tests/cache_list/files/frontcontroller8.phar differ diff --git a/ext/phar/tests/cache_list/files/frontcontroller8.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller8.phar.inc index 1dfb654a031e..fb76f8f63d2e 100644 --- a/ext/phar/tests/cache_list/files/frontcontroller8.phar.inc +++ b/ext/phar/tests/cache_list/files/frontcontroller8.phar.inc @@ -12,7 +12,11 @@ $a['unknown.ext'] = 'setStub(' "foo/bar", "phps" => Phar::PHP, "php" => Phar::PHPS)); +try { + Phar::webPhar("whatever", "index.php", "404.php", array("jpg" => "foo/bar", "phps" => Phar::PHP, "php" => Phar::PHPS)); +} catch (Throwable $e) { + die($e::class . ": " . $e->getMessage() . "\n"); +} echo "oops did not run\n"; var_dump($_ENV, $_SERVER); __HALT_COMPILER();'); diff --git a/ext/phar/tests/cache_list/files/frontcontroller9.phar b/ext/phar/tests/cache_list/files/frontcontroller9.phar index 39ca28c96cfa..cbea12cef49c 100644 Binary files a/ext/phar/tests/cache_list/files/frontcontroller9.phar and b/ext/phar/tests/cache_list/files/frontcontroller9.phar differ diff --git a/ext/phar/tests/cache_list/files/frontcontroller9.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller9.phar.inc index 00861f64205c..6d48b9fa273d 100644 --- a/ext/phar/tests/cache_list/files/frontcontroller9.phar.inc +++ b/ext/phar/tests/cache_list/files/frontcontroller9.phar.inc @@ -6,8 +6,12 @@ $a['a.jpg'] = 'hio2'; $a['a.php'] = 'setStub(' "foo/bar", "phps" => Phar::PHP, "php" => Phar::PHPS)); +try { + Phar::mungServer(array()); + Phar::webPhar("whatever", "index.php", null, array("jpg" => "foo/bar", "phps" => Phar::PHP, "php" => Phar::PHPS)); +} catch (Throwable $e) { + die($e::class . ": " . $e->getMessage() . "\n"); +} echo "oops did not run\n"; var_dump($_ENV, $_SERVER); __HALT_COMPILER();'); diff --git a/ext/phar/tests/cache_list/frontcontroller12.phpt b/ext/phar/tests/cache_list/frontcontroller12.phpt index a200fc2c7bca..e067e8968aab 100644 --- a/ext/phar/tests/cache_list/frontcontroller12.phpt +++ b/ext/phar/tests/cache_list/frontcontroller12.phpt @@ -14,8 +14,4 @@ files/frontcontroller6.phar --EXPECTHEADERS-- Content-type: text/html; charset=UTF-8 --EXPECTF-- -Fatal error: Uncaught PharException: Unknown mime type specifier used, only Phar::PHP, Phar::PHPS and a mime type string are allowed in %sfrontcontroller12.php:2 -Stack trace: -#0 %sfrontcontroller12.php(2): Phar::webPhar('whatever', 'index.php', NULL, Array) -#1 {main} - thrown in %sfrontcontroller12.php on line 2 +ValueError: Phar::webPhar(): Argument #4 ($mimeTypes) mime type specifier must be one of Phar::PHP or Phar::PHPS diff --git a/ext/phar/tests/cache_list/frontcontroller13.phpt b/ext/phar/tests/cache_list/frontcontroller13.phpt index dd66c851c127..b8ab7308b453 100644 --- a/ext/phar/tests/cache_list/frontcontroller13.phpt +++ b/ext/phar/tests/cache_list/frontcontroller13.phpt @@ -13,9 +13,5 @@ PATH_INFO=/a.php files/frontcontroller7.phar --EXPECTHEADERS-- Content-type: text/html; charset=UTF-8 ---EXPECTF-- -Fatal error: Uncaught PharException: Unknown mime type specifier used (not a string or int), only Phar::PHP, Phar::PHPS and a mime type string are allowed in %sfrontcontroller13.php:2 -Stack trace: -#0 %sfrontcontroller13.php(2): Phar::webPhar('whatever', 'index.php', NULL, Array) -#1 {main} - thrown in %sfrontcontroller13.php on line 2 +--EXPECT-- +TypeError: Phar::webPhar(): Argument #4 ($mimeTypes) mime type specifier must be of type string|int, null given diff --git a/ext/phar/tests/cache_list/frontcontroller18.phpt b/ext/phar/tests/cache_list/frontcontroller18.phpt index 90e29b17bda1..1da2dfe34ef3 100644 --- a/ext/phar/tests/cache_list/frontcontroller18.phpt +++ b/ext/phar/tests/cache_list/frontcontroller18.phpt @@ -10,9 +10,5 @@ REQUEST_URI=/frontcontroller18.php/fronk.gronk PATH_INFO=/fronk.gronk --FILE_EXTERNAL-- files/frontcontroller9.phar ---EXPECTF-- -Fatal error: Uncaught PharException: No values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME in %sfrontcontroller18.php:2 -Stack trace: -#0 %sfrontcontroller18.php(2): Phar::mungServer(Array) -#1 {main} - thrown in %sfrontcontroller18.php on line 2 +--EXPECT-- +ValueError: Phar::mungServer(): Argument #1 ($variables) must not be empty diff --git a/ext/phar/tests/cache_list/frontcontroller19.phpt b/ext/phar/tests/cache_list/frontcontroller19.phpt index b17c3ade4ee2..f85bfb1f7b5d 100644 --- a/ext/phar/tests/cache_list/frontcontroller19.phpt +++ b/ext/phar/tests/cache_list/frontcontroller19.phpt @@ -10,9 +10,5 @@ REQUEST_URI=/frontcontroller19.php/ PATH_INFO=/ --FILE_EXTERNAL-- files/frontcontroller10.phar ---EXPECTF-- -Fatal error: Uncaught PharException: Too many values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME in %sfrontcontroller19.php:2 -Stack trace: -#0 %sfrontcontroller19.php(2): Phar::mungServer(Array) -#1 {main} - thrown in %sfrontcontroller19.php on line 2 +--EXPECT-- +ValueError: Phar::mungServer(): Argument #1 ($variables) must have at most 4 elements diff --git a/ext/phar/tests/cache_list/frontcontroller20.phpt b/ext/phar/tests/cache_list/frontcontroller20.phpt index 8c9f4647b21d..605db21fd9a3 100644 --- a/ext/phar/tests/cache_list/frontcontroller20.phpt +++ b/ext/phar/tests/cache_list/frontcontroller20.phpt @@ -10,9 +10,5 @@ REQUEST_URI=/frontcontroller20.php/ PATH_INFO=/ --FILE_EXTERNAL-- files/frontcontroller11.phar ---EXPECTF-- -Fatal error: Uncaught PharException: Non-string value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME in %sfrontcontroller20.php:2 -Stack trace: -#0 %sfrontcontroller20.php(2): Phar::mungServer(Array) -#1 {main} - thrown in %sfrontcontroller20.php on line 2 +--EXPECT-- +TypeError: Phar::mungServer(): Argument #1 ($variables) must be an array of string types, array given diff --git a/ext/phar/tests/cache_list/frontcontroller29.phpt b/ext/phar/tests/cache_list/frontcontroller29.phpt index 75cea41d167c..85ec0f82dfd2 100644 --- a/ext/phar/tests/cache_list/frontcontroller29.phpt +++ b/ext/phar/tests/cache_list/frontcontroller29.phpt @@ -13,9 +13,5 @@ PATH_INFO=/fatalerror.phps files/frontcontroller8.phar --EXPECTHEADERS-- Content-type: text/html; charset=UTF-8 ---EXPECTF-- -Fatal error: Uncaught Error: Call to undefined function oopsie_daisy() in phar://%sfatalerror.phps:1 -Stack trace: -#0 %s(%d): Phar::webPhar('whatever', 'index.php', '404.php', Array) -#1 {main} - thrown in phar://%sfatalerror.phps on line 1 +--EXPECT-- +Error: Call to undefined function oopsie_daisy() diff --git a/ext/phar/tests/cache_list/frontcontroller31.phpt b/ext/phar/tests/cache_list/frontcontroller31.phpt index 9feed05344ee..aa1f20719130 100644 --- a/ext/phar/tests/cache_list/frontcontroller31.phpt +++ b/ext/phar/tests/cache_list/frontcontroller31.phpt @@ -16,9 +16,5 @@ REQUEST_URI=/frontcontroller31.php Content-type: text/html; charset=UTF-8 --FILE_EXTERNAL-- files/frontcontroller16.phar ---EXPECTF-- -Fatal error: Uncaught TypeError: Phar::webPhar(): Argument #5 ($rewrite) must be a valid callback or null, class "fail" not found in %s:%d -Stack trace: -#0 %s(%d): Phar::webPhar('test.phar', '/index.php', NULL, Array, Array) -#1 {main} - thrown in %s on line %d +--EXPECT-- +TypeError: Phar::webPhar(): Argument #5 ($rewrite) must be a valid callback or null, class "fail" not found diff --git a/ext/phar/tests/cache_list/frontcontroller32.phpt b/ext/phar/tests/cache_list/frontcontroller32.phpt index a61c91e1be29..3709efd2c870 100644 --- a/ext/phar/tests/cache_list/frontcontroller32.phpt +++ b/ext/phar/tests/cache_list/frontcontroller32.phpt @@ -16,5 +16,5 @@ REQUEST_URI=/frontcontroller32.php Content-type: text/html; charset=UTF-8 --FILE_EXTERNAL-- files/frontcontroller17.phar ---EXPECTF-- -%ahar error: rewrite callback must return a string or false +--EXPECT-- +TypeError: Rewrite callback return value must be of type string|false, null returned diff --git a/ext/phar/tests/cache_list/frontcontroller33.phpt b/ext/phar/tests/cache_list/frontcontroller33.phpt index 1b0684bc2fc4..1c294cf687e1 100644 --- a/ext/phar/tests/cache_list/frontcontroller33.phpt +++ b/ext/phar/tests/cache_list/frontcontroller33.phpt @@ -17,4 +17,4 @@ Content-type: text/html; charset=UTF-8 --FILE_EXTERNAL-- files/frontcontroller18.phar --EXPECT-- -phar error: rewrite callback must return a string or false +TypeError: Rewrite callback return value must be of type string|false, null returned diff --git a/ext/phar/tests/files/frontcontroller10.phar b/ext/phar/tests/files/frontcontroller10.phar index 078ce75b2c7b..d98257dc308c 100644 Binary files a/ext/phar/tests/files/frontcontroller10.phar and b/ext/phar/tests/files/frontcontroller10.phar differ diff --git a/ext/phar/tests/files/frontcontroller10.phar.inc b/ext/phar/tests/files/frontcontroller10.phar.inc index 4c139db58bd6..02097c5c3e59 100644 --- a/ext/phar/tests/files/frontcontroller10.phar.inc +++ b/ext/phar/tests/files/frontcontroller10.phar.inc @@ -12,8 +12,12 @@ var_dump($_SERVER["PHAR_SCRIPT_FILENAME"]); var_dump($_SERVER["PHAR_REQUEST_URI"]); '; $a->setStub('getMessage() . "\n"); +} echo "oops did not run\n"; var_dump($_ENV, $_SERVER); __HALT_COMPILER();'); diff --git a/ext/phar/tests/files/frontcontroller14.phar b/ext/phar/tests/files/frontcontroller14.phar index ecfc5d7864b0..f6f1ca3ede74 100644 Binary files a/ext/phar/tests/files/frontcontroller14.phar and b/ext/phar/tests/files/frontcontroller14.phar differ diff --git a/ext/phar/tests/files/frontcontroller14.phar.inc b/ext/phar/tests/files/frontcontroller14.phar.inc index d0ebd9a45a76..858d713a8219 100644 --- a/ext/phar/tests/files/frontcontroller14.phar.inc +++ b/ext/phar/tests/files/frontcontroller14.phar.inc @@ -9,10 +9,13 @@ $a->setStub('getMessage() . "\n"); } -Phar::interceptFileFuncs(); -Phar::mungServer(array("PHP_SELF", "REQUEST_URI")); -Phar::webPhar("whatever", "/html/index.php", null, array(), "s"); echo "oops did not run\n"; var_dump($_ENV, $_SERVER); __HALT_COMPILER();'); diff --git a/ext/phar/tests/files/frontcontroller16.phar b/ext/phar/tests/files/frontcontroller16.phar index cce5db5bb5bc..a277ae5f4d9c 100644 Binary files a/ext/phar/tests/files/frontcontroller16.phar and b/ext/phar/tests/files/frontcontroller16.phar differ diff --git a/ext/phar/tests/files/frontcontroller16.phar.inc b/ext/phar/tests/files/frontcontroller16.phar.inc index 442f1fb18f67..db0ee111b4ca 100644 --- a/ext/phar/tests/files/frontcontroller16.phar.inc +++ b/ext/phar/tests/files/frontcontroller16.phar.inc @@ -6,9 +6,9 @@ echo "hi"; '; $a->setStub('getMessage() . "\n"); + Phar::webPhar("test.phar", "/index.php", null, array(), array("fail", "here")); +} catch (Throwable $e) { + die($e::class . ": " . $e->getMessage() . "\n"); } echo "oops did not run\n"; var_dump($_ENV, $_SERVER); diff --git a/ext/phar/tests/files/frontcontroller17.phar b/ext/phar/tests/files/frontcontroller17.phar index 4dab78a9ec01..a59f7621af77 100644 Binary files a/ext/phar/tests/files/frontcontroller17.phar and b/ext/phar/tests/files/frontcontroller17.phar differ diff --git a/ext/phar/tests/files/frontcontroller17.phar.inc b/ext/phar/tests/files/frontcontroller17.phar.inc index 715479552a2b..54c19af1296a 100644 --- a/ext/phar/tests/files/frontcontroller17.phar.inc +++ b/ext/phar/tests/files/frontcontroller17.phar.inc @@ -6,9 +6,9 @@ echo "hi"; '; $a->setStub('getMessage() . "\n"); + Phar::webPhar("test.phar", "/index.php", null, array(), function() { throw new Exception; }); +} catch (Throwable $e) { + die($e::class . ": " . $e->getMessage() . "\n"); } echo "oops did not run\n"; var_dump($_ENV, $_SERVER); diff --git a/ext/phar/tests/files/frontcontroller18.phar b/ext/phar/tests/files/frontcontroller18.phar index c447f397ac54..caa108adaecc 100644 Binary files a/ext/phar/tests/files/frontcontroller18.phar and b/ext/phar/tests/files/frontcontroller18.phar differ diff --git a/ext/phar/tests/files/frontcontroller18.phar.inc b/ext/phar/tests/files/frontcontroller18.phar.inc index 847a713ba38b..4c816518ac7a 100644 --- a/ext/phar/tests/files/frontcontroller18.phar.inc +++ b/ext/phar/tests/files/frontcontroller18.phar.inc @@ -9,9 +9,9 @@ function s($a) { } try { -Phar::webPhar("test.phar", "/index.php", null, array(), "s"); -} catch (Exception $e) { -die($e->getMessage() . "\n"); + Phar::webPhar("test.phar", "/index.php", null, array(), "s"); +} catch (Throwable $e) { + die($e::class . ": " . $e->getMessage() . "\n"); } echo "oops did not run\n"; var_dump($_ENV, $_SERVER); diff --git a/ext/phar/tests/files/frontcontroller19.phar b/ext/phar/tests/files/frontcontroller19.phar index bdf8ee13c20c..eee4cba718e2 100644 Binary files a/ext/phar/tests/files/frontcontroller19.phar and b/ext/phar/tests/files/frontcontroller19.phar differ diff --git a/ext/phar/tests/files/frontcontroller19.phar.inc b/ext/phar/tests/files/frontcontroller19.phar.inc index ba84ac410a31..e573869e098b 100644 --- a/ext/phar/tests/files/frontcontroller19.phar.inc +++ b/ext/phar/tests/files/frontcontroller19.phar.inc @@ -15,9 +15,9 @@ echo "another.php\n"; $a->setStub('getMessage() . "\n"); + Phar::webPhar("test.phar", "/start/index.php"); +} catch (Throwable $e) { + die($e::class . ": " . $e->getMessage() . "\n"); } echo "oops did not run\n"; var_dump($_ENV, $_SERVER); diff --git a/ext/phar/tests/files/frontcontroller2.phar b/ext/phar/tests/files/frontcontroller2.phar index 0dd0e7f69562..c774f1c819f0 100644 Binary files a/ext/phar/tests/files/frontcontroller2.phar and b/ext/phar/tests/files/frontcontroller2.phar differ diff --git a/ext/phar/tests/files/frontcontroller2.phar.inc b/ext/phar/tests/files/frontcontroller2.phar.inc index 653c79691d99..fb7a36a9925b 100644 --- a/ext/phar/tests/files/frontcontroller2.phar.inc +++ b/ext/phar/tests/files/frontcontroller2.phar.inc @@ -5,7 +5,11 @@ $a['a.php'] = 'hio'; $a['a.jpg'] = 'hio'; $a['a.phps'] = 'setStub('getMessage() . "\n"); +} echo "oops did not run\n"; var_dump($_ENV, $_SERVER); __HALT_COMPILER();'); diff --git a/ext/phar/tests/files/frontcontroller3.phar b/ext/phar/tests/files/frontcontroller3.phar index 4859fdd10f9f..ec3e556a3c1b 100644 Binary files a/ext/phar/tests/files/frontcontroller3.phar and b/ext/phar/tests/files/frontcontroller3.phar differ diff --git a/ext/phar/tests/files/frontcontroller3.phar.inc b/ext/phar/tests/files/frontcontroller3.phar.inc index 2759d9ee45a7..cca0a8f3202e 100644 --- a/ext/phar/tests/files/frontcontroller3.phar.inc +++ b/ext/phar/tests/files/frontcontroller3.phar.inc @@ -11,7 +11,11 @@ function s($a) if (isset($b[$a])) return $b[$a]; return $a; } -Phar::webPhar("whatever", "/index.php", null, array(), "s"); +try { + Phar::webPhar("whatever", "/index.php", null, array(), "s"); +} catch (Throwable $e) { + die($e::class . ": " . $e->getMessage() . "\n"); +} echo "oops did not run\n"; var_dump($_ENV, $_SERVER); __HALT_COMPILER();'); diff --git a/ext/phar/tests/files/frontcontroller4.phar b/ext/phar/tests/files/frontcontroller4.phar index 3d4783f64b2c..a693ead059d8 100644 Binary files a/ext/phar/tests/files/frontcontroller4.phar and b/ext/phar/tests/files/frontcontroller4.phar differ diff --git a/ext/phar/tests/files/frontcontroller4.phar.inc b/ext/phar/tests/files/frontcontroller4.phar.inc index 5c6a43f9546c..86c7f83ce65f 100644 --- a/ext/phar/tests/files/frontcontroller4.phar.inc +++ b/ext/phar/tests/files/frontcontroller4.phar.inc @@ -11,7 +11,11 @@ function s($a) if (isset($b[$a])) return $b[$a]; return $a; } -Phar::webPhar("whatever", "index.php", null, array(), "s"); +try { + Phar::webPhar("whatever", "index.php", null, array(), "s"); +} catch (Throwable $e) { + die($e::class . ": " . $e->getMessage() . "\n"); +} echo "oops did not run\n"; var_dump($_ENV, $_SERVER); __HALT_COMPILER();'); diff --git a/ext/phar/tests/files/frontcontroller5.phar b/ext/phar/tests/files/frontcontroller5.phar index 4dee4e3f0d2c..20d51d151185 100644 Binary files a/ext/phar/tests/files/frontcontroller5.phar and b/ext/phar/tests/files/frontcontroller5.phar differ diff --git a/ext/phar/tests/files/frontcontroller5.phar.inc b/ext/phar/tests/files/frontcontroller5.phar.inc index d2d810c36762..43b0caf0f986 100644 --- a/ext/phar/tests/files/frontcontroller5.phar.inc +++ b/ext/phar/tests/files/frontcontroller5.phar.inc @@ -5,7 +5,11 @@ $a['a.php'] = 'hio'; $a['a.jpg'] = 'hio'; $a['a.phps'] = 'setStub(' "oops")); +try { + Phar::webPhar("whatever", "index.php", null, array(0 => "oops")); +} catch (Throwable $e) { + die($e::class . ": " . $e->getMessage() . "\n"); +} echo "oops did not run\n"; var_dump($_ENV, $_SERVER); __HALT_COMPILER();'); diff --git a/ext/phar/tests/files/frontcontroller6.phar b/ext/phar/tests/files/frontcontroller6.phar index f4a8265b1609..da4130018a02 100644 Binary files a/ext/phar/tests/files/frontcontroller6.phar and b/ext/phar/tests/files/frontcontroller6.phar differ diff --git a/ext/phar/tests/files/frontcontroller6.phar.inc b/ext/phar/tests/files/frontcontroller6.phar.inc index 61f7807a5d27..9d9e6c861ee8 100644 --- a/ext/phar/tests/files/frontcontroller6.phar.inc +++ b/ext/phar/tests/files/frontcontroller6.phar.inc @@ -5,7 +5,11 @@ $a['a.php'] = 'hio'; $a['a.jpg'] = 'hio'; $a['a.phps'] = 'setStub(' 100)); +try { + Phar::webPhar("whatever", "index.php", null, array("php" => 100)); +} catch (Throwable $e) { + die($e::class . ": " . $e->getMessage() . "\n"); +} echo "oops did not run\n"; var_dump($_ENV, $_SERVER); __HALT_COMPILER();'); diff --git a/ext/phar/tests/files/frontcontroller7.phar b/ext/phar/tests/files/frontcontroller7.phar index 07884b22bc29..4875e711c205 100644 Binary files a/ext/phar/tests/files/frontcontroller7.phar and b/ext/phar/tests/files/frontcontroller7.phar differ diff --git a/ext/phar/tests/files/frontcontroller7.phar.inc b/ext/phar/tests/files/frontcontroller7.phar.inc index f2bd72b45bd7..41ae2213367c 100644 --- a/ext/phar/tests/files/frontcontroller7.phar.inc +++ b/ext/phar/tests/files/frontcontroller7.phar.inc @@ -5,7 +5,11 @@ $a['a.php'] = 'hio'; $a['a.jpg'] = 'hio'; $a['a.phps'] = 'setStub(' null)); +try { + Phar::webPhar("whatever", "index.php", null, array("php" => null)); +} catch (Throwable $e) { + die($e::class . ": " . $e->getMessage() . "\n"); +} echo "oops did not run\n"; var_dump($_ENV, $_SERVER); __HALT_COMPILER();'); diff --git a/ext/phar/tests/files/frontcontroller8.phar b/ext/phar/tests/files/frontcontroller8.phar index 295143edb966..b110e0717c39 100644 Binary files a/ext/phar/tests/files/frontcontroller8.phar and b/ext/phar/tests/files/frontcontroller8.phar differ diff --git a/ext/phar/tests/files/frontcontroller8.phar.inc b/ext/phar/tests/files/frontcontroller8.phar.inc index 1dfb654a031e..fb76f8f63d2e 100644 --- a/ext/phar/tests/files/frontcontroller8.phar.inc +++ b/ext/phar/tests/files/frontcontroller8.phar.inc @@ -12,7 +12,11 @@ $a['unknown.ext'] = 'setStub(' "foo/bar", "phps" => Phar::PHP, "php" => Phar::PHPS)); +try { + Phar::webPhar("whatever", "index.php", "404.php", array("jpg" => "foo/bar", "phps" => Phar::PHP, "php" => Phar::PHPS)); +} catch (Throwable $e) { + die($e::class . ": " . $e->getMessage() . "\n"); +} echo "oops did not run\n"; var_dump($_ENV, $_SERVER); __HALT_COMPILER();'); diff --git a/ext/phar/tests/files/frontcontroller9.phar b/ext/phar/tests/files/frontcontroller9.phar index 39ca28c96cfa..04e0337a220c 100644 Binary files a/ext/phar/tests/files/frontcontroller9.phar and b/ext/phar/tests/files/frontcontroller9.phar differ diff --git a/ext/phar/tests/files/frontcontroller9.phar.inc b/ext/phar/tests/files/frontcontroller9.phar.inc index 00861f64205c..6d48b9fa273d 100644 --- a/ext/phar/tests/files/frontcontroller9.phar.inc +++ b/ext/phar/tests/files/frontcontroller9.phar.inc @@ -6,8 +6,12 @@ $a['a.jpg'] = 'hio2'; $a['a.php'] = 'setStub(' "foo/bar", "phps" => Phar::PHP, "php" => Phar::PHPS)); +try { + Phar::mungServer(array()); + Phar::webPhar("whatever", "index.php", null, array("jpg" => "foo/bar", "phps" => Phar::PHP, "php" => Phar::PHPS)); +} catch (Throwable $e) { + die($e::class . ": " . $e->getMessage() . "\n"); +} echo "oops did not run\n"; var_dump($_ENV, $_SERVER); __HALT_COMPILER();'); diff --git a/ext/phar/tests/frontcontroller12.phpt b/ext/phar/tests/frontcontroller12.phpt index c77e51489e13..fc38f2332b5f 100644 --- a/ext/phar/tests/frontcontroller12.phpt +++ b/ext/phar/tests/frontcontroller12.phpt @@ -12,9 +12,5 @@ PATH_INFO=/a.php files/frontcontroller6.phar --EXPECTHEADERS-- Content-type: text/html; charset=UTF-8 ---EXPECTF-- -Fatal error: Uncaught PharException: Unknown mime type specifier used, only Phar::PHP, Phar::PHPS and a mime type string are allowed in %sfrontcontroller12.php:2 -Stack trace: -#0 %sfrontcontroller12.php(2): Phar::webPhar('whatever', 'index.php', NULL, Array) -#1 {main} - thrown in %sfrontcontroller12.php on line 2 +--EXPECT-- +ValueError: Phar::webPhar(): Argument #4 ($mimeTypes) mime type specifier must be one of Phar::PHP or Phar::PHPS diff --git a/ext/phar/tests/frontcontroller13.phpt b/ext/phar/tests/frontcontroller13.phpt index e6678bae9d65..ddd604731538 100644 --- a/ext/phar/tests/frontcontroller13.phpt +++ b/ext/phar/tests/frontcontroller13.phpt @@ -12,9 +12,5 @@ PATH_INFO=/a.php files/frontcontroller7.phar --EXPECTHEADERS-- Content-type: text/html; charset=UTF-8 ---EXPECTF-- -Fatal error: Uncaught PharException: Unknown mime type specifier used (not a string or int), only Phar::PHP, Phar::PHPS and a mime type string are allowed in %sfrontcontroller13.php:2 -Stack trace: -#0 %sfrontcontroller13.php(2): Phar::webPhar('whatever', 'index.php', NULL, Array) -#1 {main} - thrown in %sfrontcontroller13.php on line 2 +--EXPECT-- +TypeError: Phar::webPhar(): Argument #4 ($mimeTypes) mime type specifier must be of type string|int, null given diff --git a/ext/phar/tests/frontcontroller18.phpt b/ext/phar/tests/frontcontroller18.phpt index 6bfe15df5cab..a8c2720fbab5 100644 --- a/ext/phar/tests/frontcontroller18.phpt +++ b/ext/phar/tests/frontcontroller18.phpt @@ -8,9 +8,5 @@ REQUEST_URI=/frontcontroller18.php/fronk.gronk PATH_INFO=/fronk.gronk --FILE_EXTERNAL-- files/frontcontroller9.phar ---EXPECTF-- -Fatal error: Uncaught PharException: No values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME in %sfrontcontroller18.php:2 -Stack trace: -#0 %sfrontcontroller18.php(2): Phar::mungServer(Array) -#1 {main} - thrown in %sfrontcontroller18.php on line 2 +--EXPECT-- +ValueError: Phar::mungServer(): Argument #1 ($variables) must not be empty diff --git a/ext/phar/tests/frontcontroller19.phpt b/ext/phar/tests/frontcontroller19.phpt index 0685975e13a6..4b00cf13a141 100644 --- a/ext/phar/tests/frontcontroller19.phpt +++ b/ext/phar/tests/frontcontroller19.phpt @@ -8,9 +8,5 @@ REQUEST_URI=/frontcontroller19.php/ PATH_INFO=/ --FILE_EXTERNAL-- files/frontcontroller10.phar ---EXPECTF-- -Fatal error: Uncaught PharException: Too many values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME in %sfrontcontroller19.php:2 -Stack trace: -#0 %sfrontcontroller19.php(2): Phar::mungServer(Array) -#1 {main} - thrown in %sfrontcontroller19.php on line 2 +--EXPECT-- +ValueError: Phar::mungServer(): Argument #1 ($variables) must have at most 4 elements diff --git a/ext/phar/tests/frontcontroller20.phpt b/ext/phar/tests/frontcontroller20.phpt index 75854822f20b..e215387c5ae5 100644 --- a/ext/phar/tests/frontcontroller20.phpt +++ b/ext/phar/tests/frontcontroller20.phpt @@ -9,7 +9,7 @@ PATH_INFO=/ --FILE_EXTERNAL-- files/frontcontroller11.phar --EXPECTF-- -Fatal error: Uncaught PharException: Non-string value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME in %sfrontcontroller20.php:2 +Fatal error: Uncaught TypeError: Phar::mungServer(): Argument #1 ($variables) must be an array of string types, array given in %sfrontcontroller20.php:2 Stack trace: #0 %sfrontcontroller20.php(2): Phar::mungServer(Array) #1 {main} diff --git a/ext/phar/tests/frontcontroller29.phpt b/ext/phar/tests/frontcontroller29.phpt index 2a19272d3e55..c17c9287bc12 100644 --- a/ext/phar/tests/frontcontroller29.phpt +++ b/ext/phar/tests/frontcontroller29.phpt @@ -12,9 +12,5 @@ PATH_INFO=/fatalerror.phps files/frontcontroller8.phar --EXPECTHEADERS-- Content-type: text/html; charset=UTF-8 ---EXPECTF-- -Fatal error: Uncaught Error: Call to undefined function oopsie_daisy() in phar://%sfatalerror.phps:1 -Stack trace: -#0 %s(%d): Phar::webPhar('whatever', 'index.php', '404.php', Array) -#1 {main} - thrown in phar://%sfatalerror.phps on line 1 +--EXPECT-- +Error: Call to undefined function oopsie_daisy() diff --git a/ext/phar/tests/frontcontroller31.phpt b/ext/phar/tests/frontcontroller31.phpt index e17f7fb3df1b..a954cc6e5cff 100644 --- a/ext/phar/tests/frontcontroller31.phpt +++ b/ext/phar/tests/frontcontroller31.phpt @@ -11,9 +11,5 @@ REQUEST_URI=/frontcontroller31.php Content-type: text/html; charset=UTF-8 --FILE_EXTERNAL-- files/frontcontroller16.phar ---EXPECTF-- -Fatal error: Uncaught TypeError: Phar::webPhar(): Argument #5 ($rewrite) must be a valid callback or null, class "fail" not found in %s:%d -Stack trace: -#0 %s(%d): Phar::webPhar('test.phar', '/index.php', NULL, Array, Array) -#1 {main} - thrown in %s on line %d +--EXPECT-- +TypeError: Phar::webPhar(): Argument #5 ($rewrite) must be a valid callback or null, class "fail" not found diff --git a/ext/phar/tests/frontcontroller32.phpt b/ext/phar/tests/frontcontroller32.phpt index 047912ef56d9..e6d054e39a0d 100644 --- a/ext/phar/tests/frontcontroller32.phpt +++ b/ext/phar/tests/frontcontroller32.phpt @@ -11,5 +11,5 @@ REQUEST_URI=/frontcontroller32.php Content-type: text/html; charset=UTF-8 --FILE_EXTERNAL-- files/frontcontroller17.phar ---EXPECTF-- -%ahar error: rewrite callback must return a string or false +--EXPECT-- +TypeError: Rewrite callback return value must be of type string|false, null returned diff --git a/ext/phar/tests/frontcontroller33.phpt b/ext/phar/tests/frontcontroller33.phpt index cdf32538d16d..3c7f8149fc12 100644 --- a/ext/phar/tests/frontcontroller33.phpt +++ b/ext/phar/tests/frontcontroller33.phpt @@ -12,4 +12,4 @@ Content-type: text/html; charset=UTF-8 --FILE_EXTERNAL-- files/frontcontroller18.phar --EXPECT-- -phar error: rewrite callback must return a string or false +TypeError: Rewrite callback return value must be of type string|false, null returned diff --git a/ext/phar/tests/invalid_setstubalias.phpt b/ext/phar/tests/invalid_setstubalias.phpt index bcbcb2666928..475c091000ee 100644 --- a/ext/phar/tests/invalid_setstubalias.phpt +++ b/ext/phar/tests/invalid_setstubalias.phpt @@ -12,29 +12,29 @@ $fname2 = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.zip'; $p = new Phar($fname); try { $p['.phar/stub.php'] = 'hi'; -} catch (Exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { $p['.phar/alias.txt'] = 'hi'; -} catch (Exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } $p = new Phar($fname2); try { $p['.phar/stub.php'] = 'hi'; -} catch (Exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { $p['.phar/alias.txt'] = 'hi'; -} catch (Exception $e) { - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } ?> ---EXPECTF-- -Cannot set stub ".phar/stub.php" directly in phar "%sinvalid_setstubalias.phar.tar", use setStub -Cannot set alias ".phar/alias.txt" directly in phar "%sinvalid_setstubalias.phar.tar", use setAlias -Cannot set stub ".phar/stub.php" directly in phar "%sinvalid_setstubalias.phar.zip", use setStub -Cannot set alias ".phar/alias.txt" directly in phar "%sinvalid_setstubalias.phar.zip", use setAlias +--EXPECT-- +ValueError: Phar::offsetSet(): Argument #1 ($localName) must not be ".phar/stub.php", use Phar::setStub() instead +ValueError: Phar::offsetSet(): Argument #1 ($localName) must not be ".phar/alias.txt", use Phar::setAlias() instead +ValueError: Phar::offsetSet(): Argument #1 ($localName) must not be ".phar/stub.php", use Phar::setStub() instead +ValueError: Phar::offsetSet(): Argument #1 ($localName) must not be ".phar/alias.txt", use Phar::setAlias() instead diff --git a/ext/phar/tests/invalid_string_phar_mungserver.phpt b/ext/phar/tests/invalid_string_phar_mungserver.phpt index 8128987dacbc..f4a430aa8395 100644 --- a/ext/phar/tests/invalid_string_phar_mungserver.phpt +++ b/ext/phar/tests/invalid_string_phar_mungserver.phpt @@ -8,10 +8,10 @@ phar $str = 'invalid'; try { Phar::mungServer([&$str]); -} catch (PharException $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } ?> --EXPECT-- -Invalid value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME +ValueError: Phar::mungServer(): Argument #1 ($variables) must only contain elements with the following values "PHP_SELF", "REQUEST_URI", "SCRIPT_FILENAME", or "SCRIPT_NAME" diff --git a/ext/phar/tests/mkdir.phpt b/ext/phar/tests/mkdir.phpt index 1ffdc7fe252d..fd79df82b0ca 100644 --- a/ext/phar/tests/mkdir.phpt +++ b/ext/phar/tests/mkdir.phpt @@ -20,9 +20,9 @@ rmdir($pname . '/a'); $a->addEmptyDir('bb'); $a->addEmptyDir('bb'); try { -$a->addEmptyDir('.phar'); -} catch (Exception $e) { -echo $e->getMessage(),"\n"; + $a->addEmptyDir('.phar'); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } ?> --CLEAN-- @@ -42,4 +42,4 @@ Warning: rmdir(): phar error: cannot remove directory "phar://", no phar archive Warning: rmdir(): phar error: cannot remove directory "" in phar "foo.phar", directory does not exist in %smkdir.php on line %d Warning: rmdir(): phar error: cannot remove directory "a" in phar "%smkdir.phar.php", phar error: path "a" exists and is a not a directory in %smkdir.php on line %d -Cannot create a directory in magic ".phar" directory +ValueError: Phar::addEmptyDir(): Argument #1 ($directory) must not start with ".phar" diff --git a/ext/phar/tests/phar_buildfromiterator5.phpt b/ext/phar/tests/phar_buildfromiterator5.phpt index 2ddf1c282ece..4d2f6b48318e 100644 --- a/ext/phar/tests/phar_buildfromiterator5.phpt +++ b/ext/phar/tests/phar_buildfromiterator5.phpt @@ -39,14 +39,12 @@ try { chdir(__DIR__); $phar = new Phar(__DIR__ . '/buildfromiterator5.phar'); var_dump($phar->buildFromIterator(new myIterator(array('a' => new stdClass)))); -} catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } ?> ---EXPECTF-- +--EXPECT-- rewind valid current -%s(24) "UnexpectedValueException" -Iterator myIterator returned an invalid value (must return a string, a stream, or an SplFileInfo object) +TypeError: Iterator myIterator return value must be of type string|object|resource, stdClass returned diff --git a/ext/phar/tests/phar_buildfromiterator6.phpt b/ext/phar/tests/phar_buildfromiterator6.phpt index 4e4f09f74aa7..a15f26fd1082 100644 --- a/ext/phar/tests/phar_buildfromiterator6.phpt +++ b/ext/phar/tests/phar_buildfromiterator6.phpt @@ -39,15 +39,13 @@ try { chdir(__DIR__); $phar = new Phar(__DIR__ . '/buildfromiterator6.phar'); var_dump($phar->buildFromIterator(new myIterator(array(basename(__FILE__, 'php') . 'phpt')))); -} catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } ?> ---EXPECTF-- +--EXPECT-- rewind valid current key -%s(24) "UnexpectedValueException" -Iterator myIterator returned an invalid key (must return a string) +TypeError: Iterator myIterator must return a key of type string, int returned diff --git a/ext/phar/tests/phar_bz2.phpt b/ext/phar/tests/phar_bz2.phpt index bb0a98101fac..85235386cc65 100644 --- a/ext/phar/tests/phar_bz2.phpt +++ b/ext/phar/tests/phar_bz2.phpt @@ -39,9 +39,9 @@ var_dump($b->isFileFormat(Phar::PHAR)); var_dump($b->isCompressed() == Phar::BZ2); // additional code coverage try { -$b->isFileFormat(25); -} catch (Exception $e) { -echo $e->getMessage(),"\n"; + $b->isFileFormat(25); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } ?> --CLEAN-- @@ -54,4 +54,4 @@ string(9) "it worked" string(%d) "phar://%sphar_bz2.phar/tar_004.php" bool(true) bool(true) -Unknown file format specified +ValueError: Phar::isFileFormat(): Argument #1 ($format) must be one of Phar::PHAR, Phar::TAR, or Phar::ZIP diff --git a/ext/phar/tests/phar_convert_again.phpt b/ext/phar/tests/phar_convert_again.phpt index 008d28ad80f6..2f703184e08c 100644 --- a/ext/phar/tests/phar_convert_again.phpt +++ b/ext/phar/tests/phar_convert_again.phpt @@ -31,9 +31,9 @@ echo $tgz->getPath() . "\n"; $tbz = $phar->convertToData(Phar::TAR, Phar::BZ2); echo $tbz->getPath() . "\n"; try { -$phar = $tbz->convertToExecutable(Phar::PHAR, Phar::NONE); -} catch (Exception $e) { -echo $e->getMessage() . "\n"; + $phar = $tbz->convertToExecutable(Phar::PHAR, Phar::NONE); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } copy($tbz->getPath(), $fname2); $tbz = new PharData($fname2); @@ -48,17 +48,17 @@ $data = $zip->convertToData(); echo $data->getPath() . "\n"; // extra code coverage try { -$data->setStub('hi'); -} catch (Exception $e) { -echo $e->getMessage() . "\n"; + $data->setStub('hi'); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { -$data->setDefaultStub(); -} catch (Exception $e) { -echo $e->getMessage() . "\n"; + $data->setDefaultStub(); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { -$data->setAlias('hi'); + $data->setAlias('hi'); } catch (Exception $e) { echo $e->getMessage() . "\n"; } @@ -69,87 +69,87 @@ echo $data->getPath() . "\n"; $tgz = $tar->convertToExecutable(null, Phar::GZ); echo $tgz->getPath() . "\n"; try { -$tgz->convertToExecutable(25); -} catch (Exception $e) { -echo $e->getMessage() . "\n"; + $tgz->convertToExecutable(25); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { -$tgz->convertToExecutable(Phar::ZIP, Phar::GZ); -} catch (Exception $e) { -echo $e->getMessage() . "\n"; + $tgz->convertToExecutable(Phar::ZIP, Phar::GZ); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { -$tgz->convertToExecutable(Phar::ZIP, Phar::BZ2); -} catch (Exception $e) { -echo $e->getMessage() . "\n"; + $tgz->convertToExecutable(Phar::ZIP, Phar::BZ2); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { -$phar->convertToData(); -} catch (Exception $e) { -echo $e->getMessage() . "\n"; + $phar->convertToData(); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { -$tgz->convertToData(Phar::PHAR); -} catch (Exception $e) { -echo $e->getMessage() . "\n"; + $tgz->convertToData(Phar::PHAR); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { -$tgz->convertToData(25); -} catch (Exception $e) { -echo $e->getMessage() . "\n"; + $tgz->convertToData(25); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { -$tgz->convertToData(Phar::ZIP, Phar::GZ); -} catch (Exception $e) { -echo $e->getMessage() . "\n"; + $tgz->convertToData(Phar::ZIP, Phar::GZ); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { -$tgz->convertToData(Phar::ZIP, Phar::BZ2); -} catch (Exception $e) { -echo $e->getMessage() . "\n"; + $tgz->convertToData(Phar::ZIP, Phar::BZ2); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { -$tgz->convertToExecutable(Phar::TAR, 25); -} catch (Exception $e) { -echo $e->getMessage() . "\n"; + $tgz->convertToExecutable(Phar::TAR, 25); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { -$tgz->convertToData(Phar::TAR, 25); -} catch (Exception $e) { -echo $e->getMessage() . "\n"; + $tgz->convertToData(Phar::TAR, 25); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } // extra code coverage try { -$data->setStub('hi'); -} catch (Exception $e) { -echo $e->getMessage() . "\n"; + $data->setStub('hi'); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { -$data->setAlias('hi'); -} catch (Exception $e) { -echo $e->getMessage() . "\n"; + $data->setAlias('hi'); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { -$data->setDefaultStub(); -} catch (Exception $e) { -echo $e->getMessage() . "\n"; + $data->setDefaultStub(); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { -$tgz->convertToData(Phar::TAR, Phar::GZ, '.phar.tgz.oops'); -} catch (Exception $e) { -echo $e->getMessage() . "\n"; + $tgz->convertToData(Phar::TAR, Phar::GZ, '.phar.tgz.oops'); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { -$phar->convertToExecutable(Phar::TAR, Phar::GZ, '.tgz.oops'); -} catch (Exception $e) { -echo $e->getMessage() . "\n"; + $phar->convertToExecutable(Phar::TAR, Phar::GZ, '.tgz.oops'); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { -$tgz->convertToData(Phar::TAR, Phar::GZ, '.phar/.tgz.oops'); -} catch (Exception $e) { -echo $e->getMessage() . "\n"; + $tgz->convertToData(Phar::TAR, Phar::GZ, '.phar/.tgz.oops'); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } ?> --CLEAN-- @@ -171,30 +171,30 @@ __HALT_COMPILER(); %sphar_convert_again.zip %sphar_convert_again.tar.gz %sphar_convert_again.tar.bz2 -Unable to add newly converted phar "%sphar_convert_again.phar" to the list of phars, a phar with that name already exists +BadMethodCallException: Unable to add newly converted phar "%sphar_convert_again.phar" to the list of phars, a phar with that name already exists %sphar_convert_again2.phar %sphar_convert_again2.phar.zip hi %sphar_convert_again2.zip -A Phar stub cannot be set in a plain zip archive -A Phar stub cannot be set in a plain zip archive +UnexpectedValueException: A Phar stub cannot be set in a plain zip archive +UnexpectedValueException: A Phar stub cannot be set in a plain zip archive A Phar alias cannot be set in a plain zip archive %sphar_convert_again2.phar.tar %sphar_convert_again2.tar %sphar_convert_again2.phar.tar.gz -Unknown file format specified, please pass one of Phar::PHAR, Phar::TAR or Phar::ZIP -Cannot compress entire archive with gzip, zip archives do not support whole-archive compression -Cannot compress entire archive with bz2, zip archives do not support whole-archive compression -Cannot write out data phar archive, use Phar::TAR or Phar::ZIP -Cannot write out data phar archive, use Phar::TAR or Phar::ZIP -Unknown file format specified, please pass one of Phar::TAR or Phar::ZIP -Cannot compress entire archive with gzip, zip archives do not support whole-archive compression -Cannot compress entire archive with bz2, zip archives do not support whole-archive compression -Unknown compression specified, please pass one of Phar::GZ or Phar::BZ2 -Unknown compression specified, please pass one of Phar::GZ or Phar::BZ2 -A Phar stub cannot be set in a plain tar archive -A Phar alias cannot be set in a plain tar archive -A Phar stub cannot be set in a plain tar archive -data phar "%sphar_convert_again2.phar.tgz.oops" has invalid extension phar.tgz.oops -phar "%sphar_convert_again2.tgz.oops" has invalid extension tgz.oops -data phar "%sphar_convert_again2.phar/.tgz.oops" has invalid extension phar/.tgz.oops +ValueError: Phar::convertToExecutable(): Argument #1 ($format) must be one of Phar::PHAR, Phar::TAR, or Phar::ZIP +ValueError: Phar::convertToExecutable(): Argument #2 ($compression) must not be Phar::GZ when argument #1 is Phar::ZIP, as ZIP archives do not support whole-archive compression +ValueError: Phar::convertToExecutable(): Argument #2 ($compression) must not be Phar::BZ2 when argument #1 is Phar::ZIP, as ZIP archives do not support whole-archive compression +UnexpectedValueException: Cannot write out data phar archive, use Phar::TAR or Phar::ZIP +UnexpectedValueException: Cannot write out data phar archive, use Phar::TAR or Phar::ZIP +ValueError: Phar::convertToData(): Argument #1 ($format) must be one of Phar::TAR or Phar::ZIP +ValueError: Phar::convertToData(): Argument #2 ($compression) must not be Phar::GZ when argument #1 is Phar::ZIP, as ZIP archives do not support whole-archive compression +ValueError: Phar::convertToData(): Argument #2 ($compression) must not be Phar::BZ2 when argument #1 is Phar::ZIP, as ZIP archives do not support whole-archive compression +ValueError: Phar::convertToExecutable(): Argument #2 ($compression) must be one of Phar::NONE, Phar::GZ, or Phar::BZ2 +ValueError: Phar::convertToData(): Argument #2 ($compression) must be one of Phar::NONE, Phar::GZ, or Phar::BZ2 +UnexpectedValueException: A Phar stub cannot be set in a plain tar archive +UnexpectedValueException: A Phar alias cannot be set in a plain tar archive +UnexpectedValueException: A Phar stub cannot be set in a plain tar archive +BadMethodCallException: data phar "%sphar_convert_again2.phar.tgz.oops" has invalid extension phar.tgz.oops +BadMethodCallException: phar "%sphar_convert_again2.tgz.oops" has invalid extension tgz.oops +BadMethodCallException: data phar "%sphar_convert_again2.phar/.tgz.oops" has invalid extension phar/.tgz.oops diff --git a/ext/phar/tests/phar_extract.phpt b/ext/phar/tests/phar_extract.phpt index 7d50a3bed749..406c89ecd185 100644 --- a/ext/phar/tests/phar_extract.phpt +++ b/ext/phar/tests/phar_extract.phpt @@ -46,40 +46,40 @@ var_dump(is_dir(__DIR__ . '/extract1-2/one/level')); try { $a->extractTo(__DIR__ . '/whatever', new stdClass()); -} catch (TypeError $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { $a->extractTo(array()); -} catch (TypeError $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { $a->extractTo(''); -} catch (Exception $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } file_put_contents(__DIR__ . '/oops', 'I is file'); try { $a->extractTo(__DIR__ . '/oops', 'file1.txt'); -} catch (Exception $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { $a->extractTo(__DIR__ . '/oops1', array(array(), 'file1.txt')); -} catch (Exception $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { $a->extractTo(__DIR__ . '/extract', 'file1.txt'); -} catch (Exception $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } file_put_contents(__DIR__ . '/extract/file1.txt', 'first'); @@ -90,16 +90,16 @@ var_dump(file_get_contents(__DIR__ . '/extract/file1.txt')); try { $a->extractTo(str_repeat('a', 20000), 'file1.txt'); -} catch (Exception $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } $a[str_repeat('a', 20000)] = 'long'; try { $a->extractTo(__DIR__ . '/extract', str_repeat('a', 20000)); -} catch (Exception $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } ?> @@ -138,13 +138,13 @@ string(2) "hi" string(3) "hi3" string(3) "hi2" bool(false) -Phar::extractTo(): Argument #2 ($files) must be of type array|string|null, stdClass given -Phar::extractTo(): Argument #1 ($directory) must be of type string, array given -Invalid argument, extraction path must be non-zero length -Unable to use path "%soops" for extraction, it is a file, must be a directory -Invalid argument, array of filenames to extract contains non-string value -Extraction from phar "%stempmanifest1.phar.php" failed: Cannot extract "file1.txt" to "%sextract/file1.txt", path already exists +TypeError: Phar::extractTo(): Argument #2 ($files) must be of type array|string|null, stdClass given +TypeError: Phar::extractTo(): Argument #1 ($directory) must be of type string, array given +ValueError: Phar::extractTo(): Argument #1 ($directory) must not be empty +RuntimeException: Unable to use path "%soops" for extraction, it is a file, must be a directory +TypeError: Phar::extractTo(): Argument #2 ($files) must be an array of string elements, array given +PharException: Extraction from phar "%stempmanifest1.phar.php" failed: Cannot extract "file1.txt" to "%sextract%cfile1.txt", path already exists string(5) "first" string(2) "hi" -Cannot extract to "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...", destination directory is too long for filesystem -Extraction from phar "%stempmanifest1.phar.php" failed: Cannot extract "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa..." to "%s...", extracted filename is too long for filesystem +ValueError: Phar::extractTo(): Argument #1 ($directory) must be less than %d bytes +PharException: Extraction from phar "%stempmanifest1.phar.php" failed: Cannot extract "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa..." to "%s...", extracted filename is too long for filesystem diff --git a/ext/phar/tests/phar_offset_check.phpt b/ext/phar/tests/phar_offset_check.phpt index 5a039d2d8934..6b33cf4fcab0 100644 --- a/ext/phar/tests/phar_offset_check.phpt +++ b/ext/phar/tests/phar_offset_check.phpt @@ -19,44 +19,44 @@ $phar['b.txt'] = "second file\n"; try { $phar->offsetGet('.phar/stub.php'); -} catch (Exception $e) { - echo $e->getMessage()."\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { $phar->offsetGet('.phar/alias.txt'); -} catch (Exception $e) { - echo $e->getMessage()."\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { $phar->offsetSet('.phar/stub.php', ''); -} catch (Exception $e) { - echo $e->getMessage()."\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } var_dump(strlen($phar->getStub())); try { $phar->offsetUnset('.phar/stub.php'); -} catch (Exception $e) { - echo $e->getMessage()."\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } var_dump(strlen($phar->getStub())); try { $phar->offsetSet('.phar/alias.txt', 'dolly'); -} catch (Exception $e) { - echo $e->getMessage()."\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } var_dump($phar->getAlias()); try { $phar->offsetUnset('.phar/alias.txt'); -} catch (Exception $e) { - echo $e->getMessage()."\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } var_dump($phar->getAlias()); @@ -64,12 +64,12 @@ var_dump($phar->getAlias()); ?> --CLEAN-- ---EXPECTF-- -Entry .phar/stub.php does not exist -Entry .phar/alias.txt does not exist -Cannot set stub ".phar/stub.php" directly in phar "%sphar_offset_check.phar.php", use setStub +--EXPECT-- +BadMethodCallException: Entry .phar/stub.php does not exist +BadMethodCallException: Entry .phar/alias.txt does not exist +ValueError: Phar::offsetSet(): Argument #1 ($localName) must not be ".phar/stub.php", use Phar::setStub() instead int(6661) int(6661) -Cannot set alias ".phar/alias.txt" directly in phar "%sphar_offset_check.phar.php", use setAlias +ValueError: Phar::offsetSet(): Argument #1 ($localName) must not be ".phar/alias.txt", use Phar::setAlias() instead string(5) "susan" string(5) "susan" diff --git a/ext/phar/tests/phar_offset_get_error.phpt b/ext/phar/tests/phar_offset_get_error.phpt index b97971f8c3e5..da46088cef5d 100644 --- a/ext/phar/tests/phar_offset_get_error.phpt +++ b/ext/phar/tests/phar_offset_get_error.phpt @@ -16,33 +16,30 @@ $ename = '/error/..'; $p = new Phar($fname); $p[$iname] = "foobar\n"; -try -{ +try { $p[$ename] = "foobar\n"; -} -catch(Exception $e) -{ - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } include($pname . $iname); // extra coverage try { -$p['.phar/oops'] = 'hi'; -} catch (Exception $e) { -echo $e->getMessage(),"\n"; + $p['.phar/oops'] = 'hi'; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { -$a = $p['.phar/stub.php']; -} catch (Exception $e) { -echo $e->getMessage(),"\n"; + $a = $p['.phar/stub.php']; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } ?> --CLEAN-- --EXPECT-- -Entry /error/.. does not exist and cannot be created: phar error: invalid path "/error/.." contains upper directory reference +BadMethodCallException: Entry /error/.. does not exist and cannot be created: phar error: invalid path "/error/.." contains upper directory reference foobar -Cannot set any files or directories in magic ".phar" directory -Entry .phar/stub.php does not exist +ValueError: Phar::offsetSet(): Argument #1 ($localName) must not start with ".phar" +BadMethodCallException: Entry .phar/stub.php does not exist \ No newline at end of file diff --git a/ext/phar/tests/phar_oo_001.phpt b/ext/phar/tests/phar_oo_001.phpt index e30d112109f1..257a88e6a332 100644 --- a/ext/phar/tests/phar_oo_001.phpt +++ b/ext/phar/tests/phar_oo_001.phpt @@ -21,21 +21,17 @@ class MyPhar extends Phar } } -try -{ +try { $phar = new MyPhar(); var_dump($phar->getVersion()); -} -catch (LogicException $e) -{ - var_dump($e->getMessage()); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { $phar = new Phar('test.phar'); $phar->__construct('oops'); -} catch (LogicException $e) -{ - var_dump($e->getMessage()); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } ?> @@ -47,5 +43,5 @@ __halt_compiler(); --EXPECT-- string(5) "1.0.0" int(5) -string(50) "Cannot call method on an uninitialized Phar object" -string(29) "Cannot call constructor twice" +Error: Phar object is uninitialized +Error: Cannot call constructor twice diff --git a/ext/phar/tests/phar_oo_compressallgz.phpt b/ext/phar/tests/phar_oo_compressallgz.phpt index c0b8ea9da2d1..9e20b244baf8 100644 --- a/ext/phar/tests/phar_oo_compressallgz.phpt +++ b/ext/phar/tests/phar_oo_compressallgz.phpt @@ -39,10 +39,11 @@ var_dump($phar['b']->isCompressed(Phar::BZ2)); var_dump(file_get_contents($pname . '/c')); var_dump($phar['c']->isCompressed(Phar::GZ)); var_dump($phar['b']->isCompressed(Phar::BZ2)); + try { -$phar->compressFiles(25); -} catch (Exception $e) { -echo $e->getMessage() . "\n"; + $phar->compressFiles(25); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } ?> --CLEAN-- @@ -65,4 +66,4 @@ bool(false) string(1) "c" bool(true) bool(false) -Unknown compression specified, please pass one of Phar::GZ or Phar::BZ2 +ValueError: Phar::compressFiles(): Argument #2 must be one of Phar::GZ or Phar::BZ2 diff --git a/ext/phar/tests/phar_unlinkarchive.phpt b/ext/phar/tests/phar_unlinkarchive.phpt index c76669be17bd..6eb6b75f51dd 100644 --- a/ext/phar/tests/phar_unlinkarchive.phpt +++ b/ext/phar/tests/phar_unlinkarchive.phpt @@ -9,29 +9,29 @@ phar.readonly=0 getMessage(),"\n"; + Phar::unlinkArchive(""); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } $fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar'; $pdname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.tar'; try { -Phar::unlinkArchive($fname); -} catch (Exception $e) { -echo $e->getMessage(),"\n"; + Phar::unlinkArchive($fname); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } file_put_contents($pdname, 'blahblah'); try { -Phar::unlinkArchive($pdname); -} catch (Exception $e) { -echo $e->getMessage(),"\n"; + Phar::unlinkArchive($pdname); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { Phar::unlinkArchive(array()); -} catch (TypeError $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } $pname = 'phar://' . $fname; @@ -51,9 +51,9 @@ $phar = new Phar($fname); var_dump($phar->isFileFormat(Phar::ZIP)); var_dump($phar->getStub()); try { -Phar::unlinkArchive($fname); -} catch (Exception $e) { -echo $e->getMessage(),"\n"; + Phar::unlinkArchive($fname); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } $phar = $phar->convertToExecutable(Phar::ZIP); var_dump($phar->isFileFormat(Phar::ZIP)); @@ -71,8 +71,10 @@ $phar = new Phar($fname); var_dump(count($phar)); $phar['evil.php'] = 'getMessage(),"\n";} + Phar::unlinkArchive(Phar::running(false)); +} catch (Throwable $e) { + echo $e::class, ": ", $e->getMessage() . "\n"; +} var_dump(Phar::running(false)); include Phar::running(true) . "/another.php"; ?>'; @@ -89,13 +91,13 @@ unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); __HALT_COMPILER(); ?> --EXPECTF-- -Unknown phar archive "" -Unknown phar archive "%sphar_unlinkarchive.phar" -Unknown phar archive "%sphar_unlinkarchive.phar.tar": internal corruption of phar "%sphar_unlinkarchive.phar.tar" (truncated entry) -Phar::unlinkArchive(): Argument #1 ($filename) must be of type string, array given +ValueError: Phar::unlinkArchive(): Argument #1 ($filename) must not be empty +PharException: Unknown phar archive "%sphar_unlinkarchive.phar" +PharException: Unknown phar archive "%sphar_unlinkarchive.phar.tar": internal corruption of phar "%sphar_unlinkarchive.phar.tar" (truncated entry) +TypeError: Phar::unlinkArchive(): Argument #1 ($filename) must be of type string, array given bool(false) string(48) "" -phar archive "%sphar_unlinkarchive.phar" has open file handles or objects. fclose() all file handles, and unset() all objects prior to calling unlinkArchive() +PharException: phar archive "%sphar_unlinkarchive.phar" has open file handles or objects. fclose() all file handles, and unset() all objects prior to calling unlinkArchive() bool(true) string(60) "isCompressed(25); -} catch (Exception $e) { -echo $e->getMessage() . "\n"; + $b->isCompressed(25); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { -$b->compress(25); -} catch (Exception $e) { -echo $e->getMessage() . "\n"; + $b->compress(25); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } $tar = $phar->convertToData(Phar::TAR); $c = $tar['a/b']; try { -$c->compress(Phar::GZ); -} catch (Exception $e) { -echo $e->getMessage() . "\n"; + $c->compress(Phar::GZ); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { -$phar['a']->compress(Phar::GZ); -} catch (Exception $e) { -echo $e->getMessage() . "\n"; + $phar['a']->compress(Phar::GZ); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } ini_set('phar.readonly', 1); try { -$b->compress(Phar::GZ); -} catch (Exception $e) { -echo $e->getMessage() . "\n"; + $b->compress(Phar::GZ); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } ini_set('phar.readonly', 0); var_dump($b->compress(Phar::GZ)); @@ -56,15 +56,15 @@ echo "decompress\n"; ini_set('phar.readonly', 1); try { -$phar['a/b']->decompress(); -} catch (Exception $e) { -echo $e->getMessage() . "\n"; + $phar['a/b']->decompress(); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } ini_set('phar.readonly', 0); try { -$phar['a']->decompress(); -} catch (Exception $e) { -echo $e->getMessage() . "\n"; + $phar['a']->decompress(); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } var_dump($b->decompress()); var_dump($b->decompress()); @@ -74,17 +74,17 @@ var_dump($b->decompress()); --EXPECT-- -Unknown compression type specified -Unknown compression type specified -Cannot compress with Gzip compression, not possible with tar-based phar archives -Phar entry is a directory, cannot set compression -Phar is readonly, cannot change compression +ValueError: PharFileInfo::isCompressed(): Argument #1 ($compression) must be one of Phar::GZ or Phar::BZ2 +ValueError: PharFileInfo::compress(): Argument #1 ($compression) must be one of Phar::GZ or Phar::BZ2 +BadMethodCallException: Cannot compress with Gzip compression, not possible with tar-based phar archives +BadMethodCallException: Phar entry is a directory, cannot set compression +BadMethodCallException: Phar is readonly, cannot change compression bool(true) bool(true) bool(true) bool(true) decompress -Phar is readonly, cannot decompress -Phar entry is a directory, cannot set compression +BadMethodCallException: Phar is readonly, cannot decompress +BadMethodCallException: Phar entry is a directory, cannot set compression bool(true) bool(true) diff --git a/ext/phar/tests/pharfileinfo_construct.phpt b/ext/phar/tests/pharfileinfo_construct.phpt index 4839b8ebf8b4..dbb9a8d1d8c9 100644 --- a/ext/phar/tests/pharfileinfo_construct.phpt +++ b/ext/phar/tests/pharfileinfo_construct.phpt @@ -10,17 +10,17 @@ $fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar'; $pname = 'phar://' . $fname; try { -file_put_contents($fname, 'blah'); -$a = new PharFileInfo($pname . '/oops'); -} catch (Exception $e) { -echo $e->getMessage() . "\n"; -unlink($fname); + file_put_contents($fname, 'blah'); + $a = new PharFileInfo($pname . '/oops'); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; + unlink($fname); } try { -$a = new PharFileInfo(array()); -} catch (TypeError $e) { -echo $e->getMessage() . "\n"; + $a = new PharFileInfo(array()); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } $a = new Phar($fname); @@ -28,28 +28,29 @@ $a['a'] = 'hi'; $b = $a['a']; try { -$a = new PharFileInfo($pname . '/oops/I/do/not/exist'); -} catch (Exception $e) { -echo $e->getMessage() . "\n"; + $a = new PharFileInfo($pname . '/oops/I/do/not/exist'); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { -$b->__construct('oops'); -} catch (Exception $e) { -echo $e->getMessage() . "\n"; + $b->__construct('oops'); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { -$a = new PharFileInfo(__FILE__); -} catch (Exception $e) { -echo $e->getMessage() . "\n"; + $a = new PharFileInfo(__FILE__); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } ?> --CLEAN-- --EXPECTF-- -Cannot open phar file 'phar://%spharfileinfo_construct.phar/oops': internal corruption of phar "%spharfileinfo_construct.phar" (truncated entry) -PharFileInfo::__construct(): Argument #1 ($filename) must be of type string, array given -Cannot access phar file entry '%s' in archive '%s' -Cannot call constructor twice -'%s' is not a valid phar archive URL (must have at least phar://filename.phar) + +RuntimeException: Cannot open phar file 'phar://%spharfileinfo_construct.phar/oops': internal corruption of phar "%spharfileinfo_construct.phar" (truncated entry) +TypeError: PharFileInfo::__construct(): Argument #1 ($filename) must be of type string, array given +RuntimeException: Cannot access phar file entry '/oops/I/do/not/exist' in archive '%s' +Error: Cannot call constructor twice +RuntimeException: '%s' is not a valid phar archive URL (must have at least phar://filename.phar) diff --git a/ext/phar/tests/tar/frontcontroller12.phar.phpt b/ext/phar/tests/tar/frontcontroller12.phar.phpt index d72a23a552a2..f55a65e9b7f5 100644 --- a/ext/phar/tests/tar/frontcontroller12.phar.phpt +++ b/ext/phar/tests/tar/frontcontroller12.phar.phpt @@ -13,7 +13,7 @@ files/frontcontroller6.phar.tar --EXPECTHEADERS-- Content-type: text/html; charset=UTF-8 --EXPECTF-- -Fatal error: Uncaught PharException: Unknown mime type specifier used, only Phar::PHP, Phar::PHPS and a mime type string are allowed in %sfrontcontroller12.phar.php:2 +Fatal error: Uncaught ValueError: Phar::webPhar(): Argument #4 ($mimeTypes) mime type specifier must be one of Phar::PHP or Phar::PHPS in %sfrontcontroller12.phar.php:2 Stack trace: #0 %sfrontcontroller12.phar.php(2): Phar::webPhar('whatever', 'index.php', NULL, Array) #1 {main} diff --git a/ext/phar/tests/tar/frontcontroller13.phar.phpt b/ext/phar/tests/tar/frontcontroller13.phar.phpt index a5e517946e09..6cbbb6a55af5 100644 --- a/ext/phar/tests/tar/frontcontroller13.phar.phpt +++ b/ext/phar/tests/tar/frontcontroller13.phar.phpt @@ -13,7 +13,7 @@ files/frontcontroller7.phar.tar --EXPECTHEADERS-- Content-type: text/html; charset=UTF-8 --EXPECTF-- -Fatal error: Uncaught PharException: Unknown mime type specifier used (not a string or int), only Phar::PHP, Phar::PHPS and a mime type string are allowed in %sfrontcontroller13.phar.php:2 +Fatal error: Uncaught TypeError: Phar::webPhar(): Argument #4 ($mimeTypes) mime type specifier must be of type string|int, null given in %sfrontcontroller13.phar.php:2 Stack trace: #0 %sfrontcontroller13.phar.php(2): Phar::webPhar('whatever', 'index.php', NULL, Array) #1 {main} diff --git a/ext/phar/tests/tar/frontcontroller18.phar.phpt b/ext/phar/tests/tar/frontcontroller18.phar.phpt index a5aa9381218a..8e014730f658 100644 --- a/ext/phar/tests/tar/frontcontroller18.phar.phpt +++ b/ext/phar/tests/tar/frontcontroller18.phar.phpt @@ -9,7 +9,7 @@ PATH_INFO=/fronk.gronk --FILE_EXTERNAL-- files/frontcontroller9.phar.tar --EXPECTF-- -Fatal error: Uncaught PharException: No values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME in %sfrontcontroller18.phar.php:2 +Fatal error: Uncaught ValueError: Phar::mungServer(): Argument #1 ($variables) must not be empty in %sfrontcontroller18.phar.php:2 Stack trace: #0 %sfrontcontroller18.phar.php(2): Phar::mungServer(Array) #1 {main} diff --git a/ext/phar/tests/tar/frontcontroller19.phar.phpt b/ext/phar/tests/tar/frontcontroller19.phar.phpt index 90b8bf0b2d4b..64b72d411044 100644 --- a/ext/phar/tests/tar/frontcontroller19.phar.phpt +++ b/ext/phar/tests/tar/frontcontroller19.phar.phpt @@ -9,7 +9,7 @@ PATH_INFO=/ --FILE_EXTERNAL-- files/frontcontroller10.phar.tar --EXPECTF-- -Fatal error: Uncaught PharException: Too many values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME in %sfrontcontroller19.phar.php:2 +Fatal error: Uncaught ValueError: Phar::mungServer(): Argument #1 ($variables) must have at most 4 elements in %sfrontcontroller19.phar.php:2 Stack trace: #0 %sfrontcontroller19.phar.php(2): Phar::mungServer(Array) #1 {main} diff --git a/ext/phar/tests/tar/frontcontroller20.phar.phpt b/ext/phar/tests/tar/frontcontroller20.phar.phpt index 6f4616cafcfb..d7a0bb2f5db2 100644 --- a/ext/phar/tests/tar/frontcontroller20.phar.phpt +++ b/ext/phar/tests/tar/frontcontroller20.phar.phpt @@ -9,7 +9,7 @@ PATH_INFO=/ --FILE_EXTERNAL-- files/frontcontroller11.phar.tar --EXPECTF-- -Fatal error: Uncaught PharException: Non-string value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME in %sfrontcontroller20.phar.php:2 +Fatal error: Uncaught TypeError: Phar::mungServer(): Argument #1 ($variables) must be an array of string types, array given in %sfrontcontroller20.phar.php:2 Stack trace: #0 %sfrontcontroller20.phar.php(2): Phar::mungServer(Array) #1 {main} diff --git a/ext/phar/tests/tar/phar_buildfromiterator5.phpt b/ext/phar/tests/tar/phar_buildfromiterator5.phpt index 6a81c1df65d2..de163b31b994 100644 --- a/ext/phar/tests/tar/phar_buildfromiterator5.phpt +++ b/ext/phar/tests/tar/phar_buildfromiterator5.phpt @@ -39,14 +39,12 @@ try { chdir(__DIR__); $phar = new Phar(__DIR__ . '/buildfromiterator.phar.tar'); var_dump($phar->buildFromIterator(new myIterator(array('a' => new stdClass)))); -} catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } ?> ---EXPECTF-- +--EXPECT-- rewind valid current -%s(24) "UnexpectedValueException" -Iterator myIterator returned an invalid value (must return a string, a stream, or an SplFileInfo object) +TypeError: Iterator myIterator return value must be of type string|object|resource, stdClass returned diff --git a/ext/phar/tests/tar/phar_buildfromiterator6.phpt b/ext/phar/tests/tar/phar_buildfromiterator6.phpt index 918203697998..3dbe7264d388 100644 --- a/ext/phar/tests/tar/phar_buildfromiterator6.phpt +++ b/ext/phar/tests/tar/phar_buildfromiterator6.phpt @@ -39,15 +39,13 @@ try { chdir(__DIR__); $phar = new Phar(__DIR__ . '/buildfromiterator.phar.tar'); var_dump($phar->buildFromIterator(new myIterator(array(basename(__FILE__, 'php') . 'phpt')))); -} catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } ?> ---EXPECTF-- +--EXPECT-- rewind valid current key -%s(24) "UnexpectedValueException" -Iterator myIterator returned an invalid key (must return a string) +TypeError: Iterator myIterator must return a key of type string, int returned diff --git a/ext/phar/tests/tar/phar_setdefaultstub.phpt b/ext/phar/tests/tar/phar_setdefaultstub.phpt index ffb1887c2339..8e3bedf9c54c 100644 --- a/ext/phar/tests/tar/phar_setdefaultstub.phpt +++ b/ext/phar/tests/tar/phar_setdefaultstub.phpt @@ -22,8 +22,8 @@ echo "========================================================================== try { $phar->setDefaultStub(); $phar->stopBuffering(); -} catch(Exception $e) { - echo $e->getMessage(). "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } var_dump($phar->getStub()); @@ -33,14 +33,14 @@ echo "========================================================================== try { $phar->setDefaultStub('my/custom/thingy.php'); -} catch(ValueError $e) { - echo $e->getMessage(). "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { $phar->stopBuffering(); -} catch(Exception $e) { - echo $e->getMessage(). "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } var_dump($phar->getStub()); @@ -50,14 +50,14 @@ echo "========================================================================== try { $phar->setDefaultStub('my/custom/thingy.php', 'the/web.php'); -} catch(ValueError $e) { - echo $e->getMessage(). "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { $phar->stopBuffering(); -} catch(Exception $e) { - echo $e->getMessage(). "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } var_dump($phar->getStub()); @@ -76,11 +76,11 @@ string(60) "getAlias()); // check that alias can't be set manually try { $phar['.phar/alias.txt'] = 'pinocchio'; -} catch (Exception $e) { - echo $e->getMessage()."\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } var_dump($phar->getAlias()); @@ -53,6 +53,6 @@ string(%d) "%sgetalias.phar.zip" string(%d) "%sgetalias.phar.zip" string(13) "jiminycricket" string(13) "jiminycricket" -Cannot set alias ".phar/alias.txt" directly in phar "%sgetalias.phar.zip", use setAlias +ValueError: Phar::offsetSet(): Argument #1 ($localName) must not be ".phar/alias.txt", use Phar::setAlias() instead string(13) "jiminycricket" string(9) "pinocchio" diff --git a/ext/phar/tests/zip/phar_buildfromiterator5.phpt b/ext/phar/tests/zip/phar_buildfromiterator5.phpt index 3c587dfc9c87..acc72e3b703f 100644 --- a/ext/phar/tests/zip/phar_buildfromiterator5.phpt +++ b/ext/phar/tests/zip/phar_buildfromiterator5.phpt @@ -39,14 +39,12 @@ try { chdir(__DIR__); $phar = new Phar(__DIR__ . '/buildfromiterator.phar.zip'); var_dump($phar->buildFromIterator(new myIterator(array('a' => new stdClass)))); -} catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } ?> ---EXPECTF-- +--EXPECT-- rewind valid current -%s(24) "UnexpectedValueException" -Iterator myIterator returned an invalid value (must return a string, a stream, or an SplFileInfo object) +TypeError: Iterator myIterator return value must be of type string|object|resource, stdClass returned diff --git a/ext/phar/tests/zip/phar_buildfromiterator6.phpt b/ext/phar/tests/zip/phar_buildfromiterator6.phpt index 9d9140bc3433..a7508be7cb8a 100644 --- a/ext/phar/tests/zip/phar_buildfromiterator6.phpt +++ b/ext/phar/tests/zip/phar_buildfromiterator6.phpt @@ -39,15 +39,13 @@ try { chdir(__DIR__); $phar = new Phar(__DIR__ . '/buildfromiterator.phar.zip'); var_dump($phar->buildFromIterator(new myIterator(array(basename(__FILE__, 'php') . 'phpt')))); -} catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } ?> ---EXPECTF-- +--EXPECT-- rewind valid current key -%s(24) "UnexpectedValueException" -Iterator myIterator returned an invalid key (must return a string) +TypeError: Iterator myIterator must return a key of type string, int returned diff --git a/ext/phar/tests/zip/phar_setdefaultstub.phpt b/ext/phar/tests/zip/phar_setdefaultstub.phpt index e979b59b1a4a..47423ef04406 100644 --- a/ext/phar/tests/zip/phar_setdefaultstub.phpt +++ b/ext/phar/tests/zip/phar_setdefaultstub.phpt @@ -22,8 +22,8 @@ echo "========================================================================== try { $phar->setDefaultStub(); $phar->stopBuffering(); -} catch(Exception $e) { - echo $e->getMessage(). "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } var_dump($phar->getStub()); @@ -33,14 +33,14 @@ echo "========================================================================== try { $phar->setDefaultStub('my/custom/thingy.php'); -} catch(Error $e) { - echo $e->getMessage(). "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { $phar->stopBuffering(); -} catch(Exception $e) { - echo $e->getMessage(). "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } var_dump($phar->getStub()); @@ -50,14 +50,14 @@ echo "========================================================================== try { $phar->setDefaultStub('my/custom/thingy.php', 'the/web.php'); -} catch(ValueError $e) { - echo $e->getMessage(). "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } try { $phar->stopBuffering(); -} catch(Exception $e) { - echo $e->getMessage(). "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } var_dump($phar->getStub()); @@ -76,11 +76,11 @@ string(60) "