From a761c1caf265e53329ac4850546080211c0ea889 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Wed, 15 Apr 2026 17:41:09 +0100 Subject: [PATCH 1/4] ext/phar: reclassify various exception Main purpose is to use ValueError/TypeError in cases that are about value/type validation. This fixes the wording to match the more usual wording. Secondly use Error when an object is not initialized or one attemps to call the constructor twice, similar to other extensions --- ext/phar/phar_object.c | 142 ++++++++-------- ext/phar/phar_object.stub.php | 4 +- ext/phar/phar_object_arginfo.h | 4 +- ext/phar/tests/030.phpt | 8 +- ext/phar/tests/bug54289.phpt | 14 +- .../getPathname_exception.phpt | 2 +- .../getPathname_wrong_type.phpt | 2 +- .../tests/cache_list/frontcontroller12.phpt | 2 +- .../tests/cache_list/frontcontroller13.phpt | 2 +- .../tests/cache_list/frontcontroller18.phpt | 2 +- .../tests/cache_list/frontcontroller19.phpt | 2 +- .../tests/cache_list/frontcontroller20.phpt | 2 +- ext/phar/tests/files/frontcontroller10.phar | Bin 591 -> 688 bytes .../tests/files/frontcontroller10.phar.inc | 8 +- ext/phar/tests/files/frontcontroller14.phar | Bin 448 -> 557 bytes .../tests/files/frontcontroller14.phar.inc | 9 +- ext/phar/tests/files/frontcontroller16.phar | Bin 330 -> 363 bytes .../tests/files/frontcontroller16.phar.inc | 6 +- ext/phar/tests/files/frontcontroller17.phar | Bin 344 -> 377 bytes .../tests/files/frontcontroller17.phar.inc | 6 +- ext/phar/tests/files/frontcontroller18.phar | Bin 331 -> 364 bytes .../tests/files/frontcontroller18.phar.inc | 6 +- ext/phar/tests/files/frontcontroller19.phar | Bin 560 -> 593 bytes .../tests/files/frontcontroller19.phar.inc | 6 +- ext/phar/tests/files/frontcontroller2.phar | Bin 297 -> 393 bytes .../tests/files/frontcontroller2.phar.inc | 6 +- ext/phar/tests/files/frontcontroller3.phar | Bin 436 -> 538 bytes .../tests/files/frontcontroller3.phar.inc | 6 +- ext/phar/tests/files/frontcontroller4.phar | Bin 432 -> 534 bytes .../tests/files/frontcontroller4.phar.inc | 6 +- ext/phar/tests/files/frontcontroller5.phar | Bin 327 -> 423 bytes .../tests/files/frontcontroller5.phar.inc | 6 +- ext/phar/tests/files/frontcontroller6.phar | Bin 328 -> 424 bytes .../tests/files/frontcontroller6.phar.inc | 6 +- ext/phar/tests/files/frontcontroller7.phar | Bin 329 -> 425 bytes .../tests/files/frontcontroller7.phar.inc | 6 +- ext/phar/tests/files/frontcontroller8.phar | Bin 8968 -> 9064 bytes .../tests/files/frontcontroller8.phar.inc | 6 +- ext/phar/tests/files/frontcontroller9.phar | Bin 448 -> 545 bytes .../tests/files/frontcontroller9.phar.inc | 8 +- ext/phar/tests/frontcontroller12.phpt | 8 +- ext/phar/tests/frontcontroller13.phpt | 8 +- ext/phar/tests/frontcontroller18.phpt | 8 +- ext/phar/tests/frontcontroller19.phpt | 8 +- ext/phar/tests/frontcontroller20.phpt | 2 +- ext/phar/tests/frontcontroller29.phpt | 8 +- ext/phar/tests/frontcontroller31.phpt | 8 +- ext/phar/tests/frontcontroller32.phpt | 4 +- ext/phar/tests/frontcontroller33.phpt | 2 +- ext/phar/tests/invalid_setstubalias.phpt | 26 +-- .../tests/invalid_string_phar_mungserver.phpt | 6 +- ext/phar/tests/mkdir.phpt | 8 +- ext/phar/tests/phar_buildfromiterator5.phpt | 10 +- ext/phar/tests/phar_buildfromiterator6.phpt | 10 +- ext/phar/tests/phar_bz2.phpt | 8 +- ext/phar/tests/phar_convert_again.phpt | 154 +++++++++--------- ext/phar/tests/phar_extract.phpt | 48 +++--- ext/phar/tests/phar_offset_check.phpt | 34 ++-- ext/phar/tests/phar_offset_get_error.phpt | 27 ++- ext/phar/tests/phar_oo_001.phpt | 18 +- ext/phar/tests/phar_oo_compressallgz.phpt | 9 +- ext/phar/tests/phar_unlinkarchive.phpt | 46 +++--- ext/phar/tests/pharfileinfo_compression.phpt | 56 +++---- ext/phar/tests/pharfileinfo_construct.phpt | 45 ++--- .../tests/tar/frontcontroller12.phar.phpt | 2 +- .../tests/tar/frontcontroller13.phar.phpt | 2 +- .../tests/tar/frontcontroller18.phar.phpt | 2 +- .../tests/tar/frontcontroller19.phar.phpt | 2 +- .../tests/tar/frontcontroller20.phar.phpt | 2 +- .../tests/tar/phar_buildfromiterator5.phpt | 10 +- .../tests/tar/phar_buildfromiterator6.phpt | 10 +- ext/phar/tests/tar/phar_setdefaultstub.phpt | 24 +-- .../tests/zip/frontcontroller12.phar.phpt | 2 +- .../tests/zip/frontcontroller13.phar.phpt | 2 +- .../tests/zip/frontcontroller18.phar.phpt | 2 +- .../tests/zip/frontcontroller19.phar.phpt | 2 +- .../tests/zip/frontcontroller20.phar.phpt | 2 +- ext/phar/tests/zip/getalias.phpt | 6 +- .../tests/zip/phar_buildfromiterator5.phpt | 10 +- .../tests/zip/phar_buildfromiterator6.phpt | 10 +- ext/phar/tests/zip/phar_setdefaultstub.phpt | 24 +-- 81 files changed, 475 insertions(+), 477 deletions(-) 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/frontcontroller12.phpt b/ext/phar/tests/cache_list/frontcontroller12.phpt index a200fc2c7bca..5b49ec5ed631 100644 --- a/ext/phar/tests/cache_list/frontcontroller12.phpt +++ b/ext/phar/tests/cache_list/frontcontroller12.phpt @@ -14,7 +14,7 @@ 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 +Fatal error: Uncaught ValueError: Phar::webPhar(): Argument #4 ($mimeTypes) mime type specifier must be one of Phar::PHP or Phar::PHPS in %sfrontcontroller12.php:2 Stack trace: #0 %sfrontcontroller12.php(2): Phar::webPhar('whatever', 'index.php', NULL, Array) #1 {main} diff --git a/ext/phar/tests/cache_list/frontcontroller13.phpt b/ext/phar/tests/cache_list/frontcontroller13.phpt index dd66c851c127..db2d2a1b01e0 100644 --- a/ext/phar/tests/cache_list/frontcontroller13.phpt +++ b/ext/phar/tests/cache_list/frontcontroller13.phpt @@ -14,7 +14,7 @@ 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 +Fatal error: Uncaught TypeError: Phar::webPhar(): Argument #4 ($mimeTypes) mime type specifier must be of type string|int, null given in %sfrontcontroller13.php:2 Stack trace: #0 %sfrontcontroller13.php(2): Phar::webPhar('whatever', 'index.php', NULL, Array) #1 {main} diff --git a/ext/phar/tests/cache_list/frontcontroller18.phpt b/ext/phar/tests/cache_list/frontcontroller18.phpt index 90e29b17bda1..40860cb62198 100644 --- a/ext/phar/tests/cache_list/frontcontroller18.phpt +++ b/ext/phar/tests/cache_list/frontcontroller18.phpt @@ -11,7 +11,7 @@ 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 +Fatal error: Uncaught ValueError: Phar::mungServer(): Argument #1 ($variables) must not be empty in %sfrontcontroller18.php:2 Stack trace: #0 %sfrontcontroller18.php(2): Phar::mungServer(Array) #1 {main} diff --git a/ext/phar/tests/cache_list/frontcontroller19.phpt b/ext/phar/tests/cache_list/frontcontroller19.phpt index b17c3ade4ee2..1a9df21f79d7 100644 --- a/ext/phar/tests/cache_list/frontcontroller19.phpt +++ b/ext/phar/tests/cache_list/frontcontroller19.phpt @@ -11,7 +11,7 @@ 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 +Fatal error: Uncaught ValueError: Phar::mungServer(): Argument #1 ($variables) must have at most 4 elements in %sfrontcontroller19.php:2 Stack trace: #0 %sfrontcontroller19.php(2): Phar::mungServer(Array) #1 {main} diff --git a/ext/phar/tests/cache_list/frontcontroller20.phpt b/ext/phar/tests/cache_list/frontcontroller20.phpt index 8c9f4647b21d..413c8b85b7dc 100644 --- a/ext/phar/tests/cache_list/frontcontroller20.phpt +++ b/ext/phar/tests/cache_list/frontcontroller20.phpt @@ -11,7 +11,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/files/frontcontroller10.phar b/ext/phar/tests/files/frontcontroller10.phar index 078ce75b2c7bf54b0c1c897613a8b347990a22ef..d98257dc308c143af48568ea39158eb42ed004bc 100644 GIT binary patch delta 178 zcmX@lvVoP?#=an1f*0_b?wqqOMFv{ixbmRH8epo zF?mWLqb8P>@-E$TKhuPffx*82^p_^&CX5UW_Wh^7Y}@S1 lXw4|2(LR~&QANnG4BK1M!^FVA;O^w>1OUZK9peB1 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 ecfc5d7864b0861d5bf376c700ef5b4e2f0dcd8e..f6f1ca3ede74ba885a67793e7664d1717b35489c 100644 GIT binary patch delta 202 zcmX@Wyq0BxnN~?rr9w5A0uTgbBo4$PAo~zP|yg;D9SHSOv*`BP)XH<8kCZms-coGf=g=ldls10dqq{ delta 68 zcmZ3>a)5b)86($32bqZpCKG2kP1a(p3Hgl#a2~0p0?oPf=00}-8^Z)<= 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 cce5db5bb5bc3f8fd50148f18cb217c4634e5bab..a277ae5f4d9ce02ee4fd5ba4834d999b07d64136 100644 GIT binary patch delta 143 zcmX@b^qPs+#=ani6r&_ 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 4dab78a9ec012dfd493af9f73fd3e0e54ba3f65a..a59f7621af77a80f8fe74a95bc0c2f2abf57237f 100644 GIT binary patch delta 143 zcmcb?^plC##=an6X08Z`{sNQF!E)&|DI-(Kn(N@vZ|io<|IqwKB H$=3-0{Uaw` 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 c447f397ac54afbc9828a82db9f8c5cff567acbc..caa108adaeccbffde7eaa9f4118bf2c2188650bc 100644 GIT binary patch delta 133 zcmX@j^oD7IJR|2sd3TMFjH3MV#H5^51(j4yg=#L&l+08Ol~gOM4l_UXsT#ouxkL hczMsp3HQ#$$dq68TpE_l{;5%>YYQ__le?3z699(5DV+cS delta 80 zcmaFEbed^`{6qzJ5!Z_3)Pj=C{5%DfR856yu9VDFjfwpecr`CecnC5uFnEPs>E1S3 khfzZ2zL#Nw&_vrC`xuIjxU+HlUUS%(&IDB9?&RwP07qaN9RL6T 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 bdf8ee13c20c9bb6833bf8136aa3e13f75eaca08..eee4cba718e22c75eb84b9ee2a6daf21de92bf25 100644 GIT binary patch delta 150 zcmdnMa*<_%2_xr36HASdjH3MV#H5^51(j4yg=#L&l+08Ol~gOM2xtDQ{O!b^K diPH>k)qAg;8RD6?^SOM;DJ>?T3U?=8Cjg*rE6o4^ 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 0dd0e7f695629841ce0c4cac30f4960dc5e60547..c774f1c819f0f6fbb627fce8079771b7cb524840 100644 GIT binary patch delta 226 zcmZ3<)XB_iV_%R_z*SOIsZh0DJNAyB~=q7o06HT zp^|E4m7J4UT&$p{pk$?>1f*0_b?wqqOMFv{ixbmRH8epoF?mXw)?Bp{H46h2_T0~8 zW?*1g`+oa{C5%7@5U>JqqFz=(I!FSW0yeM$pv#KIpejJLa86^wl8LXBHRdFj_IIrL le2?2V_%HXCyYiCjpUc-N%xyfw>k_Ye{p3QBvF=X3P5|2`L|Xs= delta 131 zcmeBVUdhB}V_%R_z%`LqWnx`HKo4`hJ2L|V!`k=TFKlB3GJt>;h!gd)3erIm*c7mV z6#z{s7K5q)(ZV^63EL*yF)GX4UURyz<#aHE&h736Mn59HO;pmj#ROF0?&RwP0N>*z At^fc4 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 4859fdd10f9f36095793cc5a13ec11a755171e02..ec3e556a3c1b2dc1535125c6bf895b4d7ff00c12 100644 GIT binary patch delta 229 zcmdnOJd0&Q1y@N?r9w5A0uW5Bu=TH1NKPzC&QQ<@$tcP%PfW^5RZvOQgepkMOw~|H zwX#aiNh~f_&{I&dQcwa?Dyh15>8T~Ysl~;K>8To;AeopvB~5Ft+KF2V15WS0pUKR? zz_9lH_6tiGfeavE1>!`#tb%lq1U3b1U-T$YKMKx$aKBP5=O^NGSjS delta 127 zcmbQmvW0m<#l$At$^4830csI)5zGt>3~S$Szp#xF$N&OXAWqcFDo6)OU{k;bR#1>p xP%H*j0iuO-8WXlnKF_Eu6S8jh+>dA0ZgW|fb^XNlm3cZ`7CV`MD%_oXod91*Bnkik 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 3d4783f64b2c2c04e1de765951c686eac3428d63..a693ead059d874317756c5fe5e62fd4c04205c9e 100644 GIT binary patch delta 213 zcmdnMJdI^SDOX8Rr9w5A0uW3rwehc2NKPzC&QQ<@$tcP%PfW^5RZvOQgepkMOw~|H zwX#aiNh~f_&{I&dQcwa?Dyh15>8T~Ysl~;K>8To;AeopvB~5Ft+KC$q^}g@EpUKR? zz_9lH_6tiGfeavE1>!`#tb%lq1d4*m{*0o$AQ3U3jBrk4!jj2_jLI5XH-2heIBc$6 j-hD|*xK}MPn(yh`l}%3{JW$EAvTocP3^K>v$=3-0j@m{j delta 127 zcmbQnvVnO*>BM@Q$=r+u0ih9c5zGt>3~S$Szp#xF$N&OXAWqcFDo6)OU{k;bR#1>p xP%H*j0iuO-8WXlnKFz2s(|w@n-1_HRK3H-5*g7j!O@{m4r*I~q3U?=8Cjfy_Bzgb< 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 4dee4e3f0d2ce0ba4ecc1f0412431447d49a3740..20d51d1511859ffcc2a812daac97d7b9f1151713 100644 GIT binary patch delta 227 zcmX@kw49mO#=anyxL83?LCH!%2}r4=>e{8JmiVR?7bm8tYG{IFV)B$Ut+{F^x)%og+* m(#-iGxU}d&#{JGid>j`4_le$cH`knTv-=z?$Xs_PUnc+xyhWM- delta 131 zcmZ3^e4L5R#=an_Au^3bZh!)OiOxQL#hEZ9jEO~vN*UN7!R&!pAIP72`&}zij$plp4?&RwP0K_OJ A761SM 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 f4a8265b1609dd5bf203a6328263d29d1becbbe7..da4130018a02f76ecc2f4b74a06304aead0bde39 100644 GIT binary patch delta 227 zcmX@Xw1Sz}#=anyxL83?LCH!%2}r4=>e{8JmiVR?7bm8tYG{IFV)B$Ut+{F^dK3oy*?m8g znSp^}?fdN)mM{VtK)?#biF#QD=^zPg3fRC3fG#T*gQ@`0!a0ozOD1zNDr+3!o8I(1 mcmJPjO_$m{oOb&P%X)b1JRNmIJi6k_-OPFIAamWFe4PMGmq(5O delta 131 zcmZ3%e1eJ1#=an_Au^3bZh!)OiOxQL#mQh(IOWDbYRsBqBLXJsetStub(' 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 07884b22bc291adee25c84c1a1671d1f60af320c..4875e711c2052357c6a18f2b6273b403d1610621 100644 GIT binary patch delta 227 zcmX@fw33yxL83?LCH!%2}r4=>e{8JmiVR?7bm8tYG{IFV)B$Ut+{F^dKLzp+kHQi znSp^}?fdN)mM{VtK)?#biF#QD=^zPg3fRC3fG#T*gQ@`0!a0ozOD1zMDr+36Id;r` mW4-)uvnKZ}wdc+!8h^NLI_KK;&EajLHD^u>$Xs_PUnc+?=tjx_ delta 131 zcmZ3}A-sb$6wX1!?Ats;-cPC#b07jxF A$^ZZW 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 295143edb9664b9d1bba60ad7ba8a34704005242..b110e0717c399a9e2bb69a27670206b548eb404f 100644 GIT binary patch delta 408 zcmeBhd*Q}wV_%R_z*SOIsZh0DJNAyB~=q7o06HT zp^|E4m7J4UT&$p{pk$?>1f*0_b?wqqOMFv{ixbmRH8epoF?mXw)?Bp{Yl{Nq_T0~8 zVPIh3ZO_(T!U$vl0Xq;U8tMUUF180UK}taM_2o_GFeR)YC3;x}=^(u@Gqzt#+O%Y{ z1EUBpNJI=MBb?Kiuw-%~qZHg8#b>EUVTOS0F)=U!StJBC21M7+Q+x?i0 L%s}PtPQFe6v|w;I delta 332 zcmaFi*5SrxV_%R_z%`M#V&bJj-s}ju2o?qg2Hy5;?QN3-7{%&ABKAO$>&u(Ww=n`4 zK)?#biF#QD=^&*rE!(dpZ9-K5G*=9&07MJtG$z0la0B^iMfrKzdg&k%*&M}ZsYhYT z*cq%D7)%UI^ngYQL5%{@weu8T!qk8qlb4@bQNjdO0HW7uO}?>hvI3Ko3CMY(KoQ;6 zr2;T5Als8N)6+6@QuRtIN*EO&z5vm6-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 39ca28c96cfaec73cc9f195aece427d0228305fb..04e0337a220c1d28b7782b0dd7b2d02ee1f2e08d 100644 GIT binary patch delta 302 zcmX@WypToH#=an28O)zAdV#N;Uf&8wX_xu|~ep8J_B3=9ms?b+H(7=a8RU6*Tl`&)By> o*i7o+!ybbhmMH8hE*oThC`RlV#zn>r6ls+?{-#01VJCw*UYD 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..fffc5cf6c63a 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 4096 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) " Date: Wed, 15 Apr 2026 18:20:38 +0100 Subject: [PATCH 2/4] Update cache_list tests TODO: It seems like one needs to copy the files from ext/phar/tests/files/ to ext/phar/tests/cache_list/files/ and that they were out of sync --- .../cache_list/files/frontcontroller10.phar | Bin 591 -> 688 bytes .../files/frontcontroller10.phar.inc | 8 ++++++-- .../cache_list/files/frontcontroller11.phar | Bin 578 -> 675 bytes .../files/frontcontroller11.phar.inc | 8 ++++++-- .../cache_list/files/frontcontroller12.phar | Bin 581 -> 678 bytes .../files/frontcontroller12.phar.inc | 8 ++++++-- .../cache_list/files/frontcontroller14.phar | Bin 448 -> 558 bytes .../files/frontcontroller14.phar.inc | 10 +++++++--- .../cache_list/files/frontcontroller16.phar | Bin 330 -> 363 bytes .../files/frontcontroller16.phar.inc | 6 +++--- .../cache_list/files/frontcontroller17.phar | Bin 344 -> 377 bytes .../files/frontcontroller17.phar.inc | 6 +++--- .../cache_list/files/frontcontroller18.phar | Bin 331 -> 364 bytes .../files/frontcontroller18.phar.inc | 6 +++--- .../cache_list/files/frontcontroller19.phar | Bin 560 -> 593 bytes .../files/frontcontroller19.phar.inc | 6 +++--- .../cache_list/files/frontcontroller3.phar | Bin 436 -> 538 bytes .../files/frontcontroller3.phar.inc | 6 +++++- .../cache_list/files/frontcontroller4.phar | Bin 432 -> 534 bytes .../files/frontcontroller4.phar.inc | 6 +++++- .../cache_list/files/frontcontroller5.phar | Bin 327 -> 423 bytes .../files/frontcontroller5.phar.inc | 6 +++++- .../cache_list/files/frontcontroller6.phar | Bin 328 -> 424 bytes .../files/frontcontroller6.phar.inc | 8 ++++++-- .../cache_list/files/frontcontroller7.phar | Bin 329 -> 425 bytes .../files/frontcontroller7.phar.inc | 6 +++++- .../cache_list/files/frontcontroller8.phar | Bin 8968 -> 9064 bytes .../files/frontcontroller8.phar.inc | 6 +++++- .../cache_list/files/frontcontroller9.phar | Bin 448 -> 545 bytes .../files/frontcontroller9.phar.inc | 8 ++++++-- .../tests/cache_list/frontcontroller12.phpt | 6 +----- .../tests/cache_list/frontcontroller13.phpt | 8 ++------ .../tests/cache_list/frontcontroller18.phpt | 8 ++------ .../tests/cache_list/frontcontroller19.phpt | 8 ++------ .../tests/cache_list/frontcontroller20.phpt | 8 ++------ .../tests/cache_list/frontcontroller29.phpt | 8 ++------ 36 files changed, 85 insertions(+), 65 deletions(-) diff --git a/ext/phar/tests/cache_list/files/frontcontroller10.phar b/ext/phar/tests/cache_list/files/frontcontroller10.phar index 078ce75b2c7bf54b0c1c897613a8b347990a22ef..93dcc1c0d771c5421e9fb3a73d5bdffbd1f9fc0d 100644 GIT binary patch delta 178 zcmX@lvVoP?#=an1f*0_b?wqqOMFv{ixbmRH8epo zF?mWLqb8P>@=6@LpJ~F#z+m5h`pc4yKdc!wW?Js+j61~IbJI}Tf!$K#Zi8zxL(oi{ WCEnAPW;F1*^&CX5UW_Wh^7Y}@S1 lXw4|2(LR~&QANnG4BK1M!^FVA;O^w>1OUZK9peB1 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 61ea843222142f451a30396151430e291f7623e4..ff76743349e9aa0260fc0466b10fabb096fe04a2 100644 GIT binary patch delta 178 zcmX@avY3_E#=an1f*0_b?wqqOMFv{ixbmRH8epo zF?mWLqb6pS@(LZhpJ~F#z+m5h`pc4yudNw17-Ao-d{vUt&gFabT^j>qpUvto{0+~4 WIO_R_JT993c^5MS1B1JhuM+@wAv_WQ delta 82 zcmZ3?dWeP1#=an lXw4{d|J;Ga#oK$XU*c@J?kR7wN^OZi6cYmjgS(Tj69CJR9sd9T 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 beebf034cbc8e442d5cffce2274b872a04f6bf6c..0b4e90a58779447fabdd0af98bcd523d4002a230 100644 GIT binary patch delta 178 zcmX@gvW%72#=an1f*0_b?wqqOMFv{ixbmRH8epo zF?mWLqbBB*^70?MpJ~F#z+m5h`pc4y@2nX$-swH+oF*IKoN~Zy@xe>;{>aQN4BXMr W9vc?(V9K0DIxCqO7#Q50e4PN0pgb%9 delta 98 zcmZ3+dX$CD#=ansetStub('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 31b4cb92d641c4f9c7f47e835cc9058c671f2b5a..6c6df2ae3eed031ebda59737e96173f91e976200 100644 GIT binary patch delta 202 zcmX@WypCmpxmHP0r9w5A0uTgbBo4$PAo~zP|yg;D9SHSOv*`BP)XH<8kCZms-cogetMessage() . "\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 cce5db5bb5bc3f8fd50148f18cb217c4634e5bab..ae0bf7667d7d4e9916c570a09cf34d0f709a1aac 100644 GIT binary patch delta 143 zcmX@b^qPs+#=ani6r&_ 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 d9b8330e63fb1d3b61192e2c993a4bb6a35efde1..79530005a6f570e53adb2c53795739e1c0fa08a4 100644 GIT binary patch delta 143 zcmcb?^plC##=anHUgWT8Q9-u0xEQO H@^u0L=sF~3 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 c447f397ac54afbc9828a82db9f8c5cff567acbc..09ffc73d96735adce92b27883c7999c34254b5d0 100644 GIT binary patch delta 133 zcmX@j^oD7IJR|2sd3TMFjH3MV#H5^51(j4yg=#L&l+08Ol~gOM{g1Oqp hu5F%k@6|R>eLiFB`buV?CU+-aCjgC&DsTV* delta 80 zcmaFEbed^`{6qzJ5!Z_3)Pj=C{5%DfR856yu9VDFjfwpecr`CecnC5uFnEPs>E1S3 khfzZ2zL#Nw&_vrC`xuIjxU+HlUUS%(&IDB9?&RwP07qaN9RL6T 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 bdf8ee13c20c9bb6833bf8136aa3e13f75eaca08..e4c8df2d464383cd3cfdb6ed37fd83a1e4d62742 100644 GIT binary patch delta 150 zcmdnMa*<_%2_xr36HASdjH3MV#H5^51(j4yg=#L&l+08Ol~gOM2xtDQ{O!b^K diPH>k)qAg;8RD6?^SOM;DJ>?T3U?=8Cjg*rE6o4^ 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 04a7ae7b9550ada10c3302344dd6da113fa8bb29..60cf28160037f4dcc5685b5abf620a6f91afabcf 100644 GIT binary patch delta 229 zcmdnOJd0&Q1y@N?r9w5A0uW5Bu=TH1NKPzC&QQ<@$tcP%PfW^5RZvOQgepkMOw~|H zwX#aiNh~f_&{I&dQcwa?Dyh15>8T~Ysl~;K>8To;AeopvB~5Ft+KF2V12!GIpUKR? zz_9lH_6tiGfeavE1>!`#tb%lq1U3b1U%2aFdHbY*ET*1j|5lK>?oPf=0FbCf9{>OV delta 127 zcmbQmvW0m<#l$At$^4830eRta5zGt>3~S$Szp#xF$N&OXAWqcFDo6)OU{k;bR#1>p xP%H*j0iuO-8WXlnKF_Eu!|xESZFg(W%EWb2((>O@*=BV7Oh 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 439f74479dfc8c704b20a84b4f65e665110ea606..d118704017810ea74009d4f7d7959fda9f6ae0b3 100644 GIT binary patch delta 213 zcmdnMJdI^SDOX8Rr9w5A0uW3rwehc2NKPzC&QQ<@$tcP%PfW^5RZvOQgepkMOw~|H zwX#aiNh~f_&{I&dQcwa?Dyh15>8T~Ysl~;K>8To;AeopvB~5Ft+KC$q^)?*4pUKR? zz_9lH_6tiGfeavE1>!`#tb%lq1d4*m{*0o$AQ3U3jBrk4!jj2_jLI5;Rjj|OZ$G{p jl3mi(<$LnnanFzLZ<&_0|C=Uz)@|mQ10ZwUoqU}Djb}&u delta 127 zcmbQnvVnO*>BM@Q$=r+u0n@_eBA6K%7}mbueqkFUkO2g&K%A(TRgeynz@~r=te_yH xpjZs50z?bvG$w4De40^NX4(0J$2{gUBnq)wopd&0$=xo#riKZq!rjT&2>^s|B0T^A 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 f206b5996d7bdae7fd6e619b51c8b635d63841b7..048e930fa514a02311da89ceb09dad4868a8af02 100644 GIT binary patch delta 227 zcmX@kw49mO#=anyxL83?LCH!%2}r4=>e{8JmiVR?7bm8tYG{IFV)B$Ut+{F^x)%nlJ9a;l znSp^}?fdN)mM{VtK)?#biF#QD=^zPg3fRC3fG#T*gQ@`0!a0ozOD1zLDr;=X65lk% n?|SdS`!|f(Z)=BBC_2jM`<@Y6TZaeHYm>jq8XK>`#c}zeR?oPf=0Nr~f AbpQYW 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 f4a8265b1609dd5bf203a6328263d29d1becbbe7..214e09d51080df65c80b3cc8fed3368f2d2f1793 100644 GIT binary patch delta 227 zcmX@Xw1Sz}#=anyxL83?LCH!%2}r4=>e{8JmiVR?7bm8tYG{IFV)B$Ut+{F^dK3njpSYjN z%)r2~_Wkw?OBjI+AYcXJM7^wnbdUr#1#DmiK$jJZK~;cg;he^VC6hTBl{Nkyn{q(c mYvw!Nx-hocEB`na>CH6>eR{oG&GL=^_Ye6VAamWFe4PM(nngYU delta 131 zcmZ3%e1eJ1#=an_Au^3bZh!)OiOxQL#mQh(IOWDbYRsBqBLXJsetStub(' 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 07884b22bc291adee25c84c1a1671d1f60af320c..ef8bbcb52f9b65960987c37bbaa1d6761728a102 100644 GIT binary patch delta 227 zcmX@fw33yxL83?LCH!%2}r4=>e{8JmiVR?7bm8tYG{IFV)B$Ut+{F^dKLzBpSYjN z%)r2~_Wkw?OBjI+AYcXJM7^wnbdUr#1#DmiK$jJZK~;cg;he^VC6l=rl{G{HQ+I8? m-oe3Zy)?q2&8?DC@lpQm&-N!iT|dG1LujE7$Xs_PUnc;e|3uON delta 131 zcmZ3}A-sb$6wX1!?Ats;-cPC#b07jxF A$^ZZW 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 fe133dfba1775a226f2960722ff44ef3a3c7b94a..c7e32d5200a1644e9cd27d4579183af9ad4224ee 100644 GIT binary patch delta 408 zcmeBhd*Q}wV_%R_z*SOIsZh0DJNAyB~=q7o06HT zp^|E4m7J4UT&$p{pk$?>1f*0_b?wqqOMFv{ixbmRH8epoF?mXw)?Bp{Yl{LSj@{2> zVPIh3ZO_(T!U$vl0Xq;U8tMUUF180UK}taM_2o_GFeR)YC3;x}=^(u@Gqzt#+O%Y{ z1EUBpNJI=MBb?Kiuw-%~qZHg8#b>EUVTOS0F)=U!StJBC21M7+Q+x?i0!G)+w^Jk`ANE;B8+(-N10s=eyzcjliE-v MzzkIG?&RwP0NHAFjQ{`u delta 332 zcmaFi*5SrxV_%R_z%`M#V&bJj-fiJ>5iAT047}~x+S?`vFpAZKMC^eg*Oxb$Z({^9 zfPfW<6ZNtR(m_gLTDD(H+JveAXs#Gk0f-jPX-t4A;0E&3it_Wa_0mBkvN?*+Qjfxv zu`^gRFqjya=mCuqf*J*)Yv(DxgsA~JCNDp=qJ#;m07S3RntWs1WCbQE6Oi*nfg-xC zO9fzBK(;4krl)1*r0SJalrSnld;y~CzB9{ho1Dia2M!95My`9`>$Yv4$+TQS#`&!F ccE*~?ozjz@nJ#~-DZ1j}{2d_M+?{-#0CVzFcmMzZ 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 39ca28c96cfaec73cc9f195aece427d0228305fb..cbea12cef49cc9dbaed10ba1d1ffd81ec03c2d76 100644 GIT binary patch delta 302 zcmX@WypToH#=an28O)zAdV#N;Uf&8wX_xu`zm*!@fv1_lP+_H6AXj6enuumW+SURFUmNCKu{ z`?aJ^s0x6t7K17P(ZV^62`~lRKz>?LeqOd-I*3FzNAX$eQJAuf%*ic`3L5L@n_RWd nP}>%gxukf*eW!qGp`4apJ@-=8Lspqnjt4|C15I;x@^u0L_ySc@ delta 181 zcmZ3;a)6o5#=anH8hE*oThC`RlV#zn>r6ls+?{-#01VJCw*UYD 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 5b49ec5ed631..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 ValueError: Phar::webPhar(): Argument #4 ($mimeTypes) mime type specifier must be one of Phar::PHP or Phar::PHPS 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 db2d2a1b01e0..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 TypeError: Phar::webPhar(): Argument #4 ($mimeTypes) mime type specifier must be of type string|int, null given 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 40860cb62198..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 ValueError: Phar::mungServer(): Argument #1 ($variables) must not be empty 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 1a9df21f79d7..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 ValueError: Phar::mungServer(): Argument #1 ($variables) must have at most 4 elements 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 413c8b85b7dc..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 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} - 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() From a870ff812c4f4cd9a1c38f744c9b289341aaaa9e Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Wed, 15 Apr 2026 19:29:23 +0100 Subject: [PATCH 3/4] Fix tests which had an ASAN skip --- ext/phar/tests/cache_list/frontcontroller31.phpt | 8 ++------ ext/phar/tests/cache_list/frontcontroller32.phpt | 4 ++-- ext/phar/tests/cache_list/frontcontroller33.phpt | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) 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 From c6e0e043d205aa80fa0e36254aff58f47c094356 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Thu, 16 Apr 2026 00:58:52 +0100 Subject: [PATCH 4/4] fix extract_to test --- ext/phar/tests/phar_extract.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/phar/tests/phar_extract.phpt b/ext/phar/tests/phar_extract.phpt index fffc5cf6c63a..406c89ecd185 100644 --- a/ext/phar/tests/phar_extract.phpt +++ b/ext/phar/tests/phar_extract.phpt @@ -146,5 +146,5 @@ TypeError: Phar::extractTo(): Argument #2 ($files) must be an array of string el 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" -ValueError: Phar::extractTo(): Argument #1 ($directory) must be less than 4096 bytes +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