Open
Conversation
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
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
iluuu1994
reviewed
Apr 17, 2026
| 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)); |
Member
There was a problem hiding this comment.
To be pedantic, array of strings? It doesn't contain types.
|
|
||
| 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"); |
Member
There was a problem hiding this comment.
This one seems a bit unnecessary. I think type errors mostly apply to signatures, whereas this is a logical issue.
| 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); |
|
|
||
| php_stream_close(fp); | ||
| if (files_ht && UNEXPECTED(zend_hash_num_elements(files_ht) == 0)) { | ||
| zend_argument_must_not_be_empty_error(2); |
| /* 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); |
Member
There was a problem hiding this comment.
Maybe "opened" instead of "found", but I don't know all the reasons for which this can fail.
| 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)); |
Member
There was a problem hiding this comment.
Inconsistent with the above, maybe just "array of strings".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
We also fix some of the phar test stubs. Which we regenerate by running the
.phar.incfile.