diff options
author | Máté Kocsis <kocsismate@woohoolabs.com> | 2020-08-07 16:48:39 +0200 |
---|---|---|
committer | Máté Kocsis <kocsismate@woohoolabs.com> | 2020-08-07 16:48:45 +0200 |
commit | 046cc5e4c213b836546689d5bdc8925f057c24b5 (patch) | |
tree | 2fc60163e4d8a588203483ad3094d339fe246799 /ext/phar | |
parent | 7b9f37c3893a9a1c942a04a09c9e6b172c4af80b (diff) | |
download | php-git-046cc5e4c213b836546689d5bdc8925f057c24b5.tar.gz |
Add another round of missing parameter types to stubs
Closes GH-5950
Diffstat (limited to 'ext/phar')
-rw-r--r-- | ext/phar/phar_object.c | 225 | ||||
-rw-r--r-- | ext/phar/phar_object.stub.php | 18 | ||||
-rw-r--r-- | ext/phar/phar_object_arginfo.h | 16 | ||||
-rw-r--r-- | ext/phar/tests/cache_list/files/frontcontroller16.phar.inc | 2 | ||||
-rw-r--r-- | ext/phar/tests/cache_list/frontcontroller31.phpt | 8 | ||||
-rw-r--r-- | ext/phar/tests/files/frontcontroller16.phar.inc | 2 | ||||
-rw-r--r-- | ext/phar/tests/frontcontroller31.phpt | 8 | ||||
-rw-r--r-- | ext/phar/tests/phar_buildfromiterator1.phpt | 3 | ||||
-rw-r--r-- | ext/phar/tests/phar_extract.phpt | 6 |
9 files changed, 139 insertions, 149 deletions
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index c72fecc6e3..97be3e900c 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -537,7 +537,9 @@ finish: ; */ PHP_METHOD(Phar, webPhar) { - zval *mimeoverride = NULL, *rewrite = NULL; + zval *mimeoverride = NULL; + zend_fcall_info rewrite_fci = {0}; + zend_fcall_info_cache rewrite_fcc; char *alias = NULL, *error, *index_php = NULL, *f404 = NULL, *ru = NULL; size_t alias_len = 0, f404_len = 0, free_pathinfo = 0; size_t ru_len = 0; @@ -550,7 +552,7 @@ PHP_METHOD(Phar, webPhar) phar_entry_info *info = NULL; size_t sapi_mod_name_len = strlen(sapi_module.name); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s!saz", &alias, &alias_len, &index_php, &index_php_len, &f404, &f404_len, &mimeoverride, &rewrite) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s!saf!", &alias, &alias_len, &index_php, &index_php_len, &f404, &f404_len, &mimeoverride, &rewrite_fci, &rewrite_fcc) == FAILURE) { RETURN_THROWS(); } @@ -668,38 +670,23 @@ PHP_METHOD(Phar, webPhar) not_cgi = 1; } - if (rewrite) { - zend_fcall_info fci; - zend_fcall_info_cache fcc; + if (ZEND_FCI_INITIALIZED(rewrite_fci)) { zval params, retval; ZVAL_STRINGL(¶ms, entry, entry_len); - if (FAILURE == zend_fcall_info_init(rewrite, 0, &fci, &fcc, NULL, NULL)) { - zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: invalid rewrite callback"); + rewrite_fci.param_count = 1; + rewrite_fci.params = ¶ms; + rewrite_fci.retval = &retval; -cleanup_fail: - zval_ptr_dtor(¶ms); - if (free_pathinfo) { - efree(path_info); - } - efree(entry); - efree(pt); - RETURN_THROWS(); - } - - fci.param_count = 1; - fci.params = ¶ms; - fci.retval = &retval; - - if (FAILURE == zend_call_function(&fci, &fcc)) { + if (FAILURE == zend_call_function(&rewrite_fci, &rewrite_fcc)) { if (!EG(exception)) { zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: failed to call rewrite callback"); } goto cleanup_fail; } - if (Z_TYPE_P(fci.retval) == IS_UNDEF || Z_TYPE(retval) == IS_UNDEF) { + if (Z_TYPE_P(rewrite_fci.retval) == IS_UNDEF || Z_TYPE(retval) == IS_UNDEF) { zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: rewrite callback must return a string or false"); goto cleanup_fail; } @@ -707,8 +694,8 @@ cleanup_fail: switch (Z_TYPE(retval)) { case IS_STRING: efree(entry); - entry = estrndup(Z_STRVAL_P(fci.retval), Z_STRLEN_P(fci.retval)); - entry_len = Z_STRLEN_P(fci.retval); + entry = estrndup(Z_STRVAL_P(rewrite_fci.retval), Z_STRLEN_P(rewrite_fci.retval)); + entry_len = Z_STRLEN_P(rewrite_fci.retval); break; case IS_TRUE: case IS_FALSE: @@ -723,7 +710,15 @@ cleanup_fail: return; default: zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: rewrite callback must return a string or false"); - goto cleanup_fail; + +cleanup_fail: + zval_ptr_dtor(¶ms); + if (free_pathinfo) { + efree(path_info); + } + efree(entry); + efree(pt); + RETURN_THROWS(); } } @@ -2703,71 +2698,67 @@ PHP_METHOD(Phar, setAlias) RETURN_THROWS(); } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &alias, &alias_len) == SUCCESS) { - if (alias_len == phar_obj->archive->alias_len && memcmp(phar_obj->archive->alias, alias, alias_len) == 0) { - RETURN_TRUE; - } - if (alias_len && NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len))) { - spprintf(&error, 0, "alias \"%s\" is already used for archive \"%s\" and cannot be used for other archives", alias, fd_ptr->fname); - if (SUCCESS == phar_free_alias(fd_ptr, alias, alias_len)) { - efree(error); - goto valid_alias; - } - zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); + if (alias_len == phar_obj->archive->alias_len && memcmp(phar_obj->archive->alias, alias, alias_len) == 0) { + RETURN_TRUE; + } + if (alias_len && NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len))) { + spprintf(&error, 0, "alias \"%s\" is already used for archive \"%s\" and cannot be used for other archives", alias, fd_ptr->fname); + if (SUCCESS == phar_free_alias(fd_ptr, alias, alias_len)) { efree(error); - RETURN_THROWS(); - } - if (!phar_validate_alias(alias, alias_len)) { - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, - "Invalid alias \"%s\" specified for phar \"%s\"", alias, phar_obj->archive->fname); - RETURN_THROWS(); + goto valid_alias; } + zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); + efree(error); + RETURN_THROWS(); + } + if (!phar_validate_alias(alias, alias_len)) { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, + "Invalid alias \"%s\" specified for phar \"%s\"", alias, phar_obj->archive->fname); + RETURN_THROWS(); + } valid_alias: - if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) { - zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname); - RETURN_THROWS(); - } - if (phar_obj->archive->alias_len && NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_alias_map)), phar_obj->archive->alias, phar_obj->archive->alias_len))) { - zend_hash_str_del(&(PHAR_G(phar_alias_map)), phar_obj->archive->alias, phar_obj->archive->alias_len); - readd = 1; - } + if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) { + zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname); + RETURN_THROWS(); + } + if (phar_obj->archive->alias_len && NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_alias_map)), phar_obj->archive->alias, phar_obj->archive->alias_len))) { + zend_hash_str_del(&(PHAR_G(phar_alias_map)), phar_obj->archive->alias, phar_obj->archive->alias_len); + readd = 1; + } - oldalias = phar_obj->archive->alias; - oldalias_len = phar_obj->archive->alias_len; - old_temp = phar_obj->archive->is_temporary_alias; + oldalias = phar_obj->archive->alias; + oldalias_len = phar_obj->archive->alias_len; + old_temp = phar_obj->archive->is_temporary_alias; - if (alias_len) { - phar_obj->archive->alias = estrndup(alias, alias_len); - } else { - phar_obj->archive->alias = NULL; - } + if (alias_len) { + phar_obj->archive->alias = estrndup(alias, alias_len); + } else { + phar_obj->archive->alias = NULL; + } - phar_obj->archive->alias_len = alias_len; - phar_obj->archive->is_temporary_alias = 0; - phar_flush(phar_obj->archive, NULL, 0, 0, &error); + phar_obj->archive->alias_len = alias_len; + phar_obj->archive->is_temporary_alias = 0; + phar_flush(phar_obj->archive, NULL, 0, 0, &error); - if (error) { - phar_obj->archive->alias = oldalias; - phar_obj->archive->alias_len = oldalias_len; - phar_obj->archive->is_temporary_alias = old_temp; - zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); - if (readd) { - zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), oldalias, oldalias_len, phar_obj->archive); - } - efree(error); - RETURN_THROWS(); + if (error) { + phar_obj->archive->alias = oldalias; + phar_obj->archive->alias_len = oldalias_len; + phar_obj->archive->is_temporary_alias = old_temp; + zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); + if (readd) { + zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), oldalias, oldalias_len, phar_obj->archive); } + efree(error); + RETURN_THROWS(); + } - zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len, phar_obj->archive); - - if (oldalias) { - efree(oldalias); - } + zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len, phar_obj->archive); - RETURN_TRUE; + if (oldalias) { + efree(oldalias); } - RETURN_FALSE; + RETURN_TRUE; } /* }}} */ @@ -4305,19 +4296,22 @@ PHP_METHOD(Phar, extractTo) php_stream *fp; php_stream_statbuf ssb; char *pathto; - zend_string *filename; + zend_string *filename = NULL; size_t pathto_len; int ret; zval *zval_file; - zval *zval_files = NULL; + HashTable *files_ht = NULL; zend_bool overwrite = 0; char *error = NULL; - PHAR_ARCHIVE_OBJECT(); + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_PATH(pathto, pathto_len) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_ARRAY_HT_OR_NULL(filename, files_ht) + Z_PARAM_BOOL(overwrite) + ZEND_PARSE_PARAMETERS_END(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { - RETURN_THROWS(); - } + PHAR_ARCHIVE_OBJECT(); fp = php_stream_open_wrapper(phar_obj->archive->fname, "rb", IGNORE_URL|STREAM_MUST_SEEK, NULL); @@ -4356,47 +4350,32 @@ PHP_METHOD(Phar, extractTo) RETURN_THROWS(); } - if (zval_files) { - switch (Z_TYPE_P(zval_files)) { - case IS_NULL: - filename = NULL; - break; - case IS_STRING: - filename = Z_STR_P(zval_files); - break; - case IS_ARRAY: - if (zend_hash_num_elements(Z_ARRVAL_P(zval_files)) == 0) { - RETURN_FALSE; - } + if (files_ht) { + if (zend_hash_num_elements(files_ht) == 0) { + RETURN_FALSE; + } - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(zval_files), 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"); - RETURN_THROWS(); - } - switch (extract_helper(phar_obj->archive, Z_STR_P(zval_file), pathto, pathto_len, overwrite, &error)) { - case -1: - zend_throw_exception_ex(phar_ce_PharException, 0, "Extraction from phar \"%s\" failed: %s", - phar_obj->archive->fname, error); - efree(error); - RETURN_THROWS(); - case 0: - zend_throw_exception_ex(phar_ce_PharException, 0, - "phar error: attempted to extract non-existent file or directory \"%s\" from phar \"%s\"", - ZSTR_VAL(Z_STR_P(zval_file)), phar_obj->archive->fname); - RETURN_THROWS(); - } - } ZEND_HASH_FOREACH_END(); - RETURN_TRUE; - default: + 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, expected a filename (string) or array of filenames"); + "Invalid argument, array of filenames to extract contains non-string value"); RETURN_THROWS(); - } - } else { - filename = NULL; + } + switch (extract_helper(phar_obj->archive, Z_STR_P(zval_file), pathto, pathto_len, overwrite, &error)) { + case -1: + zend_throw_exception_ex(phar_ce_PharException, 0, "Extraction from phar \"%s\" failed: %s", + phar_obj->archive->fname, error); + efree(error); + RETURN_THROWS(); + case 0: + zend_throw_exception_ex(phar_ce_PharException, 0, + "phar error: attempted to extract non-existent file or directory \"%s\" from phar \"%s\"", + ZSTR_VAL(Z_STR_P(zval_file)), phar_obj->archive->fname); + RETURN_THROWS(); + } + } ZEND_HASH_FOREACH_END(); + RETURN_TRUE; } ret = extract_helper(phar_obj->archive, filename, pathto, pathto_len, overwrite, &error); diff --git a/ext/phar/phar_object.stub.php b/ext/phar/phar_object.stub.php index fe5fed1406..7f0eca1034 100644 --- a/ext/phar/phar_object.stub.php +++ b/ext/phar/phar_object.stub.php @@ -58,7 +58,7 @@ class Phar extends RecursiveDirectoryIterator implements Countable, ArrayAccess public function delMetadata() {} /** @return bool */ - public function extractTo(string $pathto, $files = null, bool $overwrite = false) {} + public function extractTo(string $pathto, array|string|null $files = null, bool $overwrite = false) {} /** @return string|null */ public function getAlias() {} @@ -140,7 +140,7 @@ class Phar extends RecursiveDirectoryIterator implements Countable, ArrayAccess * @param resource $newstub * @return bool */ - public function setStub($newstub, $maxlen = -1) {} + public function setStub($newstub, int $maxlen = -1) {} /** @return void */ public function startBuffering() {} @@ -180,13 +180,13 @@ class Phar extends RecursiveDirectoryIterator implements Countable, ArrayAccess final public static function webPhar( ?string $alias = null, ?string $index = null, string $f404 = UNKNOWN, - array $mimetypes = [], $rewrites = UNKNOWN): void {} + array $mimetypes = [], ?callable $rewrites = null): void {} } class PharData extends RecursiveDirectoryIterator implements Countable, ArrayAccess { /** @alias Phar::__construct */ - public function __construct(string $filename, int $flags = FilesystemIterator::SKIP_DOTS|FilesystemIterator::UNIX_PATHS, ?string $alias = null, $fileformat = 0) {} + public function __construct(string $filename, int $flags = FilesystemIterator::SKIP_DOTS|FilesystemIterator::UNIX_PATHS, ?string $alias = null, int $fileformat = 0) {} /** @alias Phar::__destruct */ public function __destruct() {} @@ -285,7 +285,7 @@ class PharData extends RecursiveDirectoryIterator implements Countable, ArrayAcc * @return bool * @alias Phar::extractTo */ - public function extractTo(string $pathto, $files = null, bool $overwrite = false) {} + public function extractTo(string $pathto, array|string|null $files = null, bool $overwrite = false) {} /** * @return string|null @@ -418,7 +418,7 @@ class PharData extends RecursiveDirectoryIterator implements Countable, ArrayAcc * @return bool * @alias Phar::setStub */ - public function setStub($newstub, $maxlen = -1) {} + public function setStub($newstub, int $maxlen = -1) {} /** * @return void @@ -479,7 +479,7 @@ class PharData extends RecursiveDirectoryIterator implements Countable, ArrayAcc /** @alias Phar::webPhar */ final public static function webPhar( ?string $alias = null, ?string $index = null, string $f404 = UNKNOWN, - array $mimetypes = [], $rewrites = UNKNOWN): void {} + array $mimetypes = [], ?callable $rewrites = null): void {} } class PharFileInfo extends SplFileInfo @@ -519,11 +519,11 @@ class PharFileInfo extends SplFileInfo public function hasMetadata() {} /** @return bool */ - public function isCompressed($compression_type = 9021976) {} + public function isCompressed(int $compression_type = 9021976) {} /** @return bool */ public function isCRCChecked() {} /** @return void */ - public function setMetadata($metadata) {} + public function setMetadata(mixed $metadata) {} } diff --git a/ext/phar/phar_object_arginfo.h b/ext/phar/phar_object_arginfo.h index a4b446d7c5..67b5ba5580 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 the .stub.php file instead. - * Stub hash: 586c79f097e9153b70f6c6e208daa08acc0ce1d4 */ + * Stub hash: f25efd47b496a7d06a30c77911a565a49e383bce */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar___construct, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) @@ -74,7 +74,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar_extractTo, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, pathto, IS_STRING, 0) - ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, files, "null") + 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") ZEND_END_ARG_INFO() @@ -139,7 +139,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar_setStub, 0, 0, 1) ZEND_ARG_INFO(0, newstub) - ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, maxlen, "-1") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, maxlen, IS_LONG, 0, "-1") ZEND_END_ARG_INFO() #define arginfo_class_Phar_startBuffering arginfo_class_Phar___destruct @@ -206,14 +206,14 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Phar_webPhar, 0, 0, IS_VOI ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, index, IS_STRING, 1, "null") ZEND_ARG_TYPE_INFO(0, f404, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mimetypes, IS_ARRAY, 0, "[]") - ZEND_ARG_INFO(0, rewrites) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, rewrites, IS_CALLABLE, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PharData___construct, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "FilesystemIterator::SKIP_DOTS | FilesystemIterator::UNIX_PATHS") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, alias, IS_STRING, 1, "null") - ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, fileformat, "0") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, fileformat, IS_LONG, 0, "0") ZEND_END_ARG_INFO() #define arginfo_class_PharData___destruct arginfo_class_Phar___destruct @@ -355,12 +355,14 @@ ZEND_END_ARG_INFO() #define arginfo_class_PharFileInfo_hasMetadata arginfo_class_Phar___destruct ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PharFileInfo_isCompressed, 0, 0, 0) - ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, compression_type, "9021976") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, compression_type, IS_LONG, 0, "9021976") ZEND_END_ARG_INFO() #define arginfo_class_PharFileInfo_isCRCChecked arginfo_class_Phar___destruct -#define arginfo_class_PharFileInfo_setMetadata arginfo_class_Phar_setMetadata +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PharFileInfo_setMetadata, 0, 0, 1) + ZEND_ARG_TYPE_INFO(0, metadata, IS_MIXED, 0) +ZEND_END_ARG_INFO() ZEND_METHOD(Phar, __construct); diff --git a/ext/phar/tests/cache_list/files/frontcontroller16.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller16.phar.inc index 3c9986da00..442f1fb18f 100644 --- a/ext/phar/tests/cache_list/files/frontcontroller16.phar.inc +++ b/ext/phar/tests/cache_list/files/frontcontroller16.phar.inc @@ -7,7 +7,7 @@ echo "hi"; $a->setStub('<?php try { Phar::webPhar("test.phar", "/index.php", null, array(), array("fail", "here")); -} catch (Exception $e) { +} catch (TypeError|Exception $e) { die($e->getMessage() . "\n"); } echo "oops did not run\n"; diff --git a/ext/phar/tests/cache_list/frontcontroller31.phpt b/ext/phar/tests/cache_list/frontcontroller31.phpt index 54128759f0..897272999c 100644 --- a/ext/phar/tests/cache_list/frontcontroller31.phpt +++ b/ext/phar/tests/cache_list/frontcontroller31.phpt @@ -12,5 +12,9 @@ REQUEST_URI=/frontcontroller31.php Content-type: text/html; charset=UTF-8 --FILE_EXTERNAL-- files/frontcontroller16.phar ---EXPECT-- -phar error: invalid rewrite callback +--EXPECTF-- +Fatal error: Uncaught TypeError: Phar::webPhar(): Argument #5 ($rewrites) 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', '', Array, Array) +#1 {main} + thrown in %s on line %d diff --git a/ext/phar/tests/files/frontcontroller16.phar.inc b/ext/phar/tests/files/frontcontroller16.phar.inc index 3c9986da00..442f1fb18f 100644 --- a/ext/phar/tests/files/frontcontroller16.phar.inc +++ b/ext/phar/tests/files/frontcontroller16.phar.inc @@ -7,7 +7,7 @@ echo "hi"; $a->setStub('<?php try { Phar::webPhar("test.phar", "/index.php", null, array(), array("fail", "here")); -} catch (Exception $e) { +} catch (TypeError|Exception $e) { die($e->getMessage() . "\n"); } echo "oops did not run\n"; diff --git a/ext/phar/tests/frontcontroller31.phpt b/ext/phar/tests/frontcontroller31.phpt index a02c937b58..0554180b86 100644 --- a/ext/phar/tests/frontcontroller31.phpt +++ b/ext/phar/tests/frontcontroller31.phpt @@ -11,5 +11,9 @@ REQUEST_URI=/frontcontroller31.php Content-type: text/html; charset=UTF-8 --FILE_EXTERNAL-- files/frontcontroller16.phar ---EXPECT-- -phar error: invalid rewrite callback +--EXPECTF-- +Fatal error: Uncaught TypeError: Phar::webPhar(): Argument #5 ($rewrites) 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', '', Array, Array) +#1 {main} + thrown in %s on line %d diff --git a/ext/phar/tests/phar_buildfromiterator1.phpt b/ext/phar/tests/phar_buildfromiterator1.phpt index aac85ff33e..c403e8c939 100644 --- a/ext/phar/tests/phar_buildfromiterator1.phpt +++ b/ext/phar/tests/phar_buildfromiterator1.phpt @@ -10,7 +10,8 @@ phar.readonly=0 $phar = new Phar(__DIR__ . '/buildfromiterator1.phar'); try { ini_set('phar.readonly', 1); - $phar->buildFromIterator(1); + + $phar->buildFromIterator(new ArrayIterator([])); } catch (Exception $e) { var_dump(get_class($e)); echo $e->getMessage() . "\n"; diff --git a/ext/phar/tests/phar_extract.phpt b/ext/phar/tests/phar_extract.phpt index bbe95dec0d..0ccd9d50d5 100644 --- a/ext/phar/tests/phar_extract.phpt +++ b/ext/phar/tests/phar_extract.phpt @@ -45,8 +45,8 @@ var_dump(file_get_contents(__DIR__ . '/extract1-2/file2.txt')); var_dump(is_dir(__DIR__ . '/extract1-2/one/level')); try { - $a->extractTo(__DIR__ . '/whatever', 134); -} catch (Exception $e) { + $a->extractTo(__DIR__ . '/whatever', new stdClass()); +} catch (TypeError $e) { echo $e->getMessage(), "\n"; } @@ -141,7 +141,7 @@ string(2) "hi" string(3) "hi3" string(3) "hi2" bool(false) -Invalid argument, expected a filename (string) or array of filenames +Phar::extractTo(): Argument #2 ($files) must be of type string|array|null, stdClass given Phar::extractTo(): Argument #1 ($pathto) must be a valid path, 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 |