Skip to content

Commit 011c4d0

Browse files
committed
Address review comments
1 parent e7164af commit 011c4d0

File tree

9 files changed

+16
-17
lines changed

9 files changed

+16
-17
lines changed

ext/phar/phar_object.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ PHP_METHOD(Phar, mungServer)
871871
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(mungvalues), data) {
872872
ZVAL_DEREF(data);
873873
if (Z_TYPE_P(data) != IS_STRING) {
874-
zend_argument_type_error(1, "must be an array of string types, %s given", zend_zval_value_name(data));
874+
zend_argument_type_error(1, "must be an array of strings, %s given", zend_zval_value_name(data));
875875
RETURN_THROWS();
876876
}
877877

@@ -2919,7 +2919,7 @@ PHP_METHOD(Phar, setDefaultStub)
29192919
}
29202920

29212921
if ((index || webindex) && (phar_obj->archive->is_tar || phar_obj->archive->is_zip)) {
2922-
zend_argument_type_error(index ? 1 : 2, "must be null for a tar- or zip-based phar stub, string given");
2922+
zend_argument_value_error(index ? 1 : 2, "must be null for a tar- or zip-based phar stub, string given");
29232923
RETURN_THROWS();
29242924
}
29252925

@@ -4294,10 +4294,9 @@ PHP_METHOD(Phar, extractTo)
42944294
RETURN_THROWS();
42954295
}
42964296

4297-
if (files_ht && UNEXPECTED(zend_hash_num_elements(files_ht) == 0)) {
4298-
zend_argument_must_not_be_empty_error(2);
4299-
} else if (filename && UNEXPECTED(ZSTR_LEN(filename) == 0)) {
4297+
if (UNEXPECTED((files_ht && zend_hash_num_elements(files_ht) == 0) || (filename && ZSTR_LEN(filename) == 0))) {
43004298
zend_argument_must_not_be_empty_error(2);
4299+
RETURN_THROWS();
43014300
}
43024301

43034302
fp = php_stream_open_wrapper(phar_obj->archive->fname, "rb", IGNORE_URL|STREAM_MUST_SEEK, NULL);
@@ -4328,7 +4327,7 @@ PHP_METHOD(Phar, extractTo)
43284327
ZEND_HASH_FOREACH_VAL(files_ht, zval_file) {
43294328
ZVAL_DEREF(zval_file);
43304329
if (IS_STRING != Z_TYPE_P(zval_file)) {
4331-
zend_argument_type_error(2, "must be an array of string elements, %s given", zend_zval_value_name(zval_file));
4330+
zend_argument_type_error(2, "must be an array of strings, %s given", zend_zval_value_name(zval_file));
43324331
RETURN_THROWS();
43334332
}
43344333
switch (extract_helper(phar_obj->archive, Z_STR_P(zval_file), path_to, overwrite, &error)) {

ext/phar/tests/cache_list/frontcontroller20.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ PATH_INFO=/
1111
--FILE_EXTERNAL--
1212
files/frontcontroller11.phar
1313
--EXPECT--
14-
TypeError: Phar::mungServer(): Argument #1 ($variables) must be an array of string types, array given
14+
TypeError: Phar::mungServer(): Argument #1 ($variables) must be an array of strings, array given

ext/phar/tests/frontcontroller20.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ PATH_INFO=/
99
--FILE_EXTERNAL--
1010
files/frontcontroller11.phar
1111
--EXPECTF--
12-
Fatal error: Uncaught TypeError: Phar::mungServer(): Argument #1 ($variables) must be an array of string types, array given in %sfrontcontroller20.php:2
12+
Fatal error: Uncaught TypeError: Phar::mungServer(): Argument #1 ($variables) must be an array of strings, array given in %sfrontcontroller20.php:2
1313
Stack trace:
1414
#0 %sfrontcontroller20.php(2): Phar::mungServer(Array)
1515
#1 {main}

ext/phar/tests/gh17518.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ try {
1919
<?php
2020
@unlink(__DIR__.'/gh17518.phar.php');
2121
?>
22-
--EXPECTF--
23-
PharException: phar error: attempted to extract non-existent file or directory "" from phar "%sgh17518.phar.php"
22+
--EXPECT--
23+
ValueError: Phar::extractTo(): Argument #2 ($files) must not be empty

ext/phar/tests/phar_extract.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ TypeError: Phar::extractTo(): Argument #2 ($files) must be of type array|string|
142142
TypeError: Phar::extractTo(): Argument #1 ($directory) must be of type string, array given
143143
ValueError: Phar::extractTo(): Argument #1 ($directory) must not be empty
144144
RuntimeException: Unable to use path "%soops" for extraction, it is a file, must be a directory
145-
TypeError: Phar::extractTo(): Argument #2 ($files) must be an array of string elements, array given
145+
TypeError: Phar::extractTo(): Argument #2 ($files) must be an array of strings, array given
146146
PharException: Extraction from phar "%stempmanifest1.phar.php" failed: Cannot extract "file1.txt" to "%sextract%cfile1.txt", path already exists
147147
string(5) "first"
148148
string(2) "hi"

ext/phar/tests/tar/frontcontroller20.phar.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ PATH_INFO=/
99
--FILE_EXTERNAL--
1010
files/frontcontroller11.phar.tar
1111
--EXPECTF--
12-
Fatal error: Uncaught TypeError: Phar::mungServer(): Argument #1 ($variables) must be an array of string types, array given in %sfrontcontroller20.phar.php:2
12+
Fatal error: Uncaught TypeError: Phar::mungServer(): Argument #1 ($variables) must be an array of strings, array given in %sfrontcontroller20.phar.php:2
1313
Stack trace:
1414
#0 %sfrontcontroller20.phar.php(2): Phar::mungServer(Array)
1515
#1 {main}

ext/phar/tests/tar/phar_setdefaultstub.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ string(60) "<?php // tar-based phar archive stub file
7676
__HALT_COMPILER();"
7777
============================================================================
7878
============================================================================
79-
TypeError: Phar::setDefaultStub(): Argument #1 ($index) must be null for a tar- or zip-based phar stub, string given
79+
ValueError: Phar::setDefaultStub(): Argument #1 ($index) must be null for a tar- or zip-based phar stub, string given
8080
string(60) "<?php // tar-based phar archive stub file
8181
__HALT_COMPILER();"
8282
============================================================================
8383
============================================================================
84-
TypeError: Phar::setDefaultStub(): Argument #1 ($index) must be null for a tar- or zip-based phar stub, string given
84+
ValueError: Phar::setDefaultStub(): Argument #1 ($index) must be null for a tar- or zip-based phar stub, string given
8585
string(60) "<?php // tar-based phar archive stub file
8686
__HALT_COMPILER();"

ext/phar/tests/zip/frontcontroller20.phar.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ PATH_INFO=/
1212
--FILE_EXTERNAL--
1313
files/frontcontroller11.phar.zip
1414
--EXPECTF--
15-
Fatal error: Uncaught TypeError: Phar::mungServer(): Argument #1 ($variables) must be an array of string types, array given in %sfrontcontroller20.phar.php:2
15+
Fatal error: Uncaught TypeError: Phar::mungServer(): Argument #1 ($variables) must be an array of strings, array given in %sfrontcontroller20.phar.php:2
1616
Stack trace:
1717
#0 %sfrontcontroller20.phar.php(2): Phar::mungServer(Array)
1818
#1 {main}

ext/phar/tests/zip/phar_setdefaultstub.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ string(60) "<?php // zip-based phar archive stub file
7676
__HALT_COMPILER();"
7777
============================================================================
7878
============================================================================
79-
TypeError: Phar::setDefaultStub(): Argument #1 ($index) must be null for a tar- or zip-based phar stub, string given
79+
ValueError: Phar::setDefaultStub(): Argument #1 ($index) must be null for a tar- or zip-based phar stub, string given
8080
string(60) "<?php // zip-based phar archive stub file
8181
__HALT_COMPILER();"
8282
============================================================================
8383
============================================================================
84-
TypeError: Phar::setDefaultStub(): Argument #1 ($index) must be null for a tar- or zip-based phar stub, string given
84+
ValueError: Phar::setDefaultStub(): Argument #1 ($index) must be null for a tar- or zip-based phar stub, string given
8585
string(60) "<?php // zip-based phar archive stub file
8686
__HALT_COMPILER();"

0 commit comments

Comments
 (0)