diff options
Diffstat (limited to 'ext/zlib')
127 files changed, 1220 insertions, 1641 deletions
diff --git a/ext/zlib/php_zlib.h b/ext/zlib/php_zlib.h index 8e77ee62b2..6c43625217 100644 --- a/ext/zlib/php_zlib.h +++ b/ext/zlib/php_zlib.h @@ -1,7 +1,5 @@ /* +----------------------------------------------------------------------+ - | PHP Version 7 | - +----------------------------------------------------------------------+ | Copyright (c) The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | @@ -49,6 +47,7 @@ typedef struct _php_zlib_context { int status; size_t inflateDictlen; php_zlib_buffer buffer; + zend_object std; } php_zlib_context; ZEND_BEGIN_MODULE_GLOBALS(zlib) diff --git a/ext/zlib/tests/004-mb.phpt b/ext/zlib/tests/004-mb.phpt index 07a26e5294..84e40d3013 100644 --- a/ext/zlib/tests/004-mb.phpt +++ b/ext/zlib/tests/004-mb.phpt @@ -5,9 +5,7 @@ gzfile() with various invalid params --FILE-- <?php -var_dump(gzfile()); var_dump(gzfile("nonexistent_file_gzfile",1)); -var_dump(gzfile(1,1,1)); var_dump(gzfile(__DIR__."/004私はガラスを食べられます.txt.gz")); var_dump(gzfile(__DIR__."/004私はガラスを食べられます.txt.gz", 1)); @@ -15,14 +13,8 @@ var_dump(gzfile(__DIR__."/004私はガラスを食べられます.txt.gz", 1)); echo "Done\n"; ?> --EXPECTF-- -Warning: gzfile() expects at least 1 parameter, 0 given in %s on line %d -NULL - -Warning: gzfile(nonexistent_file_gzfile): failed to open stream: No such file or directory in %s on line %d +Warning: gzfile(nonexistent_file_gzfile): Failed to open stream: No such file or directory in %s on line %d bool(false) - -Warning: gzfile() expects at most 2 parameters, 3 given in %s on line %d -NULL array(6) { [0]=> string(36) "When you're taught through feelings diff --git a/ext/zlib/tests/004.phpt b/ext/zlib/tests/004.phpt index 7689ad0cf1..4921ad496c 100644 --- a/ext/zlib/tests/004.phpt +++ b/ext/zlib/tests/004.phpt @@ -5,9 +5,7 @@ gzfile() with various invalid params --FILE-- <?php -var_dump(gzfile()); var_dump(gzfile("nonexistent_file_gzfile",1)); -var_dump(gzfile(1,1,1)); var_dump(gzfile(__DIR__."/004.txt.gz")); var_dump(gzfile(__DIR__."/004.txt.gz", 1)); @@ -15,14 +13,8 @@ var_dump(gzfile(__DIR__."/004.txt.gz", 1)); echo "Done\n"; ?> --EXPECTF-- -Warning: gzfile() expects at least 1 parameter, 0 given in %s on line %d -NULL - -Warning: gzfile(nonexistent_file_gzfile): failed to open stream: No such file or directory in %s on line %d +Warning: gzfile(nonexistent_file_gzfile): Failed to open stream: No such file or directory in %s on line %d bool(false) - -Warning: gzfile() expects at most 2 parameters, 3 given in %s on line %d -NULL array(6) { [0]=> string(36) "When you're taught through feelings diff --git a/ext/zlib/tests/005.phpt b/ext/zlib/tests/005.phpt index daa178ec69..dad9a9927d 100644 --- a/ext/zlib/tests/005.phpt +++ b/ext/zlib/tests/005.phpt @@ -5,10 +5,13 @@ gzcompress()/gzuncompress() and invalid params --FILE-- <?php -var_dump(gzcompress()); -var_dump(gzcompress("", 1000)); -var_dump(gzcompress("", -1)); +try { + var_dump(gzcompress("", 1000)); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} +var_dump(gzcompress("", -1)); var_dump(gzcompress("")); var_dump(gzcompress("", 9)); @@ -19,9 +22,17 @@ Desolation, grief and agony"; var_dump($data1 = gzcompress($string)); var_dump($data2 = gzcompress($string, 9)); -var_dump(gzuncompress()); -var_dump(gzuncompress("", 1000)); -var_dump(gzuncompress("", -1)); +try { + var_dump(gzuncompress("", 1000)); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} + +try { + var_dump(gzuncompress("", -1)); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} var_dump(gzuncompress("")); var_dump(gzuncompress("", 9)); @@ -31,28 +42,18 @@ var_dump(gzuncompress($data2)); $data2[4] = 0; var_dump(gzuncompress($data2)); -echo "Done\n"; ?> --EXPECTF-- -Warning: gzcompress() expects at least 1 parameter, 0 given in %s on line %d -NULL - -Warning: gzcompress(): compression level (1000) must be within -1..9 in %s on line %d -bool(false) +gzcompress(): Argument #2 ($level) must be between -1 and 9 string(%d) "%a" string(%d) "%a" string(%d) "%a" string(%d) "%a" string(%d) "%a" -Warning: gzuncompress() expects at least 1 parameter, 0 given in %s on line %d -NULL - Warning: gzuncompress(): %s error in %s on line %d bool(false) - -Warning: gzuncompress(): length (-1) must be greater or equal zero in %s on line %d -bool(false) +gzuncompress(): Argument #2 ($max_length) must be greater than or equal to 0 Warning: gzuncompress(): %s error in %s on line %d bool(false) @@ -68,4 +69,3 @@ Desolation, grief and agony" Warning: gzuncompress(): %s error in %s on line %d bool(false) -Done diff --git a/ext/zlib/tests/006.phpt b/ext/zlib/tests/006.phpt index 1caebd7a62..31a09bad88 100644 --- a/ext/zlib/tests/006.phpt +++ b/ext/zlib/tests/006.phpt @@ -5,8 +5,12 @@ gzdeflate()/gzinflate() and invalid params --FILE-- <?php -var_dump(gzdeflate()); -var_dump(gzdeflate("", 1000)); +try { + var_dump(gzcompress("", 1000)); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} + var_dump(gzdeflate("", -1)); var_dump(gzdeflate("")); @@ -19,10 +23,14 @@ Desolation, grief and agony"; var_dump($data1 = gzdeflate($string)); var_dump($data2 = gzdeflate($string, 9)); -var_dump(gzinflate()); var_dump(gzinflate("")); var_dump(gzinflate("asfwe", 1000)); -var_dump(gzinflate("asdf", -1)); + +try { + var_dump(gzinflate("asdf", -1)); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} var_dump(gzinflate("asdf")); var_dump(gzinflate("asdf", 9)); @@ -32,31 +40,21 @@ var_dump(gzinflate($data2)); $data2[4] = 0; var_dump(gzinflate($data2)); -echo "Done\n"; ?> --EXPECTF-- -Warning: gzdeflate() expects at least 1 parameter, 0 given in %s on line %d -NULL - -Warning: gzdeflate(): compression level (1000) must be within -1..9 in %s on line %d -bool(false) +gzcompress(): Argument #2 ($level) must be between -1 and 9 string(%d) "%a" string(%d) "%a" string(%d) "%a" string(%d) "%a" string(%d) "%a" -Warning: gzinflate() expects at least 1 parameter, 0 given in %s on line %d -NULL - Warning: gzinflate(): data error in %s on line %d bool(false) Warning: gzinflate(): data error in %s on line %d bool(false) - -Warning: gzinflate(): length (-1) must be greater or equal zero in %s on line %d -bool(false) +gzinflate(): Argument #2 ($max_length) must be greater than or equal to 0 Warning: gzinflate(): data error in %s on line %d bool(false) @@ -72,4 +70,3 @@ Desolation, grief and agony" Warning: gzinflate(): data error in %s on line %d bool(false) -Done diff --git a/ext/zlib/tests/007.phpt b/ext/zlib/tests/007.phpt index 6c42bf67db..6783b44f4d 100644 --- a/ext/zlib/tests/007.phpt +++ b/ext/zlib/tests/007.phpt @@ -5,11 +5,21 @@ gzencode() and invalid params --FILE-- <?php -var_dump(gzencode()); -var_dump(gzencode(1,1,1,1)); -var_dump(gzencode("", -10)); -var_dump(gzencode("", 100)); -var_dump(gzencode("", 1, 100)); +try { + var_dump(gzencode("", -10)); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} +try { + var_dump(gzencode("", 100)); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} +try { + var_dump(gzencode("", 1, 100)); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} var_dump(gzencode("", -1, ZLIB_ENCODING_GZIP)); var_dump(gzencode("", 9, ZLIB_ENCODING_DEFLATE)); @@ -19,33 +29,22 @@ Light in this temple Light in my truth Lies in the darkness"; -var_dump(gzencode($string, 9, 3)); +try { + var_dump(gzencode($string, 9, 3)); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} var_dump(gzencode($string, -1, ZLIB_ENCODING_GZIP)); var_dump(gzencode($string, 9, ZLIB_ENCODING_DEFLATE)); -echo "Done\n"; ?> --EXPECTF-- -Warning: gzencode() expects at least 1 parameter, 0 given in %s on line %d -NULL - -Warning: gzencode() expects at most 3 parameters, 4 given in %s on line %d -NULL - -Warning: gzencode(): compression level (-10) must be within -1..9 in %s on line %d -bool(false) - -Warning: gzencode(): compression level (100) must be within -1..9 in %s on line %d -bool(false) - -Warning: gzencode(): encoding mode must be either ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE in %s on line %d -bool(false) +gzencode(): Argument #2 ($level) must be between -1 and 9 +gzencode(): Argument #2 ($level) must be between -1 and 9 +gzencode(): Argument #3 ($encoding) must be one of ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP, or ZLIB_ENCODING_DEFLATE string(%d) "%a" string(%d) "%a" - -Warning: gzencode(): encoding mode must be either ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE in %s on line %d -bool(false) +gzencode(): Argument #3 ($encoding) must be one of ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP, or ZLIB_ENCODING_DEFLATE string(%d) "%a" string(%d) "%a" -Done diff --git a/ext/zlib/tests/bug55544-win.phpt b/ext/zlib/tests/bug55544-win.phpt Binary files differindex 3f9843fc45..9bbfef5f7f 100644 --- a/ext/zlib/tests/bug55544-win.phpt +++ b/ext/zlib/tests/bug55544-win.phpt diff --git a/ext/zlib/tests/bug55544.phpt b/ext/zlib/tests/bug55544.phpt Binary files differindex e650fe6909..b5041cedc5 100644 --- a/ext/zlib/tests/bug55544.phpt +++ b/ext/zlib/tests/bug55544.phpt diff --git a/ext/zlib/tests/bug60761.phpt b/ext/zlib/tests/bug60761.phpt index 04763be504..37191c2739 100644 --- a/ext/zlib/tests/bug60761.phpt +++ b/ext/zlib/tests/bug60761.phpt @@ -19,14 +19,14 @@ $lens = array(); for ( $i=0 ; $i < 100 ; $i++ ) { - // can't use ob_gzhandler with zlib.output_compression - ob_start();//"ob_gzhandler"); - phpinfo(); - $html = ob_get_clean(); + // can't use ob_gzhandler with zlib.output_compression + ob_start();//"ob_gzhandler"); + phpinfo(); + $html = ob_get_clean(); - $len = strlen($html); + $len = strlen($html); - $lens[$len] = $len; + $lens[$len] = $len; } $lens = array_values($lens); diff --git a/ext/zlib/tests/bug61139.phpt b/ext/zlib/tests/bug61139.phpt index ab7c74e9cc..646396c041 100644 --- a/ext/zlib/tests/bug61139.phpt +++ b/ext/zlib/tests/bug61139.phpt @@ -3,7 +3,7 @@ Bug #61139 (gzopen leaks when specifying invalid mode) --SKIPIF-- <?php if (!extension_loaded('zlib')) { - die('skip - zlib extension not loaded'); + die('skip - zlib extension not loaded'); } ?> --FILE-- @@ -12,7 +12,7 @@ if (!extension_loaded('zlib')) { gzopen('someFile', 'c'); --CLEAN-- <?php - unlink('someFile'); + unlink('someFile'); ?> --EXPECTF-- Warning: gzopen(): gzopen failed in %s on line %d diff --git a/ext/zlib/tests/bug67724.phpt b/ext/zlib/tests/bug67724.phpt index 1e5026f650..3edbb2ba2c 100644 --- a/ext/zlib/tests/bug67724.phpt +++ b/ext/zlib/tests/bug67724.phpt @@ -9,11 +9,11 @@ extension_loaded("zlib") or die("skip need ext/zlib"); echo "Test\n"; $f = fopen(__DIR__."/bug67724.gz.gz", "rb") - or die(current(error_get_last())); + or die(current(error_get_last())); stream_filter_append($f, "zlib.inflate", STREAM_FILTER_READ, ["window" => 30]); stream_filter_append($f, "zlib.inflate", STREAM_FILTER_READ, ["window" => 30]); for ($i = 0; !feof($f); $i += strlen(fread($f, 0x1000))) - ; + ; fclose($f); var_dump($i); diff --git a/ext/zlib/tests/bug71417.phpt b/ext/zlib/tests/bug71417.phpt index ae1390134e..b601b4c725 100644 --- a/ext/zlib/tests/bug71417.phpt +++ b/ext/zlib/tests/bug71417.phpt @@ -1,15 +1,15 @@ --TEST-- -Bug #71417: fread() does not detect decoding errors from filter zlib.inflate +Bug #71417: fread() does not report zlib.inflate errors --SKIPIF-- <?php if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build'); ?> --FILE-- <?php function test($case) { - $plain = "The quick brown fox jumps over the lazy dog."; - $fn = "bug71417.gz"; - $compressed = (string) gzencode($plain); - + $plain = "The quick brown fox jumps over the lazy dog."; + $fn = "bug71417.gz"; + $compressed = (string) gzencode($plain); + if ($case == 1) { // 1. Set a random byte in the middle of the compressed data. // $ php test-zlib-inflate.php @@ -37,26 +37,26 @@ function test($case) { // 4. Corrupted final length. // $ php test-zlib-inflate.phpread: string(0) "" // read: string(44) "The quick brown fox jumps over the lazy dog." - // $ gunzip test-zlib-inflate.gz + // $ gunzip test-zlib-inflate.gz // gzip: test-zlib-inflate.gz: invalid compressed data--length error $compressed[strlen($compressed)-2] = 'X'; } - - // The gzdecode() function applied to the corrupted compressed data always - // detects the error: - // --> gzdecode(): PHP Fatal error: Uncaught ErrorException: gzdecode(): data error in ... - echo "gzdecode(): ", rawurldecode(gzdecode($compressed)), "\n"; - file_put_contents($fn, $compressed); - - $r = fopen($fn, "r"); - stream_filter_append($r, 'zlib.inflate', STREAM_FILTER_READ, array('window' => 15+16)); - while (!feof($r)) { - $s = fread($r, 100); - echo "read: "; var_dump($s); - } - fclose($r); - unlink($fn); + // The gzdecode() function applied to the corrupted compressed data always + // detects the error: + // --> gzdecode(): PHP Fatal error: Uncaught ErrorException: gzdecode(): data error in ... + echo "gzdecode(): ", rawurldecode(gzdecode($compressed)), "\n"; + + file_put_contents($fn, $compressed); + + $r = fopen($fn, "r"); + stream_filter_append($r, 'zlib.inflate', STREAM_FILTER_READ, array('window' => 15+16)); + while (!feof($r)) { + $s = fread($r, 100); + echo "read: "; var_dump($s); + } + fclose($r); + unlink($fn); } test(1); @@ -69,6 +69,8 @@ test(4); gzdecode(): Warning: gzdecode(): data error in %s on line %d + +Notice: fread(): zlib: data error in %s on line %d read: bool(false) gzdecode(): Warning: gzdecode(): data error in %s on line %d @@ -77,8 +79,12 @@ read: string(32) "The quick brown fox jumps over t" gzdecode(): Warning: gzdecode(): data error in %s on line %d + +Notice: fread(): zlib: data error in %s on line %d read: bool(false) gzdecode(): Warning: gzdecode(): data error in %s on line %d + +Notice: fread(): zlib: data error in %s on line %d read: bool(false) diff --git a/ext/zlib/tests/bug75273.phpt b/ext/zlib/tests/bug75273.phpt index 66ec81edff..f3309546bd 100644 --- a/ext/zlib/tests/bug75273.phpt +++ b/ext/zlib/tests/bug75273.phpt @@ -7,22 +7,22 @@ if (!extension_loaded('zlib')) die('skip zlib extension not available'); --FILE-- <?php function non_repeating_str($len = 8192) { - $ret = ''; - mt_srand(1); - $iterations = (int) ($len / 256) + 1; - for ($i = 0; $i < $iterations; $i++) { - $haves = array(); - $cnt = 0; - while ($cnt < 256) { - $j = mt_rand(0, 255); - if (!isset($haves[$j])) { - $haves[$j] = $j; - $cnt++; - $ret .= chr($j); - } - } - } - return substr($ret, 0, $len); + $ret = ''; + mt_srand(1); + $iterations = (int) ($len / 256) + 1; + for ($i = 0; $i < $iterations; $i++) { + $haves = array(); + $cnt = 0; + while ($cnt < 256) { + $j = mt_rand(0, 255); + if (!isset($haves[$j])) { + $haves[$j] = $j; + $cnt++; + $ret .= chr($j); + } + } + } + return substr($ret, 0, $len); } $base_len = 32768 - 23 /*overhead*/; @@ -30,25 +30,25 @@ $base_len = 32768 - 23 /*overhead*/; $stream = fopen('php://memory', 'rb+'); for ($i = 1; $i <= 8; $i++) { - $in_data = non_repeating_str($base_len + $i); + $in_data = non_repeating_str($base_len + $i); - $deflate_filter = stream_filter_append($stream, 'zlib.deflate', STREAM_FILTER_WRITE, ['window' => 16 + 15]); - rewind($stream); - fwrite($stream, $in_data); - stream_filter_remove($deflate_filter); + $deflate_filter = stream_filter_append($stream, 'zlib.deflate', STREAM_FILTER_WRITE, ['window' => 16 + 15]); + rewind($stream); + fwrite($stream, $in_data); + stream_filter_remove($deflate_filter); - rewind($stream); - $out_data = stream_get_contents($stream); - $out_data_len = strlen($out_data); + rewind($stream); + $out_data = stream_get_contents($stream); + $out_data_len = strlen($out_data); - $inflate_filter = stream_filter_prepend($stream, 'zlib.inflate', STREAM_FILTER_WRITE, ['window' => 16 + 15]); - rewind($stream); - $fwrite_len = fwrite($stream, $out_data); - stream_filter_remove($inflate_filter); + $inflate_filter = stream_filter_prepend($stream, 'zlib.inflate', STREAM_FILTER_WRITE, ['window' => 16 + 15]); + rewind($stream); + $fwrite_len = fwrite($stream, $out_data); + stream_filter_remove($inflate_filter); - if ($out_data_len !== $fwrite_len) { - echo "bug i=$i out_data_len=$out_data_len fwrite_len=$fwrite_len\n"; - } + if ($out_data_len !== $fwrite_len) { + echo "bug i=$i out_data_len=$out_data_len fwrite_len=$fwrite_len\n"; + } } fclose($stream); diff --git a/ext/zlib/tests/bug75299.phpt b/ext/zlib/tests/bug75299.phpt index b9a9439f2e..9f07aa095a 100644 --- a/ext/zlib/tests/bug75299.phpt +++ b/ext/zlib/tests/bug75299.phpt @@ -11,10 +11,8 @@ $r = new ReflectionFunction('inflate_add'); var_dump($r->getNumberOfRequiredParameters()); var_dump($r->getNumberOfParameters()); ?> -===DONE=== --EXPECT-- int(1) int(2) int(2) int(3) -===DONE=== diff --git a/ext/zlib/tests/bug_34821.phpt b/ext/zlib/tests/bug_34821.phpt index 53ef4d229e..8095bab23a 100644 --- a/ext/zlib/tests/bug_34821.phpt +++ b/ext/zlib/tests/bug_34821.phpt @@ -7,10 +7,10 @@ Bug #34821 (zlib encoders fail on widely varying binary data) // test 50 bytes to 50k $b = array( - 50, - 500, - 5000, - 50000, + 50, + 500, + 5000, + 50000, // 1000000, // works, but test would take too long ); @@ -18,12 +18,12 @@ $s = ''; $i = 0; foreach ($b as $size) { - do { - $s .= chr(rand(0,255)); - } while (++$i < $size); - var_dump($s === gzinflate(gzdeflate($s))); - var_dump($s === gzuncompress(gzcompress($s))); - var_dump($s === gzinflate(substr(gzencode($s), 10, -8))); + do { + $s .= chr(rand(0,255)); + } while (++$i < $size); + var_dump($s === gzinflate(gzdeflate($s))); + var_dump($s === gzuncompress(gzcompress($s))); + var_dump($s === gzinflate(substr(gzencode($s), 10, -8))); } ?> --EXPECT-- diff --git a/ext/zlib/tests/bug_52944.phpt b/ext/zlib/tests/bug_52944.phpt index 782e2396a7..e63dde2d29 100644 --- a/ext/zlib/tests/bug_52944.phpt +++ b/ext/zlib/tests/bug_52944.phpt @@ -18,7 +18,9 @@ var_dump(fread($fp,1)); var_dump(fread($fp,1)); fclose($fp); echo "Done.\n"; ---EXPECT-- +?> +--EXPECTF-- +Notice: fread(): zlib: data error in %s on line %d bool(false) string(0) "" Done. diff --git a/ext/zlib/tests/deflate_add_block_v123.phpt b/ext/zlib/tests/deflate_add_block_v123.phpt index c103dcb07d..6789e4496f 100644 --- a/ext/zlib/tests/deflate_add_block_v123.phpt +++ b/ext/zlib/tests/deflate_add_block_v123.phpt @@ -16,8 +16,6 @@ $resource = deflate_init(ZLIB_ENCODING_GZIP); var_dump(deflate_add($resource, "aaaaaaaaaaaaaaaaaaaaaa", ZLIB_BLOCK)); ?> -===DONE=== --EXPECTF-- Warning: deflate_add(): zlib >= 1.2.4 required for BLOCK deflate; current version: %s in %s on line %d bool(false) -===DONE=== diff --git a/ext/zlib/tests/deflate_add_buffer_full.phpt b/ext/zlib/tests/deflate_add_buffer_full.phpt index dc6012dc13..95669fa1a3 100644 --- a/ext/zlib/tests/deflate_add_buffer_full.phpt +++ b/ext/zlib/tests/deflate_add_buffer_full.phpt @@ -45,9 +45,7 @@ $deflated = deflate_add( echo bin2hex(substr($deflated, strlen($deflated) - 4)) . "\n"; ?> -===DONE=== --EXPECT-- 0000ffff 0000ffff 0000ffff -===DONE=== diff --git a/ext/zlib/tests/deflate_add_error.phpt b/ext/zlib/tests/deflate_add_error.phpt index 060a005779..11483f8847 100644 --- a/ext/zlib/tests/deflate_add_error.phpt +++ b/ext/zlib/tests/deflate_add_error.phpt @@ -9,15 +9,23 @@ if (!extension_loaded("zlib")) { --FILE-- <?php $badResource = fopen("php://memory", "r+"); -var_dump(deflate_add($badResource, "test")); + +try { + var_dump(deflate_add($badResource, "test")); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} $resource = deflate_init(ZLIB_ENCODING_DEFLATE); $badFlushType = 6789; -var_dump(deflate_add($resource, "test", $badFlushType)); -?> ---EXPECTF-- -Warning: deflate_add(): Invalid deflate resource in %s on line %d -bool(false) -Warning: deflate_add(): flush mode must be ZLIB_NO_FLUSH, ZLIB_PARTIAL_FLUSH, ZLIB_SYNC_FLUSH, ZLIB_FULL_FLUSH, ZLIB_BLOCK or ZLIB_FINISH in %s on line %d -bool(false) +try { + var_dump(deflate_add($resource, "test", $badFlushType)); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} + +?> +--EXPECT-- +deflate_add(): Argument #1 ($context) must be of type DeflateContext, resource given +deflate_add(): Argument #3 ($flush_mode) must be one of ZLIB_NO_FLUSH, ZLIB_PARTIAL_FLUSH, ZLIB_SYNC_FLUSH, ZLIB_FULL_FLUSH, ZLIB_BLOCK, or ZLIB_FINISH diff --git a/ext/zlib/tests/deflate_init_error.phpt b/ext/zlib/tests/deflate_init_error.phpt index 340a3f1062..104d8552e3 100644 --- a/ext/zlib/tests/deflate_init_error.phpt +++ b/ext/zlib/tests/deflate_init_error.phpt @@ -8,24 +8,41 @@ if (!extension_loaded("zlib")) { ?> --FILE-- <?php -var_dump(deflate_init(42)); -var_dump(deflate_init(ZLIB_ENCODING_DEFLATE, ['level' => 42])); -var_dump(deflate_init(ZLIB_ENCODING_DEFLATE, ['level' => -2])); -var_dump(deflate_init(ZLIB_ENCODING_DEFLATE, ['memory' => 0])); -var_dump(deflate_init(ZLIB_ENCODING_DEFLATE, ['memory' => 10])); -?> ---EXPECTF-- -Warning: deflate_init(): encoding mode must be ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE in %s on line %d -bool(false) -Warning: deflate_init(): compression level (42) must be within -1..9 in %s on line %d -bool(false) +try { + var_dump(deflate_init(42)); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} -Warning: deflate_init(): compression level (-2) must be within -1..9 in %s on line %d -bool(false) +try { + var_dump(deflate_init(ZLIB_ENCODING_DEFLATE, ['level' => 42])); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} -Warning: deflate_init(): compression memory level (0) must be within 1..9 in %s on line %d -bool(false) +try { + var_dump(deflate_init(ZLIB_ENCODING_DEFLATE, ['level' => -2])); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} -Warning: deflate_init(): compression memory level (10) must be within 1..9 in %s on line %d -bool(false) +try { + var_dump(deflate_init(ZLIB_ENCODING_DEFLATE, ['memory' => 0])); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} + +try { + var_dump(deflate_init(ZLIB_ENCODING_DEFLATE, ['memory' => 10])); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} + +?> +--EXPECT-- +deflate_init(): Argument #1 ($encoding) must be one of ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP, or ZLIB_ENCODING_DEFLATE +deflate_init(): "level" option must be between -1 and 9 +deflate_init(): "level" option must be between -1 and 9 +deflate_init(): "memory" option must be between 1 and 9 +deflate_init(): "memory" option must be between 1 and 9 diff --git a/ext/zlib/tests/dictionary_usage.phpt b/ext/zlib/tests/dictionary_usage.phpt index 0823b3ca94..359cfd3550 100644 --- a/ext/zlib/tests/dictionary_usage.phpt +++ b/ext/zlib/tests/dictionary_usage.phpt @@ -18,7 +18,6 @@ var_dump($dictStr_a === $a); $r = inflate_init(ZLIB_ENCODING_DEFLATE, ["dictionary" => $dict]); var_dump(inflate_add($r, $a, ZLIB_FINISH)); - $r = inflate_init(ZLIB_ENCODING_DEFLATE, ["dictionary" => ["8"] + range("a", "z")]); var_dump(inflate_add($r, $a, ZLIB_FINISH)); @@ -28,5 +27,5 @@ string(%d) "%s" bool(true) string(6) "abdcde" -Warning: inflate_add(): dictionary does not match expected dictionary (incorrect adler32 hash) in %s on line %d +Warning: inflate_add(): Dictionary does not match expected dictionary (incorrect adler32 hash) in %s on line %d bool(false) diff --git a/ext/zlib/tests/func.inc b/ext/zlib/tests/func.inc index 7556f81e6a..73cfc4e06f 100644 --- a/ext/zlib/tests/func.inc +++ b/ext/zlib/tests/func.inc @@ -2,17 +2,17 @@ function get_zlib_version() { - $version = NULL; + $version = NULL; - ob_start(); - phpinfo(); - $info = ob_get_contents(); - ob_end_clean(); - //if (preg_match(',zlib.*Compiled Version => (\d+\.\d+\.\d+),s', $info, $match)) { - // $version = $match[1]; - if (preg_match(',zlib(?!.*libXML).*Compiled Version (=> |</).*(\d+\.\d+\.\d+?),sU', $info, $match)) { - $version = $match[2]; - } + ob_start(); + phpinfo(); + $info = ob_get_contents(); + ob_end_clean(); + //if (preg_match(',zlib.*Compiled Version => (\d+\.\d+\.\d+),s', $info, $match)) { + // $version = $match[1]; + if (preg_match(',zlib(?!.*libXML).*Compiled Version (=> |</).*(\d+\.\d+\.\d+?),sU', $info, $match)) { + $version = $match[2]; + } - return $version; + return $version; } diff --git a/ext/zlib/tests/gzclose_basic.phpt b/ext/zlib/tests/gzclose_basic.phpt index 0393db2c57..1f72fc1c88 100644 --- a/ext/zlib/tests/gzclose_basic.phpt +++ b/ext/zlib/tests/gzclose_basic.phpt @@ -3,7 +3,7 @@ Test function gzclose() by calling it with its expected arguments --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -17,23 +17,27 @@ gzread($h, 20); var_dump(gzclose($h)); //should fail. -gzread($h, 20); +try { + gzread($h, 20); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} $h = gzopen($f, 'r'); gzread($h, 20); var_dump(fclose($h)); //should fail. -gzread($h, 20); +try { + gzread($h, 20); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} ?> -===DONE=== ---EXPECTF-- +--EXPECT-- bool(true) - -Warning: gzread(): supplied resource is not a valid stream resource in %s on line %d +gzread(): supplied resource is not a valid stream resource bool(true) - -Warning: gzread(): supplied resource is not a valid stream resource in %s on line %d -===DONE=== +gzread(): supplied resource is not a valid stream resource diff --git a/ext/zlib/tests/gzcompress_basic1.phpt b/ext/zlib/tests/gzcompress_basic1.phpt index 882fd87fad..a5d2735927 100644 --- a/ext/zlib/tests/gzcompress_basic1.phpt +++ b/ext/zlib/tests/gzcompress_basic1.phpt @@ -3,17 +3,11 @@ Test gzcompress() function : basic functionality --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php -/* Prototype : string gzcompress(string data [, int level, [int encoding]]) - * Description: Gzip-compress a string - * Source code: ext/zlib/zlib.c - * Alias to functions: - */ - /* * add a comment here to say what the test is supposed to do */ @@ -34,7 +28,7 @@ for($i = -1; $i < 10; $i++) { echo "-- Compression level $i --\n"; $output = gzcompress($data, $i); var_dump(md5($output)); - var_dump(strcmp(gzuncompress($output), $data)); + var_dump(strcmp(gzuncompress($output), $data)); } // Compressing a smaller string @@ -42,7 +36,7 @@ for($i = -1; $i < 10; $i++) { echo "-- Compression level $i --\n"; $output = gzcompress($smallstring, $i); var_dump(bin2hex($output)); - var_dump(strcmp(gzuncompress($output), $smallstring)); + var_dump(strcmp(gzuncompress($output), $smallstring)); } // Calling gzcompress() with mandatory arguments @@ -50,7 +44,6 @@ echo "\n-- Testing with no specified compression level --\n"; var_dump( bin2hex(gzcompress($smallstring) )); ?> -===Done=== --EXPECT-- *** Testing gzcompress() : basic functionality *** -- Compression level -1 -- @@ -122,4 +115,3 @@ int(0) -- Testing with no specified compression level -- string(70) "789c735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb" -===Done=== diff --git a/ext/zlib/tests/gzcompress_error1.phpt b/ext/zlib/tests/gzcompress_error1.phpt index 3f742a4dca..e740de6d0c 100644 --- a/ext/zlib/tests/gzcompress_error1.phpt +++ b/ext/zlib/tests/gzcompress_error1.phpt @@ -3,82 +3,42 @@ Test gzcompress() function : error conditions --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php -/* Prototype : string gzcompress(string data [, int level, [int encoding]]) - * Description: Gzip-compress a string - * Source code: ext/zlib/zlib.c - * Alias to functions: - */ - /* * add a comment here to say what the test is supposed to do */ echo "*** Testing gzcompress() : error conditions ***\n"; -// Zero arguments -echo "\n-- Testing gzcompress() function with Zero arguments --\n"; -var_dump( gzcompress() ); - -//Test gzcompress with one more than the expected number of arguments -echo "\n-- Testing gzcompress() function with more than expected no. of arguments --\n"; -$data = 'string_val'; -$level = 2; -$encoding = ZLIB_ENCODING_RAW; -$extra_arg = 10; -var_dump( gzcompress($data, $level, $encoding, $extra_arg) ); - echo "\n-- Testing with incorrect compression level --\n"; +$data = 'string_val'; $bad_level = 99; -var_dump(gzcompress($data, $bad_level)); +try { + var_dump(gzcompress($data, $bad_level)); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} echo "\n-- Testing with invalid encoding --\n"; $data = 'string_val'; +$level = 2; $encoding = 99; -var_dump(gzcompress($data, $level, $encoding)); - -echo "\n-- Testing with incorrect parameters --\n"; - -class Tester { - function Hello() { - echo "Hello\n"; - } +try { + var_dump(gzcompress($data, $level, $encoding)); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; } -$testclass = new Tester(); -var_dump(gzcompress($testclass)); - ?> -===Done=== ---EXPECTF-- +--EXPECT-- *** Testing gzcompress() : error conditions *** --- Testing gzcompress() function with Zero arguments -- - -Warning: gzcompress() expects at least 1 parameter, 0 given in %s on line %d -NULL - --- Testing gzcompress() function with more than expected no. of arguments -- - -Warning: gzcompress() expects at most 3 parameters, 4 given in %s on line %d -NULL - -- Testing with incorrect compression level -- - -Warning: gzcompress(): compression level (99) must be within -1..9 in %s on line %d -bool(false) +gzcompress(): Argument #2 ($level) must be between -1 and 9 -- Testing with invalid encoding -- - -Warning: gzcompress(): encoding mode must be either ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE in %s on line %d -bool(false) - --- Testing with incorrect parameters -- - -Warning: gzcompress() expects parameter 1 to be string, object given in %s on line %d -NULL -===Done=== +gzcompress(): Argument #3 ($encoding) must be one of ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP, or ZLIB_ENCODING_DEFLATE diff --git a/ext/zlib/tests/gzcompress_variation1.phpt b/ext/zlib/tests/gzcompress_variation1.phpt index c4bc0a1ff5..762aa3c870 100644 --- a/ext/zlib/tests/gzcompress_variation1.phpt +++ b/ext/zlib/tests/gzcompress_variation1.phpt @@ -3,17 +3,11 @@ Test gzcompress() function : variation --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php -/* Prototype : string gzcompress(string data [, int level, [int encoding]]) - * Description: Gzip-compress a string - * Source code: ext/zlib/zlib.c - * Alias to functions: - */ - include(__DIR__ . '/data.inc'); echo "*** Testing gzcompress() : variation ***\n"; @@ -24,11 +18,9 @@ var_dump( md5($output)); var_dump(md5(gzcompress($output))); ?> -===Done=== --EXPECT-- *** Testing gzcompress() : variation *** -- Testing multiple compression -- string(32) "764809aef15bb34cb73ad49ecb600d99" string(32) "eba942bc2061f23ea8688cc5101872a4" -===Done=== diff --git a/ext/zlib/tests/gzdeflate_basic1.phpt b/ext/zlib/tests/gzdeflate_basic1.phpt index 8ab0ee6243..7ace99a8a7 100644 --- a/ext/zlib/tests/gzdeflate_basic1.phpt +++ b/ext/zlib/tests/gzdeflate_basic1.phpt @@ -3,17 +3,11 @@ Test gzdeflate() function : basic functionality --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php -/* Prototype : string gzdeflate(string data [, int level, [int encoding]]) - * Description: Gzip-compress a string - * Source code: ext/zlib/zlib.c - * Alias to functions: - */ - /* * add a comment here to say what the test is supposed to do */ @@ -34,7 +28,7 @@ for($i = -1; $i < 10; $i++) { echo "-- Compression level $i --\n"; $output = gzdeflate($data, $i); var_dump(md5($output)); - var_dump(strcmp(gzinflate($output), $data)); + var_dump(strcmp(gzinflate($output), $data)); } // Compressing a smaller string @@ -42,7 +36,7 @@ for($i = -1; $i < 10; $i++) { echo "-- Compression level $i --\n"; $output = gzdeflate($smallstring, $i); var_dump(bin2hex($output)); - var_dump(strcmp(gzinflate($output), $smallstring)); + var_dump(strcmp(gzinflate($output), $smallstring)); } // Calling gzdeflate() with just mandatory arguments @@ -50,7 +44,6 @@ echo "\n-- Testing with no specified compression level --\n"; var_dump( bin2hex(gzdeflate($smallstring) )); ?> -===Done=== --EXPECT-- *** Testing gzdeflate() : basic functionality *** -- Compression level -1 -- @@ -122,4 +115,3 @@ int(0) -- Testing with no specified compression level -- string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200" -===Done=== diff --git a/ext/zlib/tests/gzdeflate_error1.phpt b/ext/zlib/tests/gzdeflate_error1.phpt index 93f8c03b4c..5081f66dc4 100644 --- a/ext/zlib/tests/gzdeflate_error1.phpt +++ b/ext/zlib/tests/gzdeflate_error1.phpt @@ -3,84 +3,42 @@ Test gzdeflate() function : error conditions --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php -/* Prototype : string gzdeflate(string data [, int level, [int encoding]]) - * Description: Gzip-compress a string - * Source code: ext/zlib/zlib.c - * Alias to functions: - */ - /* * add a comment here to say what the test is supposed to do */ echo "*** Testing gzdeflate() : error conditions ***\n"; -// Zero arguments -echo "\n-- Testing gzdeflate() function with Zero arguments --\n"; -var_dump( gzdeflate() ); - -//Test gzdeflate with one more than the expected number of arguments -echo "\n-- Testing gzdeflate() function with more than expected no. of arguments --\n"; $data = 'string_val'; -$level = 2; -$encoding = ZLIB_ENCODING_RAW; -$extra_arg = 10; -var_dump( gzdeflate($data, $level, $encoding, $extra_arg) ); echo "\n-- Testing with incorrect compression level --\n"; $bad_level = 99; -var_dump(gzdeflate($data, $bad_level)); +try { + var_dump(gzdeflate($data, $bad_level)); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} echo "\n-- Testing with incorrect encoding --\n"; +$level = 2; $bad_encoding = 99; -var_dump(gzdeflate($data, $level, $bad_encoding)); - -class Tester { - function Hello() { - echo "Hello\n"; - } +try { + var_dump(gzdeflate($data, $level, $bad_encoding)); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; } -echo "\n-- Testing with incorrect parameters --\n"; -$testclass = new Tester(); -var_dump(gzdeflate($testclass)); -var_dump(gzdeflate($data, $testclass)); - ?> -===Done=== ---EXPECTF-- +--EXPECT-- *** Testing gzdeflate() : error conditions *** --- Testing gzdeflate() function with Zero arguments -- - -Warning: gzdeflate() expects at least 1 parameter, 0 given in %s on line %d -NULL - --- Testing gzdeflate() function with more than expected no. of arguments -- - -Warning: gzdeflate() expects at most 3 parameters, 4 given in %s on line %d -NULL - -- Testing with incorrect compression level -- - -Warning: gzdeflate(): compression level (99) must be within -1..9 in %s on line %d -bool(false) +gzdeflate(): Argument #2 ($level) must be between -1 and 9 -- Testing with incorrect encoding -- - -Warning: gzdeflate(): encoding mode must be either ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE in %s on line %d -bool(false) - --- Testing with incorrect parameters -- - -Warning: gzdeflate() expects parameter 1 to be string, object given in %s on line %d -NULL - -Warning: gzdeflate() expects parameter 2 to be int, object given in %s on line %d -NULL -===Done=== +gzdeflate(): Argument #3 ($encoding) must be one of ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP, or ZLIB_ENCODING_DEFLATE diff --git a/ext/zlib/tests/gzdeflate_variation1.phpt b/ext/zlib/tests/gzdeflate_variation1.phpt index 7993abb529..e881d77b51 100644 --- a/ext/zlib/tests/gzdeflate_variation1.phpt +++ b/ext/zlib/tests/gzdeflate_variation1.phpt @@ -3,17 +3,11 @@ Test gzdeflate() function : variation --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php -/* Prototype : string gzdeflate(string data [, int level]) - * Description: Gzip-compress a string - * Source code: ext/zlib/zlib.c - * Alias to functions: - */ - include(__DIR__ . '/data.inc'); echo "*** Testing gzdeflate() : variation ***\n"; @@ -26,11 +20,9 @@ var_dump( md5($output)); var_dump(md5(gzdeflate($output))); ?> -===Done=== --EXPECT-- *** Testing gzdeflate() : variation *** -- Testing multiple compression -- string(32) "078554fe65e06f6ff01eab51cfc7ae9b" string(32) "86b9f895ef1377da5269ec3cb2729f71" -===Done=== diff --git a/ext/zlib/tests/gzencode_basic1.phpt b/ext/zlib/tests/gzencode_basic1.phpt index dfb09cc2ed..b129399dfd 100644 --- a/ext/zlib/tests/gzencode_basic1.phpt +++ b/ext/zlib/tests/gzencode_basic1.phpt @@ -3,17 +3,11 @@ Test gzencode() function : basic functionality --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php -/* Prototype : string gzencode ( string $data [, int $level [, int $encoding_mode ]] ) - * Description: Gzip-compress a string - * Source code: ext/zlib/zlib.c - * Alias to functions: - */ - /* * Test basic function of gzencode */ @@ -35,7 +29,7 @@ for($i = -1; $i < 10; $i++) { $output = gzencode($data, $i); // Clear OS byte before encode - $output[9] = "\x00"; + $output[9] = "\x00"; var_dump(md5($output)); } @@ -46,7 +40,7 @@ for($i = -1; $i < 10; $i++) { $output = gzencode($smallstring, $i); // Clear OS byte before encode - $output[9] = "\x00"; + $output[9] = "\x00"; var_dump(md5($output)); } @@ -59,7 +53,6 @@ echo "\n-- Testing gzencode with mode specified --\n"; var_dump(bin2hex(gzencode($smallstring, -1, FORCE_GZIP))); ?> -===Done=== --EXPECTF-- *** Testing gzencode() : basic functionality *** -- Compression level -1 -- @@ -112,4 +105,3 @@ string(94) "1f8b08000000000000%c%c735428ce4dccc951282e29cacc4b5728c95748cecf2d28 -- Testing gzencode with mode specified -- string(94) "1f8b08000000000000%c%c735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200edc4e40b1b000000" -===Done=== diff --git a/ext/zlib/tests/gzencode_error1.phpt b/ext/zlib/tests/gzencode_error1.phpt index ac846866c5..00d70f9398 100644 --- a/ext/zlib/tests/gzencode_error1.phpt +++ b/ext/zlib/tests/gzencode_error1.phpt @@ -3,96 +3,43 @@ Test gzencode() function : error conditions --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php -/* Prototype : string gzencode ( string $data [, int $level [, int $encoding_mode ]] ) - * Description: Gzip-compress a string - * Source code: ext/zlib/zlib.c - * Alias to functions: - */ - /* * Test error cases for gzencode */ echo "*** Testing gzencode() : error conditions ***\n"; -// Zero arguments -echo "\n-- Testing gzencode() function with Zero arguments --\n"; -var_dump( gzencode() ); - -//Test gzencode with one more than the expected number of arguments -echo "\n-- Testing gzencode() function with more than expected no. of arguments --\n"; $data = 'string_val'; $level = 2; $encoding_mode = FORCE_DEFLATE; -$extra_arg = 10; -var_dump( gzencode($data, $level, $encoding_mode, $extra_arg) ); echo "\n-- Testing with incorrect compression level --\n"; $bad_level = 99; -var_dump(gzencode($data, $bad_level)); +try { + var_dump(gzencode($data, $bad_level)); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} echo "\n-- Testing with incorrect encoding_mode --\n"; $bad_mode = 99; -var_dump(gzencode($data, $level, $bad_mode)); - -class Tester { - function Hello() { - echo "Hello\n"; - } +try { + var_dump(gzencode($data, $level, $bad_mode)); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; } -echo "\n-- Testing with incorrect parameters --\n"; -$testclass = new Tester(); -var_dump(gzencode($testclass)); -var_dump(gzencode($data, $testclass)); -var_dump(gzencode($data, -1, 99.99)); -var_dump(gzencode($data, -1, $testclass)); -var_dump(gzencode($data, "a very none numeric string\n")); - ?> -===Done=== ---EXPECTF-- +--EXPECT-- *** Testing gzencode() : error conditions *** --- Testing gzencode() function with Zero arguments -- - -Warning: gzencode() expects at least 1 parameter, 0 given in %s on line %d -NULL - --- Testing gzencode() function with more than expected no. of arguments -- - -Warning: gzencode() expects at most 3 parameters, 4 given in %s on line %d -NULL - -- Testing with incorrect compression level -- - -Warning: gzencode(): compression level (99) must be within -1..9 in %s on line %d -bool(false) +gzencode(): Argument #2 ($level) must be between -1 and 9 -- Testing with incorrect encoding_mode -- - -Warning: gzencode(): encoding mode must be either ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE in %s on line %d -bool(false) - --- Testing with incorrect parameters -- - -Warning: gzencode() expects parameter 1 to be string, object given in %s on line %d -NULL - -Warning: gzencode() expects parameter 2 to be int, object given in %s on line %d -NULL - -Warning: gzencode(): encoding mode must be either ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE in %s on line %d -bool(false) - -Warning: gzencode() expects parameter 3 to be int, object given in %s on line %d -NULL - -Warning: gzencode() expects parameter 2 to be int, string given in %s on line %d -NULL -===Done=== +gzencode(): Argument #3 ($encoding) must be one of ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP, or ZLIB_ENCODING_DEFLATE diff --git a/ext/zlib/tests/gzencode_variation1-win32.phpt b/ext/zlib/tests/gzencode_variation1-win32.phpt index 798924f9fe..f7870e890f 100644 --- a/ext/zlib/tests/gzencode_variation1-win32.phpt +++ b/ext/zlib/tests/gzencode_variation1-win32.phpt @@ -8,22 +8,16 @@ if( substr(PHP_OS, 0, 3) != "WIN" ) { } if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php -/* Prototype : string gzencode ( string $data [, int $level [, int $encoding_mode ]] ) - * Description: Gzip-compress a string - * Source code: ext/zlib/zlib.c - * Alias to functions: - */ - if(!function_exists("gzdecode")) { - function gzdecode($data) - { - return gzinflate(substr($data,10,-8)); - } + function gzdecode($data) + { + return gzinflate(substr($data,10,-8)); + } } @@ -37,10 +31,8 @@ $output = gzencode(gzencode($data)); $back = gzdecode(gzdecode($output)); var_dump($data === $back); ?> -===Done=== --EXPECT-- *** Testing gzencode() : variation *** -- Testing multiple compression -- bool(true) -===Done=== diff --git a/ext/zlib/tests/gzencode_variation1.phpt b/ext/zlib/tests/gzencode_variation1.phpt index 2f953168fa..b3987b9d20 100644 --- a/ext/zlib/tests/gzencode_variation1.phpt +++ b/ext/zlib/tests/gzencode_variation1.phpt @@ -8,7 +8,7 @@ if( substr(PHP_OS, 0, 3) == "WIN" ) { } if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } if (PHP_OS == "Darwin") { @@ -17,12 +17,6 @@ if (PHP_OS == "Darwin") { ?> --FILE-- <?php -/* Prototype : string gzencode ( string $data [, int $level [, int $encoding_mode ]] ) - * Description: Gzip-compress a string - * Source code: ext/zlib/zlib.c - * Alias to functions: - */ - include(__DIR__ . '/data.inc'); echo "*** Testing gzencode() : variation ***\n"; @@ -32,10 +26,8 @@ $output = gzencode($data); var_dump(bin2hex(gzencode($output))); ?> -===Done=== --EXPECT-- *** Testing gzencode() : variation *** -- Testing multiple compression -- string(3658) "1f8b0800000000000003010e07f1f81f8b08000000000000036d574d6fe4c80dbdeb57d4ad2f3dfe01eb83e1ec22980e309b4562c067b64449159754dafab0b6e7d7e73d96da1e4c72184c4b2ab2c8f7c847fa25baabba98dc1a8b2b7c38bb324b713ee37f757f56cdc5c7f5b17b9d152f923b157c5ae335e0b75fedd0e2d781c6b98ea3a6ee05affe1dfc3a6527f8f09c52dcb38ba38bb5249934d6ecfe1e53a9ab76ff4c342cf2a64ed2028349fc9a8b139755685352acb82b9fbb67f8bade5cdcb698e1fcec94b7ceba3cb897e806cfc8114350dd1ebbdfa35b62d2478b0056d23ed809b9b95d696d91ce2aa97c911e3fa539c43f84c887554a4d125c9e63ff96711cc08c0866263cb37a0bbe2122ae8f6baecb2284abfb4ddf916db8354cddeef37c1afe5fa02fc7afb3db34f5b3acbdf2eb905490d8f38d7468d253a323d5ebb903760d7944d3b2024e834a99ddce77669bdd823cfbb8e899d4ad4c799677452e6029e80023a03b2374005590641f7d3877df2ad09f3c0e82a54d6a5644fd63049a37ed4bc362016fd9f51264f1e5c630727421ae930b7ed416e93e47b7c71a400390361ffbecb7561bb98f69b5da289e91becc27f08b3b724cb8704f9144d366431d0cb870c56b205deaa2e17636063761a911039fb7e4bf9f06c4f0aecd2ec80e8b41831ca7515e31286166458ea3ef71f2ce7cde2ae269c96d60525724a9c9170b713ed5750758f3cd2a361fc8b288fc92358ce884692e8ea0fe59bd969a0da2eed5831b715749eaae7178f3ebd30fb88c92105f367cce2c882955dc6bf8eca0d5d57540b3092894743ba0fd5b2dad021836191f1afc0bba14dde1642cb0b1aa6879c38907dcefa0720082b801bec61417469219175267dfa047df35b0bd1332001c28cdfafd3bcabe91e74368cdd8d8478e494c190e7ee90c67f2bde288e68ab6b15e883c995be4f8feb6c6dda4278e4f38578ddbdc7be36788daf0c3cb1d1819c73822f7000a0d1813fa94153b572315e51343b536bc64977dff163cebfd8418773261f524017e251fccc60ae29a5770ae097594d52e9c1229d87ce967a36401c46b69945afb249d101c9d420ffa9a123e232c20e76467d5d169202a2dd4c582949e013e745df7958d4b0cc4fd4377a737cd4feea7974070000f314d423e0634cb9a618fdf5dc64fd422181fd59c9230c9f6f9d18dc8fc23e9cccbc7188733b04aa57de83ebea0be3633cff5fa1ff83269be7f44f5a8d84550cc703255fd345dd402034d0b3e11a73ec6e3d4a77f4f685b614329f1b3132ae7af33d02e1e55e291fa6574b758d1f0200e7423dbc852211818043a7c9ce80aa9d59fce0401959f5ea2cf71fde90824f8c9192dbe9d329db143794675ddcf257dd7755273b67340414e3ccad12e3f661f8aad9cf9957dc1275d10a51d3934fa81e68dc6768fb8ee23e373936c8e13feab8b0f50d227f7af76f561fb0950f3d099bbc316c3892a42fb36806d8660e800fa4f43fd4b962d2097d71933a54b77ff948677848eb17bb3a88b621682cfb3bbb49cf42fed6b3944124ad8358ca688aa44dd5f2144c7c9ab16f25b9aca9654ef357ec9ad55c40d324d6cc3d9e3920b863c231d31a95d937fb5520f9c816c79b7dcecc593fb9593cc05a51ebb1eeddd5b49eb437769738d0f64adc579d372b8b7f7c0208487ee3915ebf5766e148ebd77cf4e01f3ec285047011e55838968b6494d517fe29224777b24dd3ddf933101695b102e87db805eef291b74dcfd91628fb2a53f93dbd2968ef2e598746c9204f89fba1f0246fc671610a0591806e46a1346f77c40d910a47c5e20ffb23f003c04b648327a4ed98032c1965bd35bb0044f5344248f56fdb99aa61d6451d68e33489a83bffbe6573541b2da5f64681ea12090f778b2075374778810f73965fa3626a9d41f4df2f83f7c34658cec921b5a9bde49dd5007ec882b02adc514f81aa85898b5cc98e1b137733c0a8789b7f5648d2d231b80bf74978f25d61ce08a8abd11801fd8f995e066676307192ff7641f1cc6e0dee68565b8b22ac3889cd067bf732754a6b270af1044c6a8776811a4f6d8bd0477a9f516064201b920b92d7cd4dc7eee13e6b3eb3528a82f9abb3f388ebe6a8f871393461b73816ec54c99d604174bc5a6801de13908f86aea6a7d0fea107d682bcf1ec348b83872e6b8a316ecd02eb8f8dc86a609bf59a2dd03f1dfa4079436d55e24617be1a2854d008b2b2b1705e2078a7f3946318df1c24f6bf70d4b456eca286ec2b585b28262cc048a098c3e2d5f325a92bb36f691afdc14c822da1b116c9c1c07bb362eb0a04b78834c812134230ebf2044ac2e3c0e3ad00f848dc5010f3bf917ec2fc700b7bf26dacea8440620e04f90f4d97d6dd77cfde8a05c7d3930f1e5811fb8ec5c70964dcc8187ec90e32fdd6b64eec7586413b7d55bed65c4cce39a9b6c15e70e9da94e53fc904e6286f01f5b5562c94211befbc23507e01b2a3865e2f45b5d7b591f290087a5605b82495b4e393f31aa5b37211ec40241a746d903c5eebf117a4d3ddb0d00007b64cbc70e070000" -===Done=== diff --git a/ext/zlib/tests/gzencode_variation2-win32.phpt b/ext/zlib/tests/gzencode_variation2-win32.phpt index 9936ec8d3b..727a079b61 100644 --- a/ext/zlib/tests/gzencode_variation2-win32.phpt +++ b/ext/zlib/tests/gzencode_variation2-win32.phpt @@ -8,22 +8,16 @@ if( substr(PHP_OS, 0, 3) != "WIN" ) { } if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } include 'func.inc'; if (version_compare(get_zlib_version(), "1.2.11") < 0) { - die("skip - at least zlib 1.2.11 required, got " . get_zlib_version()); + die("skip - at least zlib 1.2.11 required, got " . get_zlib_version()); } ?> --FILE-- <?php -/* Prototype : string gzencode ( string $data [, int $level [, int $encoding_mode ]] ) - * Description: Gzip-compress a string - * Source code: ext/zlib/zlib.c - * Alias to functions: - */ - echo "*** Testing gzencode() : variation ***\n"; $data = "A small string to encode\n"; @@ -34,7 +28,6 @@ var_dump(bin2hex(gzencode($data, -1, FORCE_GZIP))); var_dump(bin2hex(gzencode($data, -1, FORCE_DEFLATE))); ?> -===DONE=== --EXPECT-- *** Testing gzencode() : variation *** @@ -42,4 +35,3 @@ var_dump(bin2hex(gzencode($data, -1, FORCE_DEFLATE))); string(90) "1f8b080000000000000a735428ce4dccc951282e29cacc4b5728c95748cd4bce4f49e50200d7739de519000000" string(90) "1f8b080000000000000a735428ce4dccc951282e29cacc4b5728c95748cd4bce4f49e50200d7739de519000000" string(66) "789c735428ce4dccc951282e29cacc4b5728c95748cd4bce4f49e50200735808cd" -===DONE=== diff --git a/ext/zlib/tests/gzencode_variation2.phpt b/ext/zlib/tests/gzencode_variation2.phpt index 9160cf5197..f1e3c0d2ba 100644 --- a/ext/zlib/tests/gzencode_variation2.phpt +++ b/ext/zlib/tests/gzencode_variation2.phpt @@ -8,7 +8,7 @@ if( substr(PHP_OS, 0, 3) == "WIN" ) { } if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } if (PHP_OS == "Darwin") { @@ -17,12 +17,6 @@ if (PHP_OS == "Darwin") { ?> --FILE-- <?php -/* Prototype : string gzencode ( string $data [, int $level [, int $encoding_mode ]] ) - * Description: Gzip-compress a string - * Source code: ext/zlib/zlib.c - * Alias to functions: - */ - echo "*** Testing gzencode() : variation ***\n"; $data = "A small string to encode\n"; @@ -33,7 +27,6 @@ var_dump(bin2hex(gzencode($data, -1, FORCE_GZIP))); var_dump(bin2hex(gzencode($data, -1, FORCE_DEFLATE))); ?> -===DONE=== --EXPECT-- *** Testing gzencode() : variation *** @@ -41,4 +34,3 @@ var_dump(bin2hex(gzencode($data, -1, FORCE_DEFLATE))); string(90) "1f8b0800000000000003735428ce4dccc951282e29cacc4b5728c95748cd4bce4f49e50200d7739de519000000" string(90) "1f8b0800000000000003735428ce4dccc951282e29cacc4b5728c95748cd4bce4f49e50200d7739de519000000" string(66) "789c735428ce4dccc951282e29cacc4b5728c95748cd4bce4f49e50200735808cd" -===DONE=== diff --git a/ext/zlib/tests/gzeof_basic.phpt b/ext/zlib/tests/gzeof_basic.phpt index 33d46599c3..f92450d22b 100644 --- a/ext/zlib/tests/gzeof_basic.phpt +++ b/ext/zlib/tests/gzeof_basic.phpt @@ -3,7 +3,7 @@ Test function feof() by calling it with its expected arguments --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -36,7 +36,6 @@ gzclose($h); ?> -===DONE=== --EXPECT-- -- test 1 -- bool(false) @@ -55,4 +54,3 @@ reading 250 characters. eof should be true bool(true) reading 20 characters. eof should be true still bool(true) -===DONE=== diff --git a/ext/zlib/tests/gzeof_variation1.phpt b/ext/zlib/tests/gzeof_variation1.phpt index 4a845917af..3be013facf 100644 --- a/ext/zlib/tests/gzeof_variation1.phpt +++ b/ext/zlib/tests/gzeof_variation1.phpt @@ -3,7 +3,7 @@ Test function gzeof while writing. --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -18,14 +18,14 @@ var_dump(gzeof($h)); gzwrite( $h, $str, $length); var_dump(gzeof($h)); gzclose($h); -var_dump(gzeof($h)); +try { + var_dump(gzeof($h)); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} unlink($filename); ?> -===DONE=== ---EXPECTF-- +--EXPECT-- bool(false) bool(false) - -Warning: gzeof(): supplied resource is not a valid stream resource in %s on line %d -bool(false) -===DONE=== +gzeof(): supplied resource is not a valid stream resource diff --git a/ext/zlib/tests/gzfile_basic.phpt b/ext/zlib/tests/gzfile_basic.phpt index 56bc8b2d7a..249e225714 100644 --- a/ext/zlib/tests/gzfile_basic.phpt +++ b/ext/zlib/tests/gzfile_basic.phpt @@ -24,7 +24,6 @@ var_dump(gzfile( $filename ) ); unlink($filename); rmdir($dirname); ?> -===DONE=== --EXPECT-- array(3) { [0]=> @@ -36,4 +35,3 @@ array(3) { [2]=> string(17) "for all languages" } -===DONE=== diff --git a/ext/zlib/tests/gzfile_basic2.phpt b/ext/zlib/tests/gzfile_basic2.phpt index 0a968ce394..7507164304 100644 --- a/ext/zlib/tests/gzfile_basic2.phpt +++ b/ext/zlib/tests/gzfile_basic2.phpt @@ -24,7 +24,6 @@ var_dump(gzfile( $filename ) ); unlink($filename); rmdir($dirname); ?> -===DONE=== --EXPECT-- array(3) { [0]=> @@ -36,4 +35,3 @@ array(3) { [2]=> string(17) "for all languages" } -===DONE=== diff --git a/ext/zlib/tests/gzfile_variation11.phpt b/ext/zlib/tests/gzfile_variation11.phpt index 76f0a537b5..2d0c73e647 100644 --- a/ext/zlib/tests/gzfile_variation11.phpt +++ b/ext/zlib/tests/gzfile_variation11.phpt @@ -25,7 +25,6 @@ foreach ( $variation as $var ) { var_dump(gzfile( $filename, $var ) ); } ?> -===DONE=== --EXPECT-- array(6) { [0]=> @@ -127,4 +126,3 @@ array(6) { string(39) "and I know that it descends down on me " } -===DONE=== diff --git a/ext/zlib/tests/gzfile_variation12.phpt b/ext/zlib/tests/gzfile_variation12.phpt index 6b9aec5334..d63d444097 100644 --- a/ext/zlib/tests/gzfile_variation12.phpt +++ b/ext/zlib/tests/gzfile_variation12.phpt @@ -23,7 +23,6 @@ foreach ( $variation as $var ) { var_dump(gzfile( $filename, $var ) ); } ?> -===DONE=== --EXPECT-- array(6) { [0]=> @@ -105,4 +104,3 @@ array(6) { string(39) "and I know that it descends down on me " } -===DONE=== diff --git a/ext/zlib/tests/gzfile_variation15.phpt b/ext/zlib/tests/gzfile_variation15.phpt index 77028fbd09..7fb103b3ec 100644 --- a/ext/zlib/tests/gzfile_variation15.phpt +++ b/ext/zlib/tests/gzfile_variation15.phpt @@ -3,7 +3,7 @@ Test gzfile() function : variation: use include path (relative directories in pa --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -78,7 +78,6 @@ function test_gzfile() { } ?> -===DONE=== --EXPECT-- array(1) { [0]=> @@ -105,4 +104,3 @@ array(1) { string(28) "This is a file in script dir" } -===DONE=== diff --git a/ext/zlib/tests/gzfile_variation3.phpt b/ext/zlib/tests/gzfile_variation3.phpt index 5871b34f78..276c839468 100644 --- a/ext/zlib/tests/gzfile_variation3.phpt +++ b/ext/zlib/tests/gzfile_variation3.phpt @@ -25,26 +25,17 @@ $variation = array( foreach ( $variation as $var ) { - var_dump(gzfile( $var , $use_include_path ) ); + try { + var_dump(gzfile( $var , $use_include_path ) ); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } } ?> -===DONE=== ---EXPECTF-- -Warning: gzfile(): Filename cannot be empty in %s on line %d -bool(false) - -Warning: gzfile(): Filename cannot be empty in %s on line %d -bool(false) - -Warning: gzfile(): Filename cannot be empty in %s on line %d -bool(false) - -Warning: gzfile(): Filename cannot be empty in %s on line %d -bool(false) - -Warning: gzfile(): Filename cannot be empty in %s on line %d -bool(false) - -Warning: gzfile(): Filename cannot be empty in %s on line %d -bool(false) -===DONE=== +--EXPECT-- +Path cannot be empty +Path cannot be empty +Path cannot be empty +Path cannot be empty +Path cannot be empty +Path cannot be empty diff --git a/ext/zlib/tests/gzfile_variation4.phpt b/ext/zlib/tests/gzfile_variation4.phpt index 9b3128125a..e3a90207a0 100644 --- a/ext/zlib/tests/gzfile_variation4.phpt +++ b/ext/zlib/tests/gzfile_variation4.phpt @@ -24,20 +24,18 @@ foreach ( $variation as $var ) { var_dump(gzfile( $var , $use_include_path ) ); } ?> -===DONE=== --EXPECTF-- -Warning: gzfile(10.5): failed to open stream: No such file or directory in %s on line %d +Warning: gzfile(10.5): Failed to open stream: No such file or directory in %s on line %d bool(false) -Warning: gzfile(-10.5): failed to open stream: No such file or directory in %s on line %d +Warning: gzfile(-10.5): Failed to open stream: No such file or directory in %s on line %d bool(false) -Warning: gzfile(123456789000): failed to open stream: No such file or directory in %s on line %d +Warning: gzfile(123456789000): Failed to open stream: No such file or directory in %s on line %d bool(false) -Warning: gzfile(-123456789000): failed to open stream: No such file or directory in %s on line %d +Warning: gzfile(-123456789000): Failed to open stream: No such file or directory in %s on line %d bool(false) -Warning: gzfile(0.5): failed to open stream: No such file or directory in %s on line %d +Warning: gzfile(0.5): Failed to open stream: No such file or directory in %s on line %d bool(false) -===DONE=== diff --git a/ext/zlib/tests/gzfile_variation5.phpt b/ext/zlib/tests/gzfile_variation5.phpt index 1627d2eb11..be3a95f600 100644 --- a/ext/zlib/tests/gzfile_variation5.phpt +++ b/ext/zlib/tests/gzfile_variation5.phpt @@ -23,17 +23,15 @@ foreach ( $variation as $var ) { var_dump(gzfile( $var , $use_include_path ) ); } ?> -===DONE=== --EXPECTF-- -Warning: gzfile(0): failed to open stream: No such file or directory in %s on line %d +Warning: gzfile(0): Failed to open stream: No such file or directory in %s on line %d bool(false) -Warning: gzfile(1): failed to open stream: No such file or directory in %s on line %d +Warning: gzfile(1): Failed to open stream: No such file or directory in %s on line %d bool(false) -Warning: gzfile(12345): failed to open stream: No such file or directory in %s on line %d +Warning: gzfile(12345): Failed to open stream: No such file or directory in %s on line %d bool(false) -Warning: gzfile(-2345): failed to open stream: No such file or directory in %s on line %d +Warning: gzfile(-2345): Failed to open stream: No such file or directory in %s on line %d bool(false) -===DONE=== diff --git a/ext/zlib/tests/gzfile_variation7.phpt b/ext/zlib/tests/gzfile_variation7.phpt index 04fa2e666b..6c9807b733 100644 --- a/ext/zlib/tests/gzfile_variation7.phpt +++ b/ext/zlib/tests/gzfile_variation7.phpt @@ -27,17 +27,15 @@ foreach ( $variation_array as $var ) { var_dump(gzfile( $var , $use_include_path ) ); } ?> -===DONE=== --EXPECTF-- -Warning: gzfile(string): failed to open stream: No such file or directory in %s on line %d +Warning: gzfile(string): Failed to open stream: No such file or directory in %s on line %d bool(false) -Warning: gzfile(string): failed to open stream: No such file or directory in %s on line %d +Warning: gzfile(string): Failed to open stream: No such file or directory in %s on line %d bool(false) -Warning: gzfile(sTrInG): failed to open stream: No such file or directory in %s on line %d +Warning: gzfile(sTrInG): Failed to open stream: No such file or directory in %s on line %d bool(false) -Warning: gzfile(hello world): failed to open stream: No such file or directory in %s on line %d +Warning: gzfile(hello world): Failed to open stream: No such file or directory in %s on line %d bool(false) -===DONE=== diff --git a/ext/zlib/tests/gzfile_variation9.phpt b/ext/zlib/tests/gzfile_variation9.phpt index 8fa994026f..4b848b4037 100644 --- a/ext/zlib/tests/gzfile_variation9.phpt +++ b/ext/zlib/tests/gzfile_variation9.phpt @@ -22,7 +22,6 @@ foreach ( $variation as $var ) { var_dump(gzfile( $filename, $var ) ); } ?> -===DONE=== --EXPECT-- array(6) { [0]=> @@ -104,4 +103,3 @@ array(6) { string(39) "and I know that it descends down on me " } -===DONE=== diff --git a/ext/zlib/tests/gzgetc_basic.phpt b/ext/zlib/tests/gzgetc_basic.phpt index 73dc128bf2..5eff9b6d5d 100644 --- a/ext/zlib/tests/gzgetc_basic.phpt +++ b/ext/zlib/tests/gzgetc_basic.phpt @@ -3,11 +3,11 @@ Test function gzgetc() by calling it with its expected arguments zlib 1.2.5 --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } include 'func.inc'; if (version_compare(get_zlib_version(), '1.2.5') > 0) { - die('skip - only for zlib <= 1.2.5'); + die('skip - only for zlib <= 1.2.5'); } ?> --FILE-- @@ -29,7 +29,6 @@ echo "\ncharacters counted=$count\n"; gzclose($h); ?> -===DONE=== --EXPECT-- When you're taught through feelings Destiny flying high above @@ -39,4 +38,3 @@ as it turns around and I know that it descends down on me characters counted=176 -===DONE=== diff --git a/ext/zlib/tests/gzgetc_basic_1.phpt b/ext/zlib/tests/gzgetc_basic_1.phpt index b555877c8c..49e4ab8f6b 100644 --- a/ext/zlib/tests/gzgetc_basic_1.phpt +++ b/ext/zlib/tests/gzgetc_basic_1.phpt @@ -3,11 +3,11 @@ Test function gzgetc() by calling it with its expected arguments zlib 1.2.7 --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } include 'func.inc'; if (version_compare(get_zlib_version(), '1.2.7') < 0) { - die('skip - only for zlib >= 1.2.7'); + die('skip - only for zlib >= 1.2.7'); } ?> --FILE-- @@ -19,18 +19,17 @@ if (version_compare(get_zlib_version(), '1.2.7') < 0) { $f = __DIR__."/004.txt.gz"; $h = gzopen($f, 'r'); if ($h) { - $count = 0; - while (($c = fgetc( $h )) !== false) { - $count++; - echo $c; - } + $count = 0; + while (($c = fgetc( $h )) !== false) { + $count++; + echo $c; + } - echo "\ncharacters counted=$count\n"; - gzclose($h); + echo "\ncharacters counted=$count\n"; + gzclose($h); } ?> -===DONE=== --EXPECT-- When you're taught through feelings Destiny flying high above @@ -40,4 +39,3 @@ as it turns around and I know that it descends down on me characters counted=176 -===DONE=== diff --git a/ext/zlib/tests/gzgets_basic.phpt b/ext/zlib/tests/gzgets_basic.phpt index 8f2e1c0a20..4f4e908645 100644 --- a/ext/zlib/tests/gzgets_basic.phpt +++ b/ext/zlib/tests/gzgets_basic.phpt @@ -3,7 +3,7 @@ Test function gzgets() by calling it with its expected arguments --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -26,7 +26,6 @@ gzclose($h); ?> -===DONE=== --EXPECT-- string(9) "When you'" string(13) "re taught thr" @@ -43,4 +42,3 @@ string(19) "as it turns around " string(39) "and I know that it descends down on me " -===DONE=== diff --git a/ext/zlib/tests/gzgetss.phpt b/ext/zlib/tests/gzgetss.phpt deleted file mode 100644 index 58d13ab733..0000000000 --- a/ext/zlib/tests/gzgetss.phpt +++ /dev/null @@ -1,32 +0,0 @@ ---TEST-- -gzgetss — Get line from gz-file pointer and strip HTML tags - function ---CREDITS-- -marcosptf - <marcosptf@yahoo.com.br> ---SKIPIF-- -<?php -if(!extension_loaded("zlib")){die("skip - ZLIB extension not loaded");} -?> ---FILE-- -<?php -$handle = gzopen(__DIR__ . '/gzgetss.gz', 'r'); - -while (!gzeof($handle)){ - $buffer = gzgetss($handle, 4096, "<code>"); - print($buffer); -} -gzclose($handle); -?> ---EXPECTF-- -Deprecated: Function gzgetss() is deprecated in %s on line %d - - -Deprecated: Function gzgetss() is deprecated in %s on line %d - - -Deprecated: Function gzgetss() is deprecated in %s on line %d - <code>stringgzgetss(resource $zp, int $length [, string $allowable_tags ]);<code/> - -Deprecated: Function gzgetss() is deprecated in %s on line %d - - -Deprecated: Function gzgetss() is deprecated in %s on line %d diff --git a/ext/zlib/tests/gzinflate_error1.phpt b/ext/zlib/tests/gzinflate_error1.phpt index fd65f54e55..67f2aa438b 100644 --- a/ext/zlib/tests/gzinflate_error1.phpt +++ b/ext/zlib/tests/gzinflate_error1.phpt @@ -3,73 +3,27 @@ Test gzinflate() function : error conditions --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php -/* Prototype : string gzinflate(string data [, int length]) - * Description: Unzip a gzip-compressed string - * Source code: ext/zlib/zlib.c - * Alias to functions: - */ - include(__DIR__ . '/data.inc'); echo "*** Testing gzinflate() : error conditions ***\n"; -echo "\n-- Testing gzcompress() function with Zero arguments --\n"; -var_dump( gzinflate() ); - -echo "\n-- Testing gzcompress() function with more than expected no. of arguments --\n"; -$data = 'string_val'; -$length = 10; -$extra_arg = 10; -var_dump( gzinflate($data, $length, $extra_arg) ); - echo "\n-- Testing with a buffer that is too small --\n"; +$data = 'string_val'; $short_len = strlen($data) - 1; $compressed = gzcompress($data); var_dump(gzinflate($compressed, $short_len)); -echo "\n-- Testing with incorrect parameters --\n"; - -class Tester { - function Hello() { - echo "Hello\n"; - } -} - -$testclass = new Tester(); -var_dump(gzinflate($testclass)); -var_dump(gzinflate($data, $testclass)); - ?> -===DONE=== --EXPECTF-- *** Testing gzinflate() : error conditions *** --- Testing gzcompress() function with Zero arguments -- - -Warning: gzinflate() expects at least 1 parameter, 0 given in %s on line %d -NULL - --- Testing gzcompress() function with more than expected no. of arguments -- - -Warning: gzinflate() expects at most 2 parameters, 3 given in %s on line %d -NULL - -- Testing with a buffer that is too small -- Warning: gzinflate(): data error in %s on line %d bool(false) - --- Testing with incorrect parameters -- - -Warning: gzinflate() expects parameter 1 to be string, object given in %s on line %d -NULL - -Warning: gzinflate() expects parameter 2 to be int, object given in %s on line %d -NULL -===DONE=== diff --git a/ext/zlib/tests/gzopen_basic.phpt b/ext/zlib/tests/gzopen_basic.phpt index 4ef34aea68..cbb4174f9f 100644 --- a/ext/zlib/tests/gzopen_basic.phpt +++ b/ext/zlib/tests/gzopen_basic.phpt @@ -3,17 +3,11 @@ Test gzopen() function : basic functionality --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php -/* Prototype : resource gzopen(string filename, string mode [, int use_include_path]) - * Description: Open a .gz-file and return a .gz-file pointer - * Source code: ext/zlib/zlib.c - * Alias to functions: - */ - echo "*** Testing gzopen() : basic functionality ***\n"; @@ -33,7 +27,6 @@ gzpassthru($h); gzclose($h); ?> -===DONE=== --EXPECT-- *** Testing gzopen() : basic functionality *** When you're taught through feelings @@ -48,4 +41,3 @@ all I know is that you can realize it Destiny who cares as it turns around and I know that it descends down on me -===DONE=== diff --git a/ext/zlib/tests/gzopen_basic2.phpt b/ext/zlib/tests/gzopen_basic2.phpt index dd3ba18235..5814b5168f 100644 --- a/ext/zlib/tests/gzopen_basic2.phpt +++ b/ext/zlib/tests/gzopen_basic2.phpt @@ -3,17 +3,11 @@ Test gzopen() function : basic functionality for writing --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php -/* Prototype : resource gzopen(string filename, string mode [, int use_include_path]) - * Description: Open a .gz-file and return a .gz-file pointer - * Source code: ext/zlib/zlib.c - * Alias to functions: - */ - echo "*** Testing gzopen() : basic functionality ***\n"; @@ -40,13 +34,11 @@ foreach($modes as $mode) { } ?> -===DONE=== --EXPECTF-- *** Testing gzopen() : basic functionality *** testing mode -- w -- This was the information that was written testing mode -- w+ -- -Warning: gzopen(): cannot open a zlib stream for reading and writing at the same time! in %s on line %d +Warning: gzopen(): Cannot open a zlib stream for reading and writing at the same time! in %s on line %d bool(false) -===DONE=== diff --git a/ext/zlib/tests/gzopen_include_path.inc b/ext/zlib/tests/gzopen_include_path.inc index add04f74de..ca3da43489 100644 --- a/ext/zlib/tests/gzopen_include_path.inc +++ b/ext/zlib/tests/gzopen_include_path.inc @@ -11,82 +11,82 @@ $newdirs = array($dir1, $dir2, $dir3); $reldirs = array("dir1", "dir2", "dir3"); function generate_next_rel_path() { - global $reldirs; - //create the include directory structure - $pathSep = ":"; - $newIncludePath = ""; - if(substr(PHP_OS, 0, 3) == 'WIN' ) { - $pathSep = ";"; - } - foreach($reldirs as $newdir) { - $newIncludePath .= $newdir.$pathSep; - } - return "dir4".$pathSep . $newIncludePath; + global $reldirs; + //create the include directory structure + $pathSep = ":"; + $newIncludePath = ""; + if(substr(PHP_OS, 0, 3) == 'WIN' ) { + $pathSep = ";"; + } + foreach($reldirs as $newdir) { + $newIncludePath .= $newdir.$pathSep; + } + return "dir4".$pathSep . $newIncludePath; } function generate_next_path() { - global $newdirs, $dir4; - //create the include directory structure - $pathSep = ":"; - $newIncludePath = ""; - if(substr(PHP_OS, 0, 3) == 'WIN' ) { - $pathSep = ";"; - } - foreach($newdirs as $newdir) { - $newIncludePath .= $newdir.$pathSep; - } - return $dir4.$pathSep . $newIncludePath; + global $newdirs, $dir4; + //create the include directory structure + $pathSep = ":"; + $newIncludePath = ""; + if(substr(PHP_OS, 0, 3) == 'WIN' ) { + $pathSep = ";"; + } + foreach($newdirs as $newdir) { + $newIncludePath .= $newdir.$pathSep; + } + return $dir4.$pathSep . $newIncludePath; } function create_include_path() { - global $newdirs; - //create the include directory structure - $pathSep = ":"; - $newIncludePath = ""; - if(substr(PHP_OS, 0, 3) == 'WIN' ) { - $pathSep = ";"; - } - foreach($newdirs as $newdir) { - mkdir($newdir); - $newIncludePath .= $newdir.$pathSep; - } - return $newIncludePath; + global $newdirs; + //create the include directory structure + $pathSep = ":"; + $newIncludePath = ""; + if(substr(PHP_OS, 0, 3) == 'WIN' ) { + $pathSep = ";"; + } + foreach($newdirs as $newdir) { + mkdir($newdir); + $newIncludePath .= $newdir.$pathSep; + } + return $newIncludePath; } function relative_include_path() { - global $reldirs; - //create the include directory structure - $pathSep = ":"; - $newIncludePath = ""; - if(substr(PHP_OS, 0, 3) == 'WIN' ) { - $pathSep = ";"; - } - foreach($reldirs as $newdir) { - mkdir($newdir); - $newIncludePath .= $newdir.$pathSep; - } - return $newIncludePath; + global $reldirs; + //create the include directory structure + $pathSep = ":"; + $newIncludePath = ""; + if(substr(PHP_OS, 0, 3) == 'WIN' ) { + $pathSep = ";"; + } + foreach($reldirs as $newdir) { + mkdir($newdir); + $newIncludePath .= $newdir.$pathSep; + } + return $newIncludePath; } function teardown_include_path() { - global $newdirs; - // remove the directory structure - foreach($newdirs as $newdir) { - rmdir($newdir); - } + global $newdirs; + // remove the directory structure + foreach($newdirs as $newdir) { + rmdir($newdir); + } } function teardown_relative_path() { - global $reldirs; - // remove the directory structure - foreach($reldirs as $newdir) { - rmdir($newdir); - } + global $reldirs; + // remove the directory structure + foreach($reldirs as $newdir) { + rmdir($newdir); + } } ?> diff --git a/ext/zlib/tests/gzopen_variation4.phpt b/ext/zlib/tests/gzopen_variation4.phpt index 6a00c30670..6505306c45 100644 --- a/ext/zlib/tests/gzopen_variation4.phpt +++ b/ext/zlib/tests/gzopen_variation4.phpt @@ -3,17 +3,11 @@ Test gzopen() function : variation: use include path (relative directories in pa --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php -/* Prototype : resource gzopen(string filename, string mode [, int use_include_path]) - * Description: Open a .gz-file and return a .gz-file pointer - * Source code: ext/zlib/zlib.c - * Alias to functions: - */ - echo "*** Testing gzopen() : usage variation ***\n"; $testName = 'gzopen_variation4'; @@ -31,77 +25,85 @@ foreach($modes as $mode) { chdir($baseDir); rmdir($workingDir); foreach($newdirs as $newdir) { - rmdir($newdir); + rmdir($newdir); } chdir(".."); rmdir($thisTestDir); function test_gzopen($mode) { - global $scriptFile, $secondFile, $firstFile, $filename; - - // create a file in the middle directory - $h = gzopen($secondFile, "w"); - gzwrite($h, "This is a file in dir2"); - gzclose($h); - - echo "\n** testing with mode=$mode **\n"; - // should read dir2 file - $h = gzopen($filename, $mode, true); - gzpassthru($h); - gzclose($h); - echo "\n"; - - //create a file in dir1 - $h = gzopen($firstFile, "w"); - gzwrite($h, "This is a file in dir1"); - gzclose($h); - - //should now read dir1 file - $h = gzopen($filename, $mode, true); - gzpassthru($h); - gzclose($h); - echo "\n"; - - // create a file in working directory - $h = gzopen($filename, "w"); - gzwrite($h, "This is a file in working dir"); - gzclose($h); - - //should still read dir1 file - $h = gzopen($filename, $mode, true); - gzpassthru($h); - gzclose($h); - echo "\n"; - - unlink($firstFile); - unlink($secondFile); - - //should read the file in working dir - $h = gzopen($filename, $mode, true); - gzpassthru($h); - gzclose($h); - echo "\n"; - - // create a file in the script directory - $h = gzopen($scriptFile, "w"); - gzwrite($h, "This is a file in script dir"); - gzclose($h); - - //should read the file in script dir - $h = gzopen($filename, $mode, true); - gzpassthru($h); - gzclose($h); - echo "\n"; - - //cleanup - unlink($filename); - unlink($scriptFile); - + global $scriptFile, $secondFile, $firstFile, $filename; + + // create a file in the middle directory + $h = gzopen($secondFile, "w"); + gzwrite($h, "This is a file in dir2"); + gzclose($h); + + echo "\n** testing with mode=$mode **\n"; + // should read dir2 file + $h = gzopen($filename, $mode, true); + if ($h) { + gzpassthru($h); + gzclose($h); + echo "\n"; + } + + //create a file in dir1 + $h = gzopen($firstFile, "w"); + gzwrite($h, "This is a file in dir1"); + gzclose($h); + + //should now read dir1 file + $h = gzopen($filename, $mode, true); + if ($h) { + gzpassthru($h); + gzclose($h); + echo "\n"; + } + + // create a file in working directory + $h = gzopen($filename, "w"); + gzwrite($h, "This is a file in working dir"); + gzclose($h); + + //should still read dir1 file + $h = gzopen($filename, $mode, true); + if ($h) { + gzpassthru($h); + gzclose($h); + echo "\n"; + } + + unlink($firstFile); + unlink($secondFile); + + //should read the file in working dir + $h = gzopen($filename, $mode, true); + if ($h) { + gzpassthru($h); + gzclose($h); + echo "\n"; + } + + // create a file in the script directory + $h = gzopen($scriptFile, "w"); + gzwrite($h, "This is a file in script dir"); + gzclose($h); + + //should read the file in script dir + $h = gzopen($filename, $mode, true); + if ($h) { + gzpassthru($h); + gzclose($h); + echo "\n"; + } + + //cleanup + unlink($filename); + unlink($scriptFile); } ?> -===DONE=== --EXPECTF-- *** Testing gzopen() : usage variation *** @@ -116,40 +118,15 @@ This is a file in script dir ** testing with mode=r+ ** -Warning: gzopen(): cannot open a zlib stream for reading and writing at the same time! in %s on line %d - -Warning: gzpassthru() expects parameter 1 to be resource, bool given in %s on line %d - -Warning: gzclose() expects parameter 1 to be resource, bool given in %s on line %d - - -Warning: gzopen(): cannot open a zlib stream for reading and writing at the same time! in %s on line %d - -Warning: gzpassthru() expects parameter 1 to be resource, bool given in %s on line %d - -Warning: gzclose() expects parameter 1 to be resource, bool given in %s on line %d - - -Warning: gzopen(): cannot open a zlib stream for reading and writing at the same time! in %s on line %d - -Warning: gzpassthru() expects parameter 1 to be resource, bool given in %s on line %d - -Warning: gzclose() expects parameter 1 to be resource, bool given in %s on line %d - - -Warning: gzopen(): cannot open a zlib stream for reading and writing at the same time! in %s on line %d - -Warning: gzpassthru() expects parameter 1 to be resource, bool given in %s on line %d - -Warning: gzclose() expects parameter 1 to be resource, bool given in %s on line %d - +Warning: gzopen(): Cannot open a zlib stream for reading and writing at the same time! in %s on line %d -Warning: gzopen(): cannot open a zlib stream for reading and writing at the same time! in %s on line %d +Warning: gzopen(): Cannot open a zlib stream for reading and writing at the same time! in %s on line %d -Warning: gzpassthru() expects parameter 1 to be resource, bool given in %s on line %d +Warning: gzopen(): Cannot open a zlib stream for reading and writing at the same time! in %s on line %d -Warning: gzclose() expects parameter 1 to be resource, bool given in %s on line %d +Warning: gzopen(): Cannot open a zlib stream for reading and writing at the same time! in %s on line %d +Warning: gzopen(): Cannot open a zlib stream for reading and writing at the same time! in %s on line %d ** testing with mode=rt ** This is a file in dir2 @@ -157,4 +134,3 @@ This is a file in dir1 This is a file in dir1 This is a file in working dir This is a file in script dir -===DONE=== diff --git a/ext/zlib/tests/gzopen_variation5.phpt b/ext/zlib/tests/gzopen_variation5.phpt index 99ba6a0b96..e06c358d80 100644 --- a/ext/zlib/tests/gzopen_variation5.phpt +++ b/ext/zlib/tests/gzopen_variation5.phpt @@ -3,17 +3,11 @@ Test gzopen() function : variation: use include path and stream context create a --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php -/* Prototype : resource gzopen(string filename, string mode [, int use_include_path]) - * Description: Open a .gz-file and return a .gz-file pointer - * Source code: ext/zlib/zlib.c - * Alias to functions: - */ - require_once('gzopen_include_path.inc'); echo "*** Testing gzopen() : variation ***\n"; @@ -33,38 +27,36 @@ chdir(".."); rmdir($thisTestDir); function runtest() { - $tmpfile = 'gzopen_variation5.tmp'; - $h = gzopen($tmpfile, "w", true); - fwrite($h, "This is the test file"); - fclose($h); - - - $h = @gzopen($tmpfile, "r"); - if ($h === false) { - echo "Not created in working dir\n"; - } - else { - echo "created in working dir\n"; - gzclose($h); - unlink($tmpfile); - } - - $h = @gzopen('dir1/'.$tmpfile, "r"); - if ($h === false) { - echo "Not created in dir1\n"; - } - else { - echo "created in dir1\n"; - gzclose($h); - unlink('dir1/'.$tmpfile); - } + $tmpfile = 'gzopen_variation5.tmp'; + $h = gzopen($tmpfile, "w", true); + fwrite($h, "This is the test file"); + fclose($h); + + + $h = @gzopen($tmpfile, "r"); + if ($h === false) { + echo "Not created in working dir\n"; + } + else { + echo "created in working dir\n"; + gzclose($h); + unlink($tmpfile); + } + + $h = @gzopen('dir1/'.$tmpfile, "r"); + if ($h === false) { + echo "Not created in dir1\n"; + } + else { + echo "created in dir1\n"; + gzclose($h); + unlink('dir1/'.$tmpfile); + } } ?> -===DONE=== --EXPECT-- *** Testing gzopen() : variation *** created in working dir Not created in dir1 created in working dir Not created in dir1 -===DONE=== diff --git a/ext/zlib/tests/gzopen_variation6.phpt b/ext/zlib/tests/gzopen_variation6.phpt index 07f873a8dd..16b266db65 100644 --- a/ext/zlib/tests/gzopen_variation6.phpt +++ b/ext/zlib/tests/gzopen_variation6.phpt @@ -3,17 +3,11 @@ Test gzopen() function : variation: relative/absolute file --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php -/* Prototype : resource gzopen(string filename, string mode [, int use_include_path]) - * Description: Open a .gz-file and return a .gz-file pointer - * Source code: ext/zlib/zlib.c - * Alias to functions: - */ - echo "*** Testing gzopen() : variation ***\n"; $absfile = __FILE__.'.tmp'; $relfile = "gzopen_variation6.tmp"; @@ -39,9 +33,7 @@ echo "\n"; unlink($absfile); unlink($relfile); ?> -===DONE=== --EXPECT-- *** Testing gzopen() : variation *** This is an absolute file This is a relative file -===DONE=== diff --git a/ext/zlib/tests/gzopen_variation7.phpt b/ext/zlib/tests/gzopen_variation7.phpt index 0e499e0d37..7eef44a702 100644 --- a/ext/zlib/tests/gzopen_variation7.phpt +++ b/ext/zlib/tests/gzopen_variation7.phpt @@ -3,7 +3,7 @@ Test function gzopen() by calling it twice on the same file and not closing one --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -20,7 +20,6 @@ gzclose($h1); var_dump(gzread($h2, 50)); // deliberately do not close $h2 ?> -===DONE=== --EXPECT-- string(30) "When you're taught through fee" string(10) "When you'r" @@ -28,4 +27,3 @@ string(15) "lings Destiny f" string(50) "e taught through feelings Destiny flying high abov" -===DONE=== diff --git a/ext/zlib/tests/gzopen_variation8.phpt b/ext/zlib/tests/gzopen_variation8.phpt index bb64ecab16..b2b12276eb 100644 --- a/ext/zlib/tests/gzopen_variation8.phpt +++ b/ext/zlib/tests/gzopen_variation8.phpt @@ -3,17 +3,11 @@ Test gzopen() function : variation: opening a plain file --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php -/* Prototype : resource gzopen(string filename, string mode [, int use_include_path]) - * Description: Open a .gz-file and return a .gz-file pointer - * Source code: ext/zlib/zlib.c - * Alias to functions: - */ - echo "*** Testing gzopen() : variation ***\n"; $data = <<<EOT @@ -33,10 +27,8 @@ gzclose($h); echo "\n"; unlink($file); ?> -===DONE=== --EXPECT-- *** Testing gzopen() : variation *** Here is some plain text to be read and displayed. -===DONE=== diff --git a/ext/zlib/tests/gzopen_variation9.phpt b/ext/zlib/tests/gzopen_variation9.phpt index d948b435ca..b8b895a92d 100644 --- a/ext/zlib/tests/gzopen_variation9.phpt +++ b/ext/zlib/tests/gzopen_variation9.phpt @@ -3,17 +3,11 @@ Test gzopen() function : variation: try opening with possibly invalid modes --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php -/* Prototype : resource gzopen(string filename, string mode [, int use_include_path]) - * Description: Open a .gz-file and return a .gz-file pointer - * Source code: ext/zlib/zlib.c - * Alias to functions: - */ - echo "*** Testing gzopen() : variation ***\n"; $modes = array('r+', 'rf', 'w+' , 'e'); @@ -31,12 +25,11 @@ foreach ($modes as $mode) { echo "\n"; } ?> -===DONE=== --EXPECTF-- *** Testing gzopen() : variation *** mode=r+ -Warning: gzopen(): cannot open a zlib stream for reading and writing at the same time! in %s on line %d +Warning: gzopen(): Cannot open a zlib stream for reading and writing at the same time! in %s on line %d gzopen=bool(false) mode=rf @@ -44,12 +37,11 @@ gzopen=resource(%d) of type (stream) mode=w+ -Warning: gzopen(): cannot open a zlib stream for reading and writing at the same time! in %s on line %d +Warning: gzopen(): Cannot open a zlib stream for reading and writing at the same time! in %s on line %d gzopen=bool(false) mode=e -Warning: gzopen(%s/004.txt.gz): failed to open stream: %s in %s on line %d +Warning: gzopen(%s/004.txt.gz): Failed to open stream: %s in %s on line %d gzopen=bool(false) -===DONE=== diff --git a/ext/zlib/tests/gzpassthru_basic.phpt b/ext/zlib/tests/gzpassthru_basic.phpt index 2747edc786..4ca2780b41 100644 --- a/ext/zlib/tests/gzpassthru_basic.phpt +++ b/ext/zlib/tests/gzpassthru_basic.phpt @@ -3,7 +3,7 @@ Test function gzpassthru() by calling it with its expected arguments --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -19,7 +19,6 @@ var_dump(gzpassthru($h)); gzclose($h); ?> -===DONE=== --EXPECT-- When you're taught through feelings Destiny flying high above @@ -29,4 +28,3 @@ as it turns around and I know that it descends down on me int(176) int(0) -===DONE=== diff --git a/ext/zlib/tests/gzputs_basic.phpt b/ext/zlib/tests/gzputs_basic.phpt index a9bd682c14..6fd4d0748d 100644 --- a/ext/zlib/tests/gzputs_basic.phpt +++ b/ext/zlib/tests/gzputs_basic.phpt @@ -3,7 +3,7 @@ Test function gzputs() by calling it with its expected arguments --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -23,9 +23,7 @@ gzclose($h); echo "\n"; unlink($filename); ?> -===DONE=== --EXPECT-- int(34) int(10) Here is the string to be written. Here is th -===DONE=== diff --git a/ext/zlib/tests/gzread_basic.phpt b/ext/zlib/tests/gzread_basic.phpt index 813fcd8616..356eb2c845 100644 --- a/ext/zlib/tests/gzread_basic.phpt +++ b/ext/zlib/tests/gzread_basic.phpt @@ -3,7 +3,7 @@ Test function gzread() by calling it with its expected arguments --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -21,7 +21,6 @@ foreach ($lengths as $length) { gzclose($h); ?> -===DONE=== --EXPECT-- string(10) "When you'r" string(14) "e taught throu" @@ -34,4 +33,3 @@ as it turns " string(46) "around and I know that it descends down on me " -===DONE=== diff --git a/ext/zlib/tests/gzread_error2.phpt b/ext/zlib/tests/gzread_error2.phpt index a419f96640..0b4c4d13fc 100644 --- a/ext/zlib/tests/gzread_error2.phpt +++ b/ext/zlib/tests/gzread_error2.phpt @@ -3,7 +3,7 @@ Test function gzread() by calling it invalid lengths --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -11,22 +11,24 @@ if (!extension_loaded("zlib")) { $f = __DIR__."/004.txt.gz"; $h = gzopen($f, 'r'); var_dump(gzread($h, 10)); -var_dump(gzread($h, 0)); +try { + var_dump(gzread($h, 0)); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} var_dump(gzread($h, 5)); -var_dump(gzread($h, -1)); +try { + var_dump(gzread($h, -1)); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} var_dump(gzread($h, 8)); gzclose($h); ?> -===DONE=== ---EXPECTF-- +--EXPECT-- string(10) "When you'r" - -Warning: gzread(): Length parameter must be greater than 0 in %s on line %d -bool(false) +gzread(): Argument #2 ($length) must be greater than 0 string(5) "e tau" - -Warning: gzread(): Length parameter must be greater than 0 in %s on line %d -bool(false) +gzread(): Argument #2 ($length) must be greater than 0 string(8) "ght thro" -===DONE=== diff --git a/ext/zlib/tests/gzread_variation1.phpt b/ext/zlib/tests/gzread_variation1.phpt index 9cf4b9c739..f5968e28ad 100644 --- a/ext/zlib/tests/gzread_variation1.phpt +++ b/ext/zlib/tests/gzread_variation1.phpt @@ -3,7 +3,7 @@ Test function gzread() by calling it while file open for writing --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -25,10 +25,8 @@ gzclose($h); echo "\n"; unlink($filename); ?> -===DONE=== --EXPECT-- bool(false) bool(false) bool(false) Here is the string to be written. -===DONE=== diff --git a/ext/zlib/tests/gzreadgzwrite.phpt b/ext/zlib/tests/gzreadgzwrite.phpt index 87b55e673f..f2f2370f36 100644 --- a/ext/zlib/tests/gzreadgzwrite.phpt +++ b/ext/zlib/tests/gzreadgzwrite.phpt @@ -18,14 +18,14 @@ $fp = gzopen($filename, "rb"); $data = ''; while ($buf = gzread($fp, 8092)) { - $data .= $buf; + $data .= $buf; } if ($data == $original) { - echo "Strings are equal\n"; + echo "Strings are equal\n"; } else { - echo "Strings are not equal\n"; - var_dump($data); + echo "Strings are not equal\n"; + var_dump($data); } gzclose($fp); unlink($filename); diff --git a/ext/zlib/tests/gzreadgzwriteplain.phpt b/ext/zlib/tests/gzreadgzwriteplain.phpt index 0d73f022aa..8898cebb93 100644 --- a/ext/zlib/tests/gzreadgzwriteplain.phpt +++ b/ext/zlib/tests/gzreadgzwriteplain.phpt @@ -18,29 +18,29 @@ $fp = gzopen($filename, "rb"); $data = ''; while ($buf = gzread($fp, 8192)) { - $data .= $buf; + $data .= $buf; } if ($data == $original) { - echo "Strings are equal\n"; + echo "Strings are equal\n"; } else { - echo "Strings are not equal\n"; - var_dump($data); + echo "Strings are not equal\n"; + var_dump($data); } gzseek($fp, strlen($original) / 2); $data = ''; while ($buf = gzread($fp, 8192)) { - $data .= $buf; + $data .= $buf; } var_dump(strlen($data)); if ($data == substr($original, strlen($original) / 2)) { - echo "Strings are equal\n"; + echo "Strings are equal\n"; } else { - echo "Strings are not equal\n"; - var_dump($data); + echo "Strings are not equal\n"; + var_dump($data); } gzclose($fp); diff --git a/ext/zlib/tests/gzrewind_basic.phpt b/ext/zlib/tests/gzrewind_basic.phpt index 3a34f49797..ffed16d4e9 100644 --- a/ext/zlib/tests/gzrewind_basic.phpt +++ b/ext/zlib/tests/gzrewind_basic.phpt @@ -3,7 +3,7 @@ Test function gzrewind() by calling it with its expected arguments when reading --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -22,7 +22,6 @@ gzrewind($h); echo "first 20 characters=".gzread($h, 20)."\n"; gzclose($h); ?> -===DONE=== --EXPECT-- test rewind before doing anything bool(true) @@ -33,4 +32,3 @@ int(30) int(0) first 10 characters=When you'r first 20 characters=When you're taught t -===DONE=== diff --git a/ext/zlib/tests/gzrewind_basic2.phpt b/ext/zlib/tests/gzrewind_basic2.phpt index 2648966b7d..1522750c5b 100644 --- a/ext/zlib/tests/gzrewind_basic2.phpt +++ b/ext/zlib/tests/gzrewind_basic2.phpt @@ -3,7 +3,7 @@ Test function gzrewind() by calling it with its expected arguments when reading --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -23,7 +23,6 @@ echo "first 20 characters=".gzread($h,20)."\n"; gzclose($h); ?> -===DONE=== --EXPECT-- read to the end of the file, then rewind bool(true) @@ -31,4 +30,3 @@ int(176) bool(false) int(0) first 20 characters=When you're taught t -===DONE=== diff --git a/ext/zlib/tests/gzrewind_variation1.phpt b/ext/zlib/tests/gzrewind_variation1.phpt index 09acb55d80..0b2053993d 100644 --- a/ext/zlib/tests/gzrewind_variation1.phpt +++ b/ext/zlib/tests/gzrewind_variation1.phpt @@ -3,7 +3,7 @@ Test function gzrewind() by calling it with its expected arguments when writing --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -21,8 +21,6 @@ gzclose($h); unlink($f); echo "\n"; ?> -===DONE=== --EXPECT-- bool(false) The first string.The second string. -===DONE=== diff --git a/ext/zlib/tests/gzseek_basic.phpt b/ext/zlib/tests/gzseek_basic.phpt index e31e25f380..9a835f8df5 100644 --- a/ext/zlib/tests/gzseek_basic.phpt +++ b/ext/zlib/tests/gzseek_basic.phpt @@ -3,7 +3,7 @@ Test function gzseek() by calling it with its expected arguments when reading --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -30,7 +30,6 @@ echo "tell=".gztell($h)."\n"; var_dump(gzread($h, 10)); gzclose($h); ?> -===DONE=== --EXPECT-- move to the 50th byte int(0) @@ -46,4 +45,3 @@ move backward to the 20th byte int(0) tell=20 string(10) "hrough fee" -===DONE=== diff --git a/ext/zlib/tests/gzseek_basic2.phpt b/ext/zlib/tests/gzseek_basic2.phpt index 70b0d1f046..c9d60ebcfd 100644 --- a/ext/zlib/tests/gzseek_basic2.phpt +++ b/ext/zlib/tests/gzseek_basic2.phpt @@ -3,7 +3,7 @@ Test function gzseek() by calling it with its expected arguments when writing --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -29,7 +29,6 @@ echo gzread($h, strlen($str2))."\n"; gzclose($h); unlink($f); ?> -===DONE=== --EXPECT-- tell=23 tell=43 @@ -39,4 +38,3 @@ reading the output file This is the first line. string(40) "0000000000000000000000000000000000000000" This is the second line. -===DONE=== diff --git a/ext/zlib/tests/gzseek_variation1.phpt b/ext/zlib/tests/gzseek_variation1.phpt index 28eff866f9..e5dcefc9bb 100644 --- a/ext/zlib/tests/gzseek_variation1.phpt +++ b/ext/zlib/tests/gzseek_variation1.phpt @@ -3,7 +3,7 @@ Test function gzseek() by seeking forward in write mode --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -25,9 +25,7 @@ echo gzread($h, strlen($str2))."\n"; gzclose($h); unlink($f); ?> -===DONE=== --EXPECT-- This is the first line. string(40) "0000000000000000000000000000000000000000" This is the second line. -===DONE=== diff --git a/ext/zlib/tests/gzseek_variation2.phpt b/ext/zlib/tests/gzseek_variation2.phpt index 14ae30a09a..50ad28f36f 100644 --- a/ext/zlib/tests/gzseek_variation2.phpt +++ b/ext/zlib/tests/gzseek_variation2.phpt @@ -3,7 +3,7 @@ Test function gzseek() by calling it with SEEK_SET when reading --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -30,7 +30,6 @@ echo "tell=".gztell($h)."\n"; var_dump(gzread($h, 10)); gzclose($h); ?> -===DONE=== --EXPECT-- move to the 50th byte int(0) @@ -46,4 +45,3 @@ move backward to the 20th byte int(0) tell=20 string(10) "hrough fee" -===DONE=== diff --git a/ext/zlib/tests/gzseek_variation3.phpt b/ext/zlib/tests/gzseek_variation3.phpt index d238fe96bd..0ba9eb68ea 100644 --- a/ext/zlib/tests/gzseek_variation3.phpt +++ b/ext/zlib/tests/gzseek_variation3.phpt @@ -3,7 +3,7 @@ Test function gzseek() by calling it with SEEK_CUR when reading --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -30,7 +30,6 @@ echo "tell=".gztell($h)."\n"; var_dump(gzread($h, 10)); gzclose($h); ?> -===DONE=== --EXPECT-- move to the 50th byte int(0) @@ -47,4 +46,3 @@ move backward to the 77th byte int(0) tell=77 string(10) "hat you ca" -===DONE=== diff --git a/ext/zlib/tests/gzseek_variation4.phpt b/ext/zlib/tests/gzseek_variation4.phpt index 3121e587ad..2850efa7d6 100644 --- a/ext/zlib/tests/gzseek_variation4.phpt +++ b/ext/zlib/tests/gzseek_variation4.phpt @@ -3,7 +3,7 @@ Test function gzseek() by calling it with SEEK_SET when writing --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -29,7 +29,6 @@ echo gzread($h, strlen($str2))."\n"; gzclose($h); unlink($f); ?> -===DONE=== --EXPECT-- tell=23 tell=43 @@ -39,4 +38,3 @@ reading the output file This is the first line. string(40) "0000000000000000000000000000000000000000" This is the second line. -===DONE=== diff --git a/ext/zlib/tests/gzseek_variation5.phpt b/ext/zlib/tests/gzseek_variation5.phpt index b38b46558e..41d5c777a6 100644 --- a/ext/zlib/tests/gzseek_variation5.phpt +++ b/ext/zlib/tests/gzseek_variation5.phpt @@ -3,7 +3,7 @@ Test function gzseek() by calling it with SEEK_CUR when writing --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -29,7 +29,6 @@ echo gzread($h, strlen($str2))."\n"; gzclose($h); unlink($f); ?> -===DONE=== --EXPECT-- tell=23 tell=43 @@ -39,4 +38,3 @@ reading the output file This is the first line. string(40) "0000000000000000000000000000000000000000" This is the second line. -===DONE=== diff --git a/ext/zlib/tests/gzseek_variation6.phpt b/ext/zlib/tests/gzseek_variation6.phpt index 54a52dce3c..1c2e6de562 100644 --- a/ext/zlib/tests/gzseek_variation6.phpt +++ b/ext/zlib/tests/gzseek_variation6.phpt @@ -3,7 +3,7 @@ Test function gzseek() by calling it with SEEK_END when reading --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -25,7 +25,6 @@ var_dump(gzeof($h)); var_dump(gzread($h, 10)); gzclose($h); ?> -===DONE=== --EXPECTF-- move 40 bytes tell=int(40) @@ -36,4 +35,3 @@ int(-1) tell=int(40) eof=bool(false) string(10) "iny flying" -===DONE=== diff --git a/ext/zlib/tests/gzseek_variation7.phpt b/ext/zlib/tests/gzseek_variation7.phpt index a1976b2b16..1198e56ced 100644 --- a/ext/zlib/tests/gzseek_variation7.phpt +++ b/ext/zlib/tests/gzseek_variation7.phpt @@ -3,7 +3,7 @@ Test function gzseek() by calling it with SEEK_END when writing --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -32,7 +32,6 @@ gzclose($h); echo "\n"; unlink($f); ?> -===DONE=== --EXPECTF-- tell=int(23) move to the end of the file @@ -44,4 +43,3 @@ tell=int(47) reading the output file This is the first line.This is the second line. -===DONE=== diff --git a/ext/zlib/tests/gztell_basic.phpt b/ext/zlib/tests/gztell_basic.phpt index 181295c097..063bae63bb 100644 --- a/ext/zlib/tests/gztell_basic.phpt +++ b/ext/zlib/tests/gztell_basic.phpt @@ -3,7 +3,7 @@ Test function gztell() by calling it with its expected arguments when reading --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -21,7 +21,6 @@ foreach ($intervals as $interval) { gzclose($h); ?> -===DONE=== --EXPECT-- int(0) int(7) @@ -31,4 +30,3 @@ int(100) int(127) int(142) int(176) -===DONE=== diff --git a/ext/zlib/tests/gztell_basic2.phpt b/ext/zlib/tests/gztell_basic2.phpt index 59808d7596..b9d9eb0837 100644 --- a/ext/zlib/tests/gztell_basic2.phpt +++ b/ext/zlib/tests/gztell_basic2.phpt @@ -3,7 +3,7 @@ Test function gztell() by calling it with its expected arguments when writing --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -22,7 +22,6 @@ foreach ($sizes as $size) { gzclose($h); unlink($f); ?> -===DONE=== --EXPECT-- int(0) bytes written=7 @@ -39,4 +38,3 @@ bytes written=15 tell=142 bytes written=1000 tell=1142 -===DONE=== diff --git a/ext/zlib/tests/gzuncompress_basic1.phpt b/ext/zlib/tests/gzuncompress_basic1.phpt index 6107a59e4f..c46e8b35eb 100644 --- a/ext/zlib/tests/gzuncompress_basic1.phpt +++ b/ext/zlib/tests/gzuncompress_basic1.phpt @@ -3,17 +3,11 @@ Test gzuncompress() function : basic functionality --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php -/* Prototype : string gzuncompress(string data [, int length]) - * Description: Unzip a gzip-compressed string - * Source code: ext/zlib/zlib.c - * Alias to functions: - */ - include(__DIR__ . '/data.inc'); echo "*** Testing gzuncompress() : basic functionality ***\n"; @@ -31,7 +25,6 @@ echo "\n-- Calling gzuncompress() with max length of $length --\n"; echo "Result length is ". strlen(gzuncompress($compressed, $length)) . "\n"; ?> -===DONE=== --EXPECT-- *** Testing gzuncompress() : basic functionality *** @@ -40,4 +33,3 @@ int(0) -- Calling gzuncompress() with max length of 3547 -- Result length is 3547 -===DONE=== diff --git a/ext/zlib/tests/gzuncompress_error1.phpt b/ext/zlib/tests/gzuncompress_error1.phpt index f200951d4c..a93de5b054 100644 --- a/ext/zlib/tests/gzuncompress_error1.phpt +++ b/ext/zlib/tests/gzuncompress_error1.phpt @@ -3,31 +3,15 @@ Test gzuncompress() function : error conditions --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- <?php -/* Prototype : string gzuncompress(string data [, int length]) - * Description: Unzip a gzip-compressed string - * Source code: ext/zlib/zlib.c - * Alias to functions: - */ - echo "*** Testing gzuncompress() : error conditions ***\n"; -// Zero arguments -echo "\n-- Testing gzuncompress() function with Zero arguments --\n"; -var_dump( gzuncompress() ); - -//Test gzuncompress with one more than the expected number of arguments -echo "\n-- Testing gzuncompress() function with more than expected no. of arguments --\n"; -$data = 'string_val'; -$length = 10; -$extra_arg = 10; -var_dump( gzuncompress($data, $length, $extra_arg) ); - echo "\n-- Testing with a buffer that is too small --\n"; +$data = 'string_val'; $short_len = strlen($data) - 1; $compressed = gzcompress($data); @@ -36,32 +20,10 @@ var_dump(gzuncompress($compressed, $short_len)); echo "\n-- Testing with incorrect arguments --\n"; var_dump(gzuncompress(123)); -class Tester { - function Hello() { - echo "Hello\n"; - } -} - -$testclass = new Tester(); -var_dump(gzuncompress($testclass)); - -var_dump(gzuncompress($compressed, "this is not a number\n")); - ?> -===DONE=== --EXPECTF-- *** Testing gzuncompress() : error conditions *** --- Testing gzuncompress() function with Zero arguments -- - -Warning: gzuncompress() expects at least 1 parameter, 0 given in %s on line %d -NULL - --- Testing gzuncompress() function with more than expected no. of arguments -- - -Warning: gzuncompress() expects at most 2 parameters, 3 given in %s on line %d -NULL - -- Testing with a buffer that is too small -- Warning: gzuncompress(): insufficient memory in %s on line %d @@ -71,10 +33,3 @@ bool(false) Warning: gzuncompress(): data error in %s on line %d bool(false) - -Warning: gzuncompress() expects parameter 1 to be string, object given in %s on line %d -NULL - -Warning: gzuncompress() expects parameter 2 to be int, string given in %s on line %d -NULL -===DONE=== diff --git a/ext/zlib/tests/gzwrite_basic.phpt b/ext/zlib/tests/gzwrite_basic.phpt index 7d3700b8cf..699b2f4993 100644 --- a/ext/zlib/tests/gzwrite_basic.phpt +++ b/ext/zlib/tests/gzwrite_basic.phpt @@ -3,7 +3,7 @@ Test function gzwrite() by calling it with its expected arguments --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -23,9 +23,7 @@ gzclose($h); echo "\n"; unlink($filename); ?> -===DONE=== --EXPECT-- int(34) int(10) Here is the string to be written. Here is th -===DONE=== diff --git a/ext/zlib/tests/gzwrite_error2.phpt b/ext/zlib/tests/gzwrite_error2.phpt index 0cd0baa14e..009cb4d7d2 100644 --- a/ext/zlib/tests/gzwrite_error2.phpt +++ b/ext/zlib/tests/gzwrite_error2.phpt @@ -3,7 +3,7 @@ Test function gzwrite() by calling it invalid lengths --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -22,9 +22,7 @@ gzclose($h); echo "\n"; unlink($filename); ?> -===DONE=== --EXPECT-- int(0) int(0) -===DONE=== diff --git a/ext/zlib/tests/gzwrite_variation1.phpt b/ext/zlib/tests/gzwrite_variation1.phpt index 6061ef1a0f..540a87985a 100644 --- a/ext/zlib/tests/gzwrite_variation1.phpt +++ b/ext/zlib/tests/gzwrite_variation1.phpt @@ -3,7 +3,7 @@ Test function gzwrite() by calling it when file is opened for reading --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -19,9 +19,7 @@ var_dump(gzwrite( $h, $str, $length ) ); gzclose($h); ?> -===DONE=== --EXPECT-- int(0) string(10) "When you'r" int(0) -===DONE=== diff --git a/ext/zlib/tests/inflate_add_error.phpt b/ext/zlib/tests/inflate_add_error.phpt index 3bc04a0b7c..3379219752 100644 --- a/ext/zlib/tests/inflate_add_error.phpt +++ b/ext/zlib/tests/inflate_add_error.phpt @@ -8,15 +8,23 @@ if (!extension_loaded("zlib")) { ?> --FILE-- <?php + $badResource = fopen("php://memory", "r+"); -var_dump(inflate_add($badResource, "test")); +try { + var_dump(inflate_add($badResource, "test")); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} + $resource = inflate_init(ZLIB_ENCODING_DEFLATE); $badFlushType = 6789; -var_dump(inflate_add($resource, "test", $badFlushType)); -?> ---EXPECTF-- -Warning: inflate_add(): Invalid zlib.inflate resource in %s on line %d -bool(false) +try { + var_dump(inflate_add($resource, "test", $badFlushType)); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} -Warning: inflate_add(): flush mode must be ZLIB_NO_FLUSH, ZLIB_PARTIAL_FLUSH, ZLIB_SYNC_FLUSH, ZLIB_FULL_FLUSH, ZLIB_BLOCK or ZLIB_FINISH in %s on line %d -bool(false) +?> +--EXPECT-- +inflate_add(): Argument #1 ($context) must be of type InflateContext, resource given +inflate_add(): Argument #3 ($flush_mode) must be one of ZLIB_NO_FLUSH, ZLIB_PARTIAL_FLUSH, ZLIB_SYNC_FLUSH, ZLIB_FULL_FLUSH, ZLIB_BLOCK, or ZLIB_FINISH diff --git a/ext/zlib/tests/inflate_init_error.phpt b/ext/zlib/tests/inflate_init_error.phpt index 58773e61d3..1aae9b792b 100644 --- a/ext/zlib/tests/inflate_init_error.phpt +++ b/ext/zlib/tests/inflate_init_error.phpt @@ -8,12 +8,13 @@ if (!extension_loaded("zlib")) { ?> --FILE-- <?php -var_dump(inflate_init()); -var_dump(inflate_init(42)); -?> ---EXPECTF-- -Warning: inflate_init() expects at least 1 parameter, 0 given in %s on line %d -NULL -Warning: inflate_init(): encoding mode must be ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE in %s on line %d -bool(false) +try { + var_dump(inflate_init(42)); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} + +?> +--EXPECT-- +Encoding mode must be ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE diff --git a/ext/zlib/tests/ob_gzhandler_legacy_002.phpt b/ext/zlib/tests/ob_gzhandler_legacy_002.phpt index 217a0d2e35..5e940b6187 100644 --- a/ext/zlib/tests/ob_gzhandler_legacy_002.phpt +++ b/ext/zlib/tests/ob_gzhandler_legacy_002.phpt @@ -14,8 +14,8 @@ dummy=42 --FILE-- <?php if (false !== ob_gzhandler("", PHP_OUTPUT_HANDLER_START)) { - ini_set("zlib.output_compression", 0); - ob_start("ob_gzhandler"); + ini_set("zlib.output_compression", 0); + ob_start("ob_gzhandler"); } echo "hi\n"; ?> diff --git a/ext/zlib/tests/readgzfile_basic.phpt b/ext/zlib/tests/readgzfile_basic.phpt index 09bcc4c534..ca3908c16e 100644 --- a/ext/zlib/tests/readgzfile_basic.phpt +++ b/ext/zlib/tests/readgzfile_basic.phpt @@ -25,10 +25,8 @@ var_dump(readgzfile( $filename ) ); unlink($filename); rmdir($dirname); ?> -===DONE=== --EXPECT-- hello world is a very common test for all languages int(52) -===DONE=== diff --git a/ext/zlib/tests/readgzfile_basic2.phpt b/ext/zlib/tests/readgzfile_basic2.phpt index a835883aaa..fe9192e221 100644 --- a/ext/zlib/tests/readgzfile_basic2.phpt +++ b/ext/zlib/tests/readgzfile_basic2.phpt @@ -25,10 +25,8 @@ var_dump(readgzfile( $filename ) ); unlink($filename); rmdir($dirname); ?> -===DONE=== --EXPECT-- hello world is a very common test for all languages int(52) -===DONE=== diff --git a/ext/zlib/tests/readgzfile_variation10.phpt b/ext/zlib/tests/readgzfile_variation10.phpt deleted file mode 100644 index 731445dbf0..0000000000 --- a/ext/zlib/tests/readgzfile_variation10.phpt +++ /dev/null @@ -1,67 +0,0 @@ ---TEST-- -Test function readgzfile() by substituting argument 2 with emptyUnsetUndefNull values. ---SKIPIF-- -<?php -if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build'); -?> ---FILE-- -<?php - - -$filename = __DIR__."/004.txt.gz"; - - -$unset_var = 10; -unset($unset_var); - -$variation = array( - 'unset var' => @$unset_var, - 'undefined var' => @$undefined_var, - 'empty string DQ' => "", - 'empty string SQ' => '', - 'uppercase NULL' => NULL, - 'lowercase null' => null, - ); - - -foreach ( $variation as $var ) { - var_dump(readgzfile( $filename, $var ) ); -} -?> -===DONE=== ---EXPECTF-- -When you're taught through feelings -Destiny flying high above -all I know is that you can realize it -Destiny who cares -as it turns around -and I know that it descends down on me -int(176) -When you're taught through feelings -Destiny flying high above -all I know is that you can realize it -Destiny who cares -as it turns around -and I know that it descends down on me -int(176) - -Warning: readgzfile() expects parameter 2 to be int, string given in %s on line %d -NULL - -Warning: readgzfile() expects parameter 2 to be int, string given in %s on line %d -NULL -When you're taught through feelings -Destiny flying high above -all I know is that you can realize it -Destiny who cares -as it turns around -and I know that it descends down on me -int(176) -When you're taught through feelings -Destiny flying high above -all I know is that you can realize it -Destiny who cares -as it turns around -and I know that it descends down on me -int(176) -===DONE=== diff --git a/ext/zlib/tests/readgzfile_variation11.phpt b/ext/zlib/tests/readgzfile_variation11.phpt index 87eb8ac7c8..15807926a9 100644 --- a/ext/zlib/tests/readgzfile_variation11.phpt +++ b/ext/zlib/tests/readgzfile_variation11.phpt @@ -25,7 +25,6 @@ foreach ( $variation as $var ) { var_dump(readgzfile( $filename, $var ) ); } ?> -===DONE=== --EXPECT-- When you're taught through feelings Destiny flying high above @@ -62,4 +61,3 @@ Destiny who cares as it turns around and I know that it descends down on me int(176) -===DONE=== diff --git a/ext/zlib/tests/readgzfile_variation12.phpt b/ext/zlib/tests/readgzfile_variation12.phpt index af22ce6f6c..0f72050939 100644 --- a/ext/zlib/tests/readgzfile_variation12.phpt +++ b/ext/zlib/tests/readgzfile_variation12.phpt @@ -23,7 +23,6 @@ foreach ( $variation as $var ) { var_dump(readgzfile( $filename, $var ) ); } ?> -===DONE=== --EXPECT-- When you're taught through feelings Destiny flying high above @@ -53,4 +52,3 @@ Destiny who cares as it turns around and I know that it descends down on me int(176) -===DONE=== diff --git a/ext/zlib/tests/readgzfile_variation15.phpt b/ext/zlib/tests/readgzfile_variation15.phpt index 70f566446e..749087f6ce 100644 --- a/ext/zlib/tests/readgzfile_variation15.phpt +++ b/ext/zlib/tests/readgzfile_variation15.phpt @@ -3,7 +3,7 @@ Test readgzfile() function : variation: use include path (relative directories i --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -83,11 +83,9 @@ function test_readgzfile() { } ?> -===DONE=== --EXPECT-- file content:This is a file in dir2 file content:This is a file in dir1 file content:This is a file in dir1 file content:This is a file in working dir file content:This is a file in script dir -===DONE=== diff --git a/ext/zlib/tests/readgzfile_variation3.phpt b/ext/zlib/tests/readgzfile_variation3.phpt index 9b8c142781..4a7fcecf08 100644 --- a/ext/zlib/tests/readgzfile_variation3.phpt +++ b/ext/zlib/tests/readgzfile_variation3.phpt @@ -25,26 +25,17 @@ $variation = array( foreach ( $variation as $var ) { - var_dump(readgzfile( $var , $use_include_path ) ); + try { + var_dump(readgzfile( $var , $use_include_path ) ); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } } ?> -===DONE=== ---EXPECTF-- -Warning: readgzfile(): Filename cannot be empty in %s on line %d -bool(false) - -Warning: readgzfile(): Filename cannot be empty in %s on line %d -bool(false) - -Warning: readgzfile(): Filename cannot be empty in %s on line %d -bool(false) - -Warning: readgzfile(): Filename cannot be empty in %s on line %d -bool(false) - -Warning: readgzfile(): Filename cannot be empty in %s on line %d -bool(false) - -Warning: readgzfile(): Filename cannot be empty in %s on line %d -bool(false) -===DONE=== +--EXPECT-- +Path cannot be empty +Path cannot be empty +Path cannot be empty +Path cannot be empty +Path cannot be empty +Path cannot be empty diff --git a/ext/zlib/tests/readgzfile_variation4.phpt b/ext/zlib/tests/readgzfile_variation4.phpt index 32f434cba2..8d86085010 100644 --- a/ext/zlib/tests/readgzfile_variation4.phpt +++ b/ext/zlib/tests/readgzfile_variation4.phpt @@ -24,20 +24,18 @@ foreach ( $variation as $var ) { var_dump(readgzfile( $var , $use_include_path ) ); } ?> -===DONE=== --EXPECTF-- -Warning: readgzfile(10.5): failed to open stream: No such file or directory in %s on line %d +Warning: readgzfile(10.5): Failed to open stream: No such file or directory in %s on line %d bool(false) -Warning: readgzfile(-10.5): failed to open stream: No such file or directory in %s on line %d +Warning: readgzfile(-10.5): Failed to open stream: No such file or directory in %s on line %d bool(false) -Warning: readgzfile(123456789000): failed to open stream: No such file or directory in %s on line %d +Warning: readgzfile(123456789000): Failed to open stream: No such file or directory in %s on line %d bool(false) -Warning: readgzfile(-123456789000): failed to open stream: No such file or directory in %s on line %d +Warning: readgzfile(-123456789000): Failed to open stream: No such file or directory in %s on line %d bool(false) -Warning: readgzfile(0.5): failed to open stream: No such file or directory in %s on line %d +Warning: readgzfile(0.5): Failed to open stream: No such file or directory in %s on line %d bool(false) -===DONE=== diff --git a/ext/zlib/tests/readgzfile_variation5.phpt b/ext/zlib/tests/readgzfile_variation5.phpt index 2aa83fde3b..fe95bb4dbc 100644 --- a/ext/zlib/tests/readgzfile_variation5.phpt +++ b/ext/zlib/tests/readgzfile_variation5.phpt @@ -23,17 +23,15 @@ foreach ( $variation as $var ) { var_dump(readgzfile( $var , $use_include_path ) ); } ?> -===DONE=== --EXPECTF-- -Warning: readgzfile(0): failed to open stream: No such file or directory in %s on line %d +Warning: readgzfile(0): Failed to open stream: No such file or directory in %s on line %d bool(false) -Warning: readgzfile(1): failed to open stream: No such file or directory in %s on line %d +Warning: readgzfile(1): Failed to open stream: No such file or directory in %s on line %d bool(false) -Warning: readgzfile(12345): failed to open stream: No such file or directory in %s on line %d +Warning: readgzfile(12345): Failed to open stream: No such file or directory in %s on line %d bool(false) -Warning: readgzfile(-2345): failed to open stream: No such file or directory in %s on line %d +Warning: readgzfile(-2345): Failed to open stream: No such file or directory in %s on line %d bool(false) -===DONE=== diff --git a/ext/zlib/tests/readgzfile_variation7.phpt b/ext/zlib/tests/readgzfile_variation7.phpt index f4abdac9b5..e60c01cb79 100644 --- a/ext/zlib/tests/readgzfile_variation7.phpt +++ b/ext/zlib/tests/readgzfile_variation7.phpt @@ -27,17 +27,15 @@ foreach ( $variation_array as $var ) { var_dump(readgzfile( $var , $use_include_path ) ); } ?> -===DONE=== --EXPECTF-- -Warning: readgzfile(string): failed to open stream: No such file or directory in %s on line %d +Warning: readgzfile(string): Failed to open stream: No such file or directory in %s on line %d bool(false) -Warning: readgzfile(string): failed to open stream: No such file or directory in %s on line %d +Warning: readgzfile(string): Failed to open stream: No such file or directory in %s on line %d bool(false) -Warning: readgzfile(sTrInG): failed to open stream: No such file or directory in %s on line %d +Warning: readgzfile(sTrInG): Failed to open stream: No such file or directory in %s on line %d bool(false) -Warning: readgzfile(hello world): failed to open stream: No such file or directory in %s on line %d +Warning: readgzfile(hello world): Failed to open stream: No such file or directory in %s on line %d bool(false) -===DONE=== diff --git a/ext/zlib/tests/readgzfile_variation9.phpt b/ext/zlib/tests/readgzfile_variation9.phpt index 4f7b7d30c0..6a91b292da 100644 --- a/ext/zlib/tests/readgzfile_variation9.phpt +++ b/ext/zlib/tests/readgzfile_variation9.phpt @@ -22,7 +22,6 @@ foreach ( $variation as $var ) { var_dump(readgzfile( $filename, $var ) ); } ?> -===DONE=== --EXPECT-- When you're taught through feelings Destiny flying high above @@ -52,4 +51,3 @@ Destiny who cares as it turns around and I know that it descends down on me int(176) -===DONE=== diff --git a/ext/zlib/tests/zlib_filter_inflate2.phpt b/ext/zlib/tests/zlib_filter_inflate2.phpt index 7dd2ebb594..0f7718dbdf 100644 --- a/ext/zlib/tests/zlib_filter_inflate2.phpt +++ b/ext/zlib/tests/zlib_filter_inflate2.phpt @@ -33,7 +33,8 @@ fclose($fp); <?php @unlink(__DIR__ . '/test.txt.gz'); ?> ---EXPECT-- +--EXPECTF-- +Notice: fread(): zlib: data error in %s on line %d 1 2 This is quite the thing ain't it diff --git a/ext/zlib/tests/zlib_scheme_copy_basic.phpt b/ext/zlib/tests/zlib_scheme_copy_basic.phpt index a295c84bc5..9c6becb4c7 100644 --- a/ext/zlib/tests/zlib_scheme_copy_basic.phpt +++ b/ext/zlib/tests/zlib_scheme_copy_basic.phpt @@ -3,7 +3,7 @@ Test compress.zlib:// scheme with the copy function: compressed to compressed --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -31,7 +31,5 @@ else { } unlink($outputFileName); ?> -===DONE=== --EXPECT-- OK: Copy identical -===DONE=== diff --git a/ext/zlib/tests/zlib_scheme_copy_variation1.phpt b/ext/zlib/tests/zlib_scheme_copy_variation1.phpt index 4130aa4508..c96e2bee29 100644 --- a/ext/zlib/tests/zlib_scheme_copy_variation1.phpt +++ b/ext/zlib/tests/zlib_scheme_copy_variation1.phpt @@ -3,7 +3,7 @@ Test compress.zlib:// scheme with the copy function: compressed to uncompressed --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -32,7 +32,5 @@ else { } unlink($outputFileName); ?> -===DONE=== --EXPECT-- OK: Copy identical -===DONE=== diff --git a/ext/zlib/tests/zlib_scheme_copy_variation2.phpt b/ext/zlib/tests/zlib_scheme_copy_variation2.phpt index 02fae273bc..829351846b 100644 --- a/ext/zlib/tests/zlib_scheme_copy_variation2.phpt +++ b/ext/zlib/tests/zlib_scheme_copy_variation2.phpt @@ -3,7 +3,7 @@ Test compress.zlib:// scheme with the copy function: uncompressed to compressed --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -47,7 +47,5 @@ else { unlink($inputFileName); unlink($outputFileName); ?> -===DONE=== --EXPECT-- OK: Copy identical -===DONE=== diff --git a/ext/zlib/tests/zlib_scheme_dir_basic.phpt b/ext/zlib/tests/zlib_scheme_dir_basic.phpt index 768cdb23a1..014243d574 100644 --- a/ext/zlib/tests/zlib_scheme_dir_basic.phpt +++ b/ext/zlib/tests/zlib_scheme_dir_basic.phpt @@ -3,7 +3,7 @@ Test compress.zlib:// scheme with the directory functions --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -15,12 +15,10 @@ var_dump(is_dir($srcFile)); var_dump(opendir($srcFile)); var_dump(rmdir($srcFile)); ?> -===DONE=== --EXPECTF-- bool(false) bool(false) -Warning: opendir(compress.zlib://%s/dir.gz): failed to open dir: not implemented in %s on line %d +Warning: opendir(compress.zlib://%s/dir.gz): Failed to open directory: not implemented in %s on line %d bool(false) bool(false) -===DONE=== diff --git a/ext/zlib/tests/zlib_scheme_file_basic.phpt b/ext/zlib/tests/zlib_scheme_file_basic.phpt index b978e35915..cb697f44f0 100644 --- a/ext/zlib/tests/zlib_scheme_file_basic.phpt +++ b/ext/zlib/tests/zlib_scheme_file_basic.phpt @@ -3,7 +3,7 @@ Test compress.zlib:// scheme with the file --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -13,7 +13,6 @@ $srcFile = "compress.zlib://$inputFileName"; $contents = file($srcFile); var_dump($contents); ?> -===DONE=== --EXPECT-- array(6) { [0]=> @@ -35,4 +34,3 @@ array(6) { string(39) "and I know that it descends down on me " } -===DONE=== diff --git a/ext/zlib/tests/zlib_scheme_file_get_contents_basic.phpt b/ext/zlib/tests/zlib_scheme_file_get_contents_basic.phpt index e98e4e8ca6..615d3c5d25 100644 --- a/ext/zlib/tests/zlib_scheme_file_get_contents_basic.phpt +++ b/ext/zlib/tests/zlib_scheme_file_get_contents_basic.phpt @@ -3,7 +3,7 @@ Test compress.zlib:// scheme with the file_get_contents --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -13,7 +13,6 @@ $srcFile = "compress.zlib://$inputFileName"; $contents = file_get_contents($srcFile); echo $contents; ?> -===DONE=== --EXPECT-- When you're taught through feelings Destiny flying high above @@ -21,4 +20,3 @@ all I know is that you can realize it Destiny who cares as it turns around and I know that it descends down on me -===DONE=== diff --git a/ext/zlib/tests/zlib_scheme_file_put_contents_basic.phpt b/ext/zlib/tests/zlib_scheme_file_put_contents_basic.phpt index cadaeae532..7ed77b36b3 100644 --- a/ext/zlib/tests/zlib_scheme_file_put_contents_basic.phpt +++ b/ext/zlib/tests/zlib_scheme_file_put_contents_basic.phpt @@ -3,7 +3,7 @@ Test compress.zlib:// scheme with the file_get_contents --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -23,9 +23,7 @@ gzclose($h); echo "\n"; unlink($outputFileName); ?> -===DONE=== --EXPECT-- Here is some plain text to be read and displayed. -===DONE=== diff --git a/ext/zlib/tests/zlib_scheme_file_read_file_basic.phpt b/ext/zlib/tests/zlib_scheme_file_read_file_basic.phpt index c0862d31a9..7304731021 100644 --- a/ext/zlib/tests/zlib_scheme_file_read_file_basic.phpt +++ b/ext/zlib/tests/zlib_scheme_file_read_file_basic.phpt @@ -3,7 +3,7 @@ Test compress.zlib:// scheme with the file_get_contents --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -12,7 +12,6 @@ $inputFileName = __DIR__."/004.txt.gz"; $srcFile = "compress.zlib://$inputFileName"; readfile($srcFile); ?> -===DONE=== --EXPECT-- When you're taught through feelings Destiny flying high above @@ -20,4 +19,3 @@ all I know is that you can realize it Destiny who cares as it turns around and I know that it descends down on me -===DONE=== diff --git a/ext/zlib/tests/zlib_scheme_fopen_basic.phpt b/ext/zlib/tests/zlib_scheme_fopen_basic.phpt index d06276a5f4..e8c6492024 100644 --- a/ext/zlib/tests/zlib_scheme_fopen_basic.phpt +++ b/ext/zlib/tests/zlib_scheme_fopen_basic.phpt @@ -3,7 +3,7 @@ Test compress.zlib:// scheme with the fopen --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -14,7 +14,6 @@ $h = fopen($srcFile, 'r'); fpassthru($h); fclose($h); ?> -===DONE=== --EXPECT-- When you're taught through feelings Destiny flying high above @@ -22,4 +21,3 @@ all I know is that you can realize it Destiny who cares as it turns around and I know that it descends down on me -===DONE=== diff --git a/ext/zlib/tests/zlib_scheme_fopen_variation1.phpt b/ext/zlib/tests/zlib_scheme_fopen_variation1.phpt index a57d52f567..093b137c6e 100644 --- a/ext/zlib/tests/zlib_scheme_fopen_variation1.phpt +++ b/ext/zlib/tests/zlib_scheme_fopen_variation1.phpt @@ -3,7 +3,7 @@ Test compress.zlib:// scheme with the fopen on a file scheme --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -17,7 +17,6 @@ $h = fopen($compressedFile, 'r'); fpassthru($h); fclose($h); ?> -===DONE=== --EXPECTF-- file=compress.zlib://file://%s/004.txt.gz @@ -27,4 +26,3 @@ all I know is that you can realize it Destiny who cares as it turns around and I know that it descends down on me -===DONE=== diff --git a/ext/zlib/tests/zlib_scheme_rename_basic.phpt b/ext/zlib/tests/zlib_scheme_rename_basic.phpt index e7225b6d81..e67970d332 100644 --- a/ext/zlib/tests/zlib_scheme_rename_basic.phpt +++ b/ext/zlib/tests/zlib_scheme_rename_basic.phpt @@ -3,7 +3,7 @@ Test compress.zlib:// scheme with the unlink function --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -13,8 +13,6 @@ $srcFile = "compress.zlib://$inputFileName"; rename($srcFile, 'something.tmp'); var_dump(file_exists($inputFileName)); ?> -===DONE=== --EXPECTF-- Warning: rename(): ZLIB wrapper does not support renaming in %s on line %d bool(true) -===DONE=== diff --git a/ext/zlib/tests/zlib_scheme_stat_basic.phpt b/ext/zlib/tests/zlib_scheme_stat_basic.phpt index d7997e2ebd..fa48454db5 100644 --- a/ext/zlib/tests/zlib_scheme_stat_basic.phpt +++ b/ext/zlib/tests/zlib_scheme_stat_basic.phpt @@ -3,7 +3,7 @@ Test compress.zlib:// scheme with the unlink function --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -13,9 +13,7 @@ $srcFile = "compress.zlib://$inputFileName"; stat($srcFile); lstat($srcFile); ?> -===DONE=== --EXPECTF-- Warning: stat(): stat failed for compress.zlib://%s/004.txt.gz in %s on line %d Warning: lstat(): Lstat failed for compress.zlib://%s/004.txt.gz in %s on line %d -===DONE=== diff --git a/ext/zlib/tests/zlib_scheme_stat_basic2.phpt b/ext/zlib/tests/zlib_scheme_stat_basic2.phpt index e74504939e..c2cfca723a 100644 --- a/ext/zlib/tests/zlib_scheme_stat_basic2.phpt +++ b/ext/zlib/tests/zlib_scheme_stat_basic2.phpt @@ -3,7 +3,7 @@ Test compress.zlib:// scheme with the unlink function --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -27,7 +27,6 @@ echo "fileatime="; var_dump(fileatime($srcFile)); ?> -===DONE=== --EXPECTF-- file_exists=bool(false) is_file=bool(false) @@ -43,4 +42,3 @@ bool(false) fileatime= Warning: fileatime(): stat failed for compress.zlib://%s004.txt.gz in %s on line %d bool(false) -===DONE=== diff --git a/ext/zlib/tests/zlib_scheme_unlink_basic.phpt b/ext/zlib/tests/zlib_scheme_unlink_basic.phpt index cb2734d905..c5c4eabb46 100644 --- a/ext/zlib/tests/zlib_scheme_unlink_basic.phpt +++ b/ext/zlib/tests/zlib_scheme_unlink_basic.phpt @@ -3,7 +3,7 @@ Test compress.zlib:// scheme with the unlink function --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -13,8 +13,6 @@ $srcFile = "compress.zlib://$inputFileName"; unlink($srcFile); var_dump(file_exists($inputFileName)); ?> -===DONE=== --EXPECTF-- Warning: unlink(): ZLIB does not allow unlinking in %s on line %d bool(true) -===DONE=== diff --git a/ext/zlib/tests/zlib_wrapper_fflush_basic.phpt b/ext/zlib/tests/zlib_wrapper_fflush_basic.phpt index d4e7214937..54d0e37860 100644 --- a/ext/zlib/tests/zlib_wrapper_fflush_basic.phpt +++ b/ext/zlib/tests/zlib_wrapper_fflush_basic.phpt @@ -3,7 +3,7 @@ Test function fflush() on a zlib stream wrapper --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -25,9 +25,7 @@ gzclose($h); echo "\n"; unlink($filename); ?> -===DONE=== --EXPECT-- bool(true) bool(true) Here is the string to be written.Here is the string to be written. -===DONE=== diff --git a/ext/zlib/tests/zlib_wrapper_flock_basic.phpt b/ext/zlib/tests/zlib_wrapper_flock_basic.phpt index e32f116420..6d3f9d6237 100644 --- a/ext/zlib/tests/zlib_wrapper_flock_basic.phpt +++ b/ext/zlib/tests/zlib_wrapper_flock_basic.phpt @@ -3,7 +3,7 @@ Test function stream_get_meta_data on a zlib stream --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -13,7 +13,5 @@ $h = gzopen($f,'r'); var_dump(flock($h, LOCK_SH)); gzclose($h); ?> -===DONE=== --EXPECT-- bool(false) -===DONE=== diff --git a/ext/zlib/tests/zlib_wrapper_fstat_basic.phpt b/ext/zlib/tests/zlib_wrapper_fstat_basic.phpt index cb7cf915ff..eaa9a124db 100644 --- a/ext/zlib/tests/zlib_wrapper_fstat_basic.phpt +++ b/ext/zlib/tests/zlib_wrapper_fstat_basic.phpt @@ -3,7 +3,7 @@ Test function fstat() on zlib wrapper --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -13,7 +13,5 @@ $h = gzopen($f, "r"); var_dump(fstat($h)); fclose($h); ?> -===DONE=== --EXPECT-- bool(false) -===DONE=== diff --git a/ext/zlib/tests/zlib_wrapper_ftruncate_basic.phpt b/ext/zlib/tests/zlib_wrapper_ftruncate_basic.phpt index 674243ab5c..07b3917213 100644 --- a/ext/zlib/tests/zlib_wrapper_ftruncate_basic.phpt +++ b/ext/zlib/tests/zlib_wrapper_ftruncate_basic.phpt @@ -3,7 +3,7 @@ Test function ftruncate() on zlib wrapper by calling it with its expected argume --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -23,9 +23,7 @@ fclose($h); unlink($f2); ?> -===DONE=== --EXPECTF-- Warning: ftruncate(): Can't truncate this stream! in %s on line %d Warning: ftruncate(): Can't truncate this stream! in %s on line %d -===DONE=== diff --git a/ext/zlib/tests/zlib_wrapper_level.phpt b/ext/zlib/tests/zlib_wrapper_level.phpt index 135ef9c72a..5cfd9cf6a8 100644 --- a/ext/zlib/tests/zlib_wrapper_level.phpt +++ b/ext/zlib/tests/zlib_wrapper_level.phpt @@ -29,6 +29,7 @@ var_dump(10 * strlen($thisfile)); var_dump($size1); var_dump($size9); var_dump($size9 < $size1); +?> --EXPECTF-- int(%d) int(%d) diff --git a/ext/zlib/tests/zlib_wrapper_meta_data_basic.phpt b/ext/zlib/tests/zlib_wrapper_meta_data_basic.phpt index 591b93d075..815854b21e 100644 --- a/ext/zlib/tests/zlib_wrapper_meta_data_basic.phpt +++ b/ext/zlib/tests/zlib_wrapper_meta_data_basic.phpt @@ -3,7 +3,7 @@ Test function stream_get_meta_data on a zlib stream --SKIPIF-- <?php if (!extension_loaded("zlib")) { - print "skip - ZLIB extension not loaded"; + print "skip - ZLIB extension not loaded"; } ?> --FILE-- @@ -21,7 +21,6 @@ gzclose($h); ?> -===DONE=== --EXPECTF-- no wrapper array(7) { @@ -62,4 +61,3 @@ array(9) { ["uri"]=> string(%d) "compress.zlib://%s/004.txt.gz" } -===DONE=== diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 9060dcb2e2..eab3b02ca5 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -1,7 +1,5 @@ /* +----------------------------------------------------------------------+ - | PHP Version 7 | - +----------------------------------------------------------------------+ | Copyright (c) The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | @@ -28,15 +26,16 @@ #include "SAPI.h" #include "php_ini.h" #include "ext/standard/info.h" -#include "ext/standard/file.h" #include "ext/standard/php_string.h" #include "php_zlib.h" +#include "zlib_arginfo.h" +#include "Zend/zend_interfaces.h" /* * zlib include files can define the following preprocessor defines which rename * the corresponding PHP functions to gzopen64, gzseek64 and gztell64 and thereby * breaking some software, most notably PEAR's Archive_Tar, which halts execution - * without error message on gzip compressed archivesa. + * without error message on gzip compressed archives. * * This only seems to happen on 32bit systems with large file support. */ @@ -44,43 +43,94 @@ #undef gzseek #undef gztell -int le_deflate; -int le_inflate; +ZEND_DECLARE_MODULE_GLOBALS(zlib) -ZEND_DECLARE_MODULE_GLOBALS(zlib); +/* InflateContext class */ -/* {{{ Memory management wrappers */ +zend_class_entry *inflate_context_ce; +static zend_object_handlers inflate_context_object_handlers; -static voidpf php_zlib_alloc(voidpf opaque, uInt items, uInt size) -{ - return (voidpf)safe_emalloc(items, size, 0); +static inline php_zlib_context *inflate_context_from_obj(zend_object *obj) { + return (php_zlib_context *)((char *)(obj) - XtOffsetOf(php_zlib_context, std)); } -static void php_zlib_free(voidpf opaque, voidpf address) +#define Z_INFLATE_CONTEXT_P(zv) inflate_context_from_obj(Z_OBJ_P(zv)) + +static zend_object *inflate_context_create_object(zend_class_entry *class_type) { + php_zlib_context *intern = zend_object_alloc(sizeof(php_zlib_context), class_type); + + zend_object_std_init(&intern->std, class_type); + object_properties_init(&intern->std, class_type); + intern->std.handlers = &inflate_context_object_handlers; + + return &intern->std; +} + +static zend_function *inflate_context_get_constructor(zend_object *object) { + zend_throw_error(NULL, "Cannot directly construct InflateContext, use inflate_init() instead"); + return NULL; +} + +static void inflate_context_free_obj(zend_object *object) { - efree((void*)address); + php_zlib_context *intern = inflate_context_from_obj(object); + + if (intern->inflateDict) { + efree(intern->inflateDict); + } + inflateEnd(&intern->Z); + + zend_object_std_dtor(&intern->std); } /* }}} */ -/* {{{ Incremental deflate/inflate resource destructors */ +/* DeflateContext class */ + +zend_class_entry *deflate_context_ce; +static zend_object_handlers deflate_context_object_handlers; + +static inline php_zlib_context *deflate_context_from_obj(zend_object *obj) { + return (php_zlib_context *)((char *)(obj) - XtOffsetOf(php_zlib_context, std)); +} + +#define Z_DEFLATE_CONTEXT_P(zv) deflate_context_from_obj(Z_OBJ_P(zv)) + +static zend_object *deflate_context_create_object(zend_class_entry *class_type) { + php_zlib_context *intern = zend_object_alloc(sizeof(php_zlib_context), class_type); + + zend_object_std_init(&intern->std, class_type); + object_properties_init(&intern->std, class_type); + intern->std.handlers = &deflate_context_object_handlers; + + return &intern->std; +} + +static zend_function *deflate_context_get_constructor(zend_object *object) { + zend_throw_error(NULL, "Cannot directly construct DeflateContext, use deflate_init() instead"); + return NULL; +} -void deflate_rsrc_dtor(zend_resource *res) +static void deflate_context_free_obj(zend_object *object) { - z_stream *ctx = zend_fetch_resource(res, NULL, le_deflate); - deflateEnd(ctx); - efree(ctx); + php_zlib_context *intern = deflate_context_from_obj(object); + + deflateEnd(&intern->Z); + + zend_object_std_dtor(&intern->std); } +/* }}} */ -void inflate_rsrc_dtor(zend_resource *res) +/* {{{ Memory management wrappers */ + +static voidpf php_zlib_alloc(voidpf opaque, uInt items, uInt size) { - z_stream *ctx = zend_fetch_resource(res, NULL, le_inflate); - if (((php_zlib_context *) ctx)->inflateDict) { - efree(((php_zlib_context *) ctx)->inflateDict); - } - inflateEnd(ctx); - efree(ctx); + return (voidpf)safe_emalloc(items, size, 0); } +static void php_zlib_free(voidpf opaque, voidpf address) +{ + efree((void*)address); +} /* }}} */ /* {{{ php_zlib_output_conflict_check() */ @@ -471,9 +521,8 @@ static void php_zlib_cleanup_ob_gzhandler_mess(void) } /* }}} */ -/* {{{ proto string ob_gzhandler(string data, int flags) - Legacy hack */ -static PHP_FUNCTION(ob_gzhandler) +/* {{{ Legacy hack */ +PHP_FUNCTION(ob_gzhandler) { char *in_str; size_t in_len; @@ -490,7 +539,7 @@ static PHP_FUNCTION(ob_gzhandler) * - we have to mess around with php_output_context */ if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "sl", &in_str, &in_len, &flags)) { - RETURN_FALSE; + RETURN_THROWS(); } if (!(encoding = php_zlib_output_encoding())) { @@ -538,12 +587,11 @@ static PHP_FUNCTION(ob_gzhandler) } /* }}} */ -/* {{{ proto string zlib_get_coding_type(void) - Returns the coding type used for output compression */ -static PHP_FUNCTION(zlib_get_coding_type) +/* {{{ Returns the coding type used for output compression */ +PHP_FUNCTION(zlib_get_coding_type) { if (zend_parse_parameters_none() == FAILURE) { - return; + RETURN_THROWS(); } switch (ZLIBG(compression_coding)) { case PHP_ZLIB_ENCODING_GZIP: @@ -556,9 +604,8 @@ static PHP_FUNCTION(zlib_get_coding_type) } /* }}} */ -/* {{{ proto array gzfile(string filename [, int use_include_path]) - Read and uncompress entire .gz-file into an array */ -static PHP_FUNCTION(gzfile) +/* {{{ Read and uncompress entire .gz-file into an array */ +PHP_FUNCTION(gzfile) { char *filename; size_t filename_len; @@ -569,7 +616,7 @@ static PHP_FUNCTION(gzfile) php_stream *stream; if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "p|l", &filename, &filename_len, &use_include_path)) { - return; + RETURN_THROWS(); } if (use_include_path) { @@ -597,9 +644,8 @@ static PHP_FUNCTION(gzfile) } /* }}} */ -/* {{{ proto resource gzopen(string filename, string mode [, int use_include_path]) - Open a .gz-file and return a .gz-file pointer */ -static PHP_FUNCTION(gzopen) +/* {{{ Open a .gz-file and return a .gz-file pointer */ +PHP_FUNCTION(gzopen) { char *filename; char *mode; @@ -609,7 +655,7 @@ static PHP_FUNCTION(gzopen) zend_long use_include_path = 0; if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps|l", &filename, &filename_len, &mode, &mode_len, &use_include_path) == FAILURE) { - return; + RETURN_THROWS(); } if (use_include_path) { @@ -625,9 +671,8 @@ static PHP_FUNCTION(gzopen) } /* }}} */ -/* {{{ proto int readgzfile(string filename [, int use_include_path]) - Output a .gz-file */ -static PHP_FUNCTION(readgzfile) +/* {{{ Output a .gz-file */ +PHP_FUNCTION(readgzfile) { char *filename; size_t filename_len; @@ -637,7 +682,7 @@ static PHP_FUNCTION(readgzfile) zend_long use_include_path = 0; if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|l", &filename, &filename_len, &use_include_path) == FAILURE) { - return; + RETURN_THROWS(); } if (use_include_path) { @@ -656,23 +701,23 @@ static PHP_FUNCTION(readgzfile) /* }}} */ #define PHP_ZLIB_ENCODE_FUNC(name, default_encoding) \ -static PHP_FUNCTION(name) \ +PHP_FUNCTION(name) \ { \ zend_string *in, *out; \ zend_long level = -1; \ zend_long encoding = default_encoding; \ if (default_encoding) { \ if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "S|ll", &in, &level, &encoding)) { \ - return; \ + RETURN_THROWS(); \ } \ } else { \ if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "Sl|l", &in, &encoding, &level)) { \ - return; \ + RETURN_THROWS(); \ } \ } \ if (level < -1 || level > 9) { \ - php_error_docref(NULL, E_WARNING, "compression level (" ZEND_LONG_FMT ") must be within -1..9", level); \ - RETURN_FALSE; \ + zend_argument_value_error(default_encoding ? 2 : 3, "must be between -1 and 9"); \ + RETURN_THROWS(); \ } \ switch (encoding) { \ case PHP_ZLIB_ENCODING_RAW: \ @@ -680,8 +725,8 @@ static PHP_FUNCTION(name) \ case PHP_ZLIB_ENCODING_DEFLATE: \ break; \ default: \ - php_error_docref(NULL, E_WARNING, "encoding mode must be either ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE"); \ - RETURN_FALSE; \ + zend_argument_value_error(default_encoding ? 3 : 2, "must be one of ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP, or ZLIB_ENCODING_DEFLATE"); \ + RETURN_THROWS(); \ } \ if ((out = php_zlib_encode(ZSTR_VAL(in), ZSTR_LEN(in), encoding, level)) == NULL) { \ RETURN_FALSE; \ @@ -690,18 +735,18 @@ static PHP_FUNCTION(name) \ } #define PHP_ZLIB_DECODE_FUNC(name, encoding) \ -static PHP_FUNCTION(name) \ +PHP_FUNCTION(name) \ { \ char *in_buf, *out_buf; \ size_t in_len; \ size_t out_len; \ zend_long max_len = 0; \ if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &in_buf, &in_len, &max_len)) { \ - return; \ + RETURN_THROWS(); \ } \ if (max_len < 0) { \ - php_error_docref(NULL, E_WARNING, "length (" ZEND_LONG_FMT ") must be greater or equal zero", max_len); \ - RETURN_FALSE; \ + zend_argument_value_error(2, "must be greater than or equal to 0"); \ + RETURN_THROWS(); \ } \ if (SUCCESS != php_zlib_decode(in_buf, in_len, &out_buf, &out_len, encoding, max_len)) { \ RETURN_FALSE; \ @@ -710,44 +755,36 @@ static PHP_FUNCTION(name) \ efree(out_buf); \ } -/* {{{ proto binary zlib_encode(binary data, int encoding[, int level = -1]) - Compress data with the specified encoding */ +/* {{{ Compress data with the specified encoding */ PHP_ZLIB_ENCODE_FUNC(zlib_encode, 0); /* }}} */ -/* {{{ proto binary zlib_decode(binary data[, int max_decoded_len]) - Uncompress any raw/gzip/zlib encoded data */ +/* {{{ Uncompress any raw/gzip/zlib encoded data */ PHP_ZLIB_DECODE_FUNC(zlib_decode, PHP_ZLIB_ENCODING_ANY); /* }}} */ /* NOTE: The naming of these userland functions was quite unlucky */ -/* {{{ proto binary gzdeflate(binary data[, int level = -1[, int encoding = ZLIB_ENCODING_RAW]) - Encode data with the raw deflate encoding */ +/* {{{ Encode data with the raw deflate encoding */ PHP_ZLIB_ENCODE_FUNC(gzdeflate, PHP_ZLIB_ENCODING_RAW); /* }}} */ -/* {{{ proto binary gzencode(binary data[, int level = -1[, int encoding = ZLIB_ENCODING_GZIP]) - Encode data with the gzip encoding */ +/* {{{ Encode data with the gzip encoding */ PHP_ZLIB_ENCODE_FUNC(gzencode, PHP_ZLIB_ENCODING_GZIP); /* }}} */ -/* {{{ proto binary gzcompress(binary data[, int level = -1[, int encoding = ZLIB_ENCODING_DEFLATE]) - Encode data with the zlib encoding */ +/* {{{ Encode data with the zlib encoding */ PHP_ZLIB_ENCODE_FUNC(gzcompress, PHP_ZLIB_ENCODING_DEFLATE); /* }}} */ -/* {{{ proto binary gzinflate(binary data[, int max_decoded_len]) - Decode raw deflate encoded data */ +/* {{{ Decode raw deflate encoded data */ PHP_ZLIB_DECODE_FUNC(gzinflate, PHP_ZLIB_ENCODING_RAW); /* }}} */ -/* {{{ proto binary gzdecode(binary data[, int max_decoded_len]) - Decode gzip encoded data */ +/* {{{ Decode gzip encoded data */ PHP_ZLIB_DECODE_FUNC(gzdecode, PHP_ZLIB_ENCODING_GZIP); /* }}} */ -/* {{{ proto binary gzuncompress(binary data[, int max_decoded_len]) - Decode zlib encoded data */ +/* {{{ Decode zlib encoded data */ PHP_ZLIB_DECODE_FUNC(gzuncompress, PHP_ZLIB_ENCODING_DEFLATE); /* }}} */ @@ -786,7 +823,7 @@ static zend_bool zlib_create_dictionary_string(HashTable *options, char **dict, } efree(strings); if (!EG(exception)) { - php_error_docref(NULL, E_WARNING, "dictionary entries must be non-empty strings"); + zend_argument_value_error(2, "must not contain empty strings"); } return 0; } @@ -796,7 +833,7 @@ static zend_bool zlib_create_dictionary_string(HashTable *options, char **dict, efree(ptr); } while (--ptr >= strings); efree(strings); - php_error_docref(NULL, E_WARNING, "dictionary entries must not contain a NULL-byte"); + zend_argument_value_error(2, "must not contain strings with null bytes"); return 0; } } @@ -818,7 +855,7 @@ static zend_bool zlib_create_dictionary_string(HashTable *options, char **dict, } break; default: - php_error_docref(NULL, E_WARNING, "dictionary must be of type zero-terminated string or array, got %s", zend_get_type_by_const(Z_TYPE_P(option_buffer))); + zend_argument_type_error(2, "must be of type zero-terminated string or array, %s given", zend_zval_type_name(option_buffer)); return 0; } } @@ -826,11 +863,10 @@ static zend_bool zlib_create_dictionary_string(HashTable *options, char **dict, return 1; } -/* {{{ proto resource inflate_init(int encoding) - Initialize an incremental inflate context with the specified encoding */ +/* {{{ Initialize an incremental inflate context with the specified encoding */ PHP_FUNCTION(inflate_init) { - z_stream *ctx; + php_zlib_context *ctx; zend_long encoding, window = 15; char *dict = NULL; size_t dictlen = 0; @@ -838,19 +874,19 @@ PHP_FUNCTION(inflate_init) zval *option_buffer; if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "l|H", &encoding, &options)) { - return; + RETURN_THROWS(); } if (options && (option_buffer = zend_hash_str_find(options, ZEND_STRL("window"))) != NULL) { window = zval_get_long(option_buffer); } if (window < 8 || window > 15) { - php_error_docref(NULL, E_WARNING, "zlib window size (lograithm) (" ZEND_LONG_FMT ") must be within 8..15", window); - RETURN_FALSE; + zend_value_error("zlib window size (logarithm) (" ZEND_LONG_FMT ") must be within 8..15", window); + RETURN_THROWS(); } if (!zlib_create_dictionary_string(options, &dict, &dictlen)) { - RETURN_FALSE; + RETURN_THROWS(); } switch (encoding) { @@ -859,16 +895,18 @@ PHP_FUNCTION(inflate_init) case PHP_ZLIB_ENCODING_DEFLATE: break; default: - php_error_docref(NULL, E_WARNING, "encoding mode must be ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE"); - RETURN_FALSE; + zend_value_error("Encoding mode must be ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE"); + RETURN_THROWS(); } - ctx = ecalloc(1, sizeof(php_zlib_context)); - ctx->zalloc = php_zlib_alloc; - ctx->zfree = php_zlib_free; - ((php_zlib_context *) ctx)->inflateDict = dict; - ((php_zlib_context *) ctx)->inflateDictlen = dictlen; - ((php_zlib_context *) ctx)->status = Z_OK; + object_init_ex(return_value, inflate_context_ce); + ctx = Z_INFLATE_CONTEXT_P(return_value); + + ctx->Z.zalloc = php_zlib_alloc; + ctx->Z.zfree = php_zlib_free; + ctx->inflateDict = dict; + ctx->inflateDictlen = dictlen; + ctx->status = Z_OK; if (encoding < 0) { encoding += 15 - window; @@ -876,51 +914,44 @@ PHP_FUNCTION(inflate_init) encoding -= 15 - window; } - if (Z_OK == inflateInit2(ctx, encoding)) { - if (encoding == PHP_ZLIB_ENCODING_RAW && dictlen > 0) { - php_zlib_context *php_ctx = (php_zlib_context *) ctx; - switch (inflateSetDictionary(ctx, (Bytef *) php_ctx->inflateDict, php_ctx->inflateDictlen)) { - case Z_OK: - efree(php_ctx->inflateDict); - php_ctx->inflateDict = NULL; - break; - case Z_DATA_ERROR: - php_error_docref(NULL, E_WARNING, "dictionary does not match expected dictionary (incorrect adler32 hash)"); - efree(php_ctx->inflateDict); - php_ctx->inflateDict = NULL; - RETURN_FALSE; - EMPTY_SWITCH_DEFAULT_CASE() - } - } - RETURN_RES(zend_register_resource(ctx, le_inflate)); - } else { - efree(ctx); - php_error_docref(NULL, E_WARNING, "failed allocating zlib.inflate context"); + if (inflateInit2(&ctx->Z, encoding) != Z_OK) { + zval_ptr_dtor(return_value); + php_error_docref(NULL, E_WARNING, "Failed allocating zlib.inflate context"); RETURN_FALSE; } + + if (encoding == PHP_ZLIB_ENCODING_RAW && dictlen > 0) { + switch (inflateSetDictionary(&ctx->Z, (Bytef *) ctx->inflateDict, ctx->inflateDictlen)) { + case Z_OK: + efree(ctx->inflateDict); + ctx->inflateDict = NULL; + break; + case Z_DATA_ERROR: + php_error_docref(NULL, E_WARNING, "Dictionary does not match expected dictionary (incorrect adler32 hash)"); + efree(ctx->inflateDict); + ctx->inflateDict = NULL; + EMPTY_SWITCH_DEFAULT_CASE() + } + } } /* }}} */ -/* {{{ proto string inflate_add(resource context, string encoded_data[, int flush_mode = ZLIB_SYNC_FLUSH]) - Incrementally inflate encoded data in the specified context */ +/* {{{ Incrementally inflate encoded data in the specified context */ PHP_FUNCTION(inflate_add) { zend_string *out; char *in_buf; size_t in_len, buffer_used = 0, CHUNK_SIZE = 8192; zval *res; - z_stream *ctx; + php_zlib_context *ctx; zend_long flush_type = Z_SYNC_FLUSH; int status; - if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "rs|l", &res, &in_buf, &in_len, &flush_type)) { - return; + if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "Os|l", &res, inflate_context_ce, &in_buf, &in_len, &flush_type)) { + RETURN_THROWS(); } - if (!(ctx = zend_fetch_resource_ex(res, NULL, le_inflate))) { - php_error_docref(NULL, E_WARNING, "Invalid zlib.inflate resource"); - RETURN_FALSE; - } + ctx = Z_INFLATE_CONTEXT_P(res); switch (flush_type) { case Z_NO_FLUSH: @@ -932,16 +963,15 @@ PHP_FUNCTION(inflate_add) break; default: - php_error_docref(NULL, E_WARNING, - "flush mode must be ZLIB_NO_FLUSH, ZLIB_PARTIAL_FLUSH, ZLIB_SYNC_FLUSH, ZLIB_FULL_FLUSH, ZLIB_BLOCK or ZLIB_FINISH"); - RETURN_FALSE; + zend_argument_value_error(3, "must be one of ZLIB_NO_FLUSH, ZLIB_PARTIAL_FLUSH, ZLIB_SYNC_FLUSH, ZLIB_FULL_FLUSH, ZLIB_BLOCK, or ZLIB_FINISH"); + RETURN_THROWS(); } /* Lazy-resetting the zlib stream so ctx->total_in remains available until the next inflate_add() call. */ - if (((php_zlib_context *) ctx)->status == Z_STREAM_END) + if (ctx->status == Z_STREAM_END) { - ((php_zlib_context *) ctx)->status = Z_OK; - inflateReset(ctx); + ctx->status = Z_OK; + inflateReset(&ctx->Z); } if (in_len <= 0 && flush_type != Z_FINISH) { @@ -949,24 +979,24 @@ PHP_FUNCTION(inflate_add) } out = zend_string_alloc((in_len > CHUNK_SIZE) ? in_len : CHUNK_SIZE, 0); - ctx->next_in = (Bytef *) in_buf; - ctx->next_out = (Bytef *) ZSTR_VAL(out); - ctx->avail_in = in_len; - ctx->avail_out = ZSTR_LEN(out); + ctx->Z.next_in = (Bytef *) in_buf; + ctx->Z.next_out = (Bytef *) ZSTR_VAL(out); + ctx->Z.avail_in = in_len; + ctx->Z.avail_out = ZSTR_LEN(out); do { - status = inflate(ctx, flush_type); - buffer_used = ZSTR_LEN(out) - ctx->avail_out; + status = inflate(&ctx->Z, flush_type); + buffer_used = ZSTR_LEN(out) - ctx->Z.avail_out; - ((php_zlib_context *) ctx)->status = status; /* Save status for exposing to userspace */ + ctx->status = status; /* Save status for exposing to userspace */ switch (status) { case Z_OK: - if (ctx->avail_out == 0) { + if (ctx->Z.avail_out == 0) { /* more output buffer space needed; realloc and try again */ out = zend_string_realloc(out, ZSTR_LEN(out) + CHUNK_SIZE, 0); - ctx->avail_out = CHUNK_SIZE; - ctx->next_out = (Bytef *) ZSTR_VAL(out) + buffer_used; + ctx->Z.avail_out = CHUNK_SIZE; + ctx->Z.next_out = (Bytef *) ZSTR_VAL(out) + buffer_used; break; } else { goto complete; @@ -974,35 +1004,34 @@ PHP_FUNCTION(inflate_add) case Z_STREAM_END: goto complete; case Z_BUF_ERROR: - if (flush_type == Z_FINISH && ctx->avail_out == 0) { + if (flush_type == Z_FINISH && ctx->Z.avail_out == 0) { /* more output buffer space needed; realloc and try again */ out = zend_string_realloc(out, ZSTR_LEN(out) + CHUNK_SIZE, 0); - ctx->avail_out = CHUNK_SIZE; - ctx->next_out = (Bytef *) ZSTR_VAL(out) + buffer_used; + ctx->Z.avail_out = CHUNK_SIZE; + ctx->Z.next_out = (Bytef *) ZSTR_VAL(out) + buffer_used; break; } else { /* No more input data; we're finished */ goto complete; } case Z_NEED_DICT: - if (((php_zlib_context *) ctx)->inflateDict) { - php_zlib_context *php_ctx = (php_zlib_context *) ctx; - switch (inflateSetDictionary(ctx, (Bytef *) php_ctx->inflateDict, php_ctx->inflateDictlen)) { + if (ctx->inflateDict) { + switch (inflateSetDictionary(&ctx->Z, (Bytef *) ctx->inflateDict, ctx->inflateDictlen)) { case Z_OK: - efree(php_ctx->inflateDict); - php_ctx->inflateDict = NULL; + efree(ctx->inflateDict); + ctx->inflateDict = NULL; break; case Z_DATA_ERROR: - php_error_docref(NULL, E_WARNING, "dictionary does not match expected dictionary (incorrect adler32 hash)"); - efree(php_ctx->inflateDict); + efree(ctx->inflateDict); + ctx->inflateDict = NULL; zend_string_release_ex(out, 0); - php_ctx->inflateDict = NULL; + php_error_docref(NULL, E_WARNING, "Dictionary does not match expected dictionary (incorrect adler32 hash)"); RETURN_FALSE; EMPTY_SWITCH_DEFAULT_CASE() } break; } else { - php_error_docref(NULL, E_WARNING, "inflating this data requires a preset dictionary, please specify it in the options array of inflate_init()"); + php_error_docref(NULL, E_WARNING, "Inflating this data requires a preset dictionary, please specify it in the options array of inflate_init()"); RETURN_FALSE; } default: @@ -1012,61 +1041,49 @@ PHP_FUNCTION(inflate_add) } } while (1); - complete: { - out = zend_string_realloc(out, buffer_used, 0); - ZSTR_VAL(out)[buffer_used] = 0; - RETURN_STR(out); - } +complete: + out = zend_string_realloc(out, buffer_used, 0); + ZSTR_VAL(out)[buffer_used] = 0; + RETURN_STR(out); } /* }}} */ -/* {{{ proto bool inflate_get_status(resource context) - Get decompression status, usually returns either ZLIB_OK or ZLIB_STREAM_END. */ +/* {{{ Get decompression status, usually returns either ZLIB_OK or ZLIB_STREAM_END. */ PHP_FUNCTION(inflate_get_status) { zval *res; - z_stream *ctx; + php_zlib_context *ctx; - if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "r", &res)) - { - RETURN_NULL(); + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &res, inflate_context_ce) != SUCCESS) { + RETURN_THROWS(); } - if (!(ctx = zend_fetch_resource_ex(res, NULL, le_inflate))) { - php_error_docref(NULL, E_WARNING, "Invalid zlib.inflate resource"); - RETURN_FALSE; - } + ctx = Z_INFLATE_CONTEXT_P(res); - RETURN_LONG(((php_zlib_context *) ctx)->status); + RETURN_LONG(ctx->status); } /* }}} */ -/* {{{ proto bool inflate_get_read_len(resource context) - Get number of bytes read so far. */ +/* {{{ Get number of bytes read so far. */ PHP_FUNCTION(inflate_get_read_len) { zval *res; - z_stream *ctx; + php_zlib_context *ctx; - if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "r", &res)) - { - RETURN_NULL(); + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &res, inflate_context_ce) != SUCCESS) { + RETURN_THROWS(); } - if (!(ctx = zend_fetch_resource_ex(res, NULL, le_inflate))) { - php_error_docref(NULL, E_WARNING, "Invalid zlib.inflate resource"); - RETURN_FALSE; - } + ctx = Z_INFLATE_CONTEXT_P(res); - RETURN_LONG(ctx->total_in); + RETURN_LONG(ctx->Z.total_in); } /* }}} */ -/* {{{ proto resource deflate_init(int encoding[, array options]) - Initialize an incremental deflate context using the specified encoding */ +/* {{{ Initialize an incremental deflate context using the specified encoding */ PHP_FUNCTION(deflate_init) { - z_stream *ctx; + php_zlib_context *ctx; zend_long encoding, level = -1, memory = 8, window = 15, strategy = Z_DEFAULT_STRATEGY; char *dict = NULL; size_t dictlen = 0; @@ -1074,31 +1091,31 @@ PHP_FUNCTION(deflate_init) zval *option_buffer; if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "l|H", &encoding, &options)) { - return; + RETURN_THROWS(); } if (options && (option_buffer = zend_hash_str_find(options, ZEND_STRL("level"))) != NULL) { level = zval_get_long(option_buffer); } if (level < -1 || level > 9) { - php_error_docref(NULL, E_WARNING, "compression level (" ZEND_LONG_FMT ") must be within -1..9", level); - RETURN_FALSE; + zend_value_error("deflate_init(): \"level\" option must be between -1 and 9"); + RETURN_THROWS(); } if (options && (option_buffer = zend_hash_str_find(options, ZEND_STRL("memory"))) != NULL) { memory = zval_get_long(option_buffer); } if (memory < 1 || memory > 9) { - php_error_docref(NULL, E_WARNING, "compression memory level (" ZEND_LONG_FMT ") must be within 1..9", memory); - RETURN_FALSE; + zend_value_error("deflate_init(): \"memory\" option must be between 1 and 9"); + RETURN_THROWS(); } if (options && (option_buffer = zend_hash_str_find(options, ZEND_STRL("window"))) != NULL) { window = zval_get_long(option_buffer); } if (window < 8 || window > 15) { - php_error_docref(NULL, E_WARNING, "zlib window size (logarithm) (" ZEND_LONG_FMT ") must be within 8..15", window); - RETURN_FALSE; + zend_value_error("deflate_init(): \"window\" option must be between 8 and 15"); + RETURN_THROWS(); } if (options && (option_buffer = zend_hash_str_find(options, ZEND_STRL("strategy"))) != NULL) { @@ -1112,12 +1129,12 @@ PHP_FUNCTION(deflate_init) case Z_DEFAULT_STRATEGY: break; default: - php_error_docref(NULL, E_WARNING, "strategy must be one of ZLIB_FILTERED, ZLIB_HUFFMAN_ONLY, ZLIB_RLE, ZLIB_FIXED or ZLIB_DEFAULT_STRATEGY"); - RETURN_FALSE; + zend_value_error("deflate_init(): \"strategy\" option must be one of ZLIB_FILTERED, ZLIB_HUFFMAN_ONLY, ZLIB_RLE, ZLIB_FIXED, or ZLIB_DEFAULT_STRATEGY"); + RETURN_THROWS(); } if (!zlib_create_dictionary_string(options, &dict, &dictlen)) { - RETURN_FALSE; + RETURN_THROWS(); } switch (encoding) { @@ -1126,14 +1143,15 @@ PHP_FUNCTION(deflate_init) case PHP_ZLIB_ENCODING_DEFLATE: break; default: - php_error_docref(NULL, E_WARNING, - "encoding mode must be ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE"); - RETURN_FALSE; + zend_argument_value_error(1, "must be one of ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP, or ZLIB_ENCODING_DEFLATE"); + RETURN_THROWS(); } - ctx = ecalloc(1, sizeof(php_zlib_context)); - ctx->zalloc = php_zlib_alloc; - ctx->zfree = php_zlib_free; + object_init_ex(return_value, deflate_context_ce); + ctx = Z_DEFLATE_CONTEXT_P(return_value); + + ctx->Z.zalloc = php_zlib_alloc; + ctx->Z.zfree = php_zlib_free; if (encoding < 0) { encoding += 15 - window; @@ -1141,49 +1159,42 @@ PHP_FUNCTION(deflate_init) encoding -= 15 - window; } - if (Z_OK == deflateInit2(ctx, level, Z_DEFLATED, encoding, memory, strategy)) { - if (dict) { - int success = deflateSetDictionary(ctx, (Bytef *) dict, dictlen); - ZEND_ASSERT(success == Z_OK); - efree(dict); - } - - RETURN_RES(zend_register_resource(ctx, le_deflate)); - } else { - efree(ctx); - php_error_docref(NULL, E_WARNING, "failed allocating zlib.deflate context"); + if (deflateInit2(&ctx->Z, level, Z_DEFLATED, encoding, memory, strategy) != Z_OK) { + zval_ptr_dtor(return_value); + php_error_docref(NULL, E_WARNING, "Failed allocating zlib.deflate context"); RETURN_FALSE; } + + if (dict) { + int success = deflateSetDictionary(&ctx->Z, (Bytef *) dict, dictlen); + ZEND_ASSERT(success == Z_OK); + efree(dict); + } } /* }}} */ -/* {{{ proto string deflate_add(resource context, string data[, int flush_mode = ZLIB_SYNC_FLUSH]) - Incrementally deflate data in the specified context */ +/* {{{ Incrementally deflate data in the specified context */ PHP_FUNCTION(deflate_add) { zend_string *out; char *in_buf; size_t in_len, out_size, buffer_used; zval *res; - z_stream *ctx; + php_zlib_context *ctx; zend_long flush_type = Z_SYNC_FLUSH; int status; - if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "rs|l", &res, &in_buf, &in_len, &flush_type)) { - return; + if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "Os|l", &res, deflate_context_ce, &in_buf, &in_len, &flush_type)) { + RETURN_THROWS(); } - if (!(ctx = zend_fetch_resource_ex(res, NULL, le_deflate))) { - php_error_docref(NULL, E_WARNING, "Invalid deflate resource"); - RETURN_FALSE; - } + ctx = Z_DEFLATE_CONTEXT_P(res); switch (flush_type) { case Z_BLOCK: #if ZLIB_VERNUM < 0x1240L - php_error_docref(NULL, E_WARNING, - "zlib >= 1.2.4 required for BLOCK deflate; current version: %s", ZLIB_VERSION); - RETURN_FALSE; + zend_throw_error(NULL, "zlib >= 1.2.4 required for BLOCK deflate; current version: %s", ZLIB_VERSION); + RETURN_THROWS(); #endif case Z_NO_FLUSH: case Z_PARTIAL_FLUSH: @@ -1193,9 +1204,8 @@ PHP_FUNCTION(deflate_add) break; default: - php_error_docref(NULL, E_WARNING, - "flush mode must be ZLIB_NO_FLUSH, ZLIB_PARTIAL_FLUSH, ZLIB_SYNC_FLUSH, ZLIB_FULL_FLUSH, ZLIB_BLOCK or ZLIB_FINISH"); - RETURN_FALSE; + zend_argument_value_error(3, "must be one of ZLIB_NO_FLUSH, ZLIB_PARTIAL_FLUSH, ZLIB_SYNC_FLUSH, ZLIB_FULL_FLUSH, ZLIB_BLOCK, or ZLIB_FINISH"); + RETURN_THROWS(); } if (in_len <= 0 && flush_type != Z_FINISH) { @@ -1206,35 +1216,35 @@ PHP_FUNCTION(deflate_add) out_size = (out_size < 64) ? 64 : out_size; out = zend_string_alloc(out_size, 0); - ctx->next_in = (Bytef *) in_buf; - ctx->next_out = (Bytef *) ZSTR_VAL(out); - ctx->avail_in = in_len; - ctx->avail_out = ZSTR_LEN(out); + ctx->Z.next_in = (Bytef *) in_buf; + ctx->Z.next_out = (Bytef *) ZSTR_VAL(out); + ctx->Z.avail_in = in_len; + ctx->Z.avail_out = ZSTR_LEN(out); buffer_used = 0; do { - if (ctx->avail_out == 0) { + if (ctx->Z.avail_out == 0) { /* more output buffer space needed; realloc and try again */ /* adding 64 more bytes solved every issue I have seen */ out = zend_string_realloc(out, ZSTR_LEN(out) + 64, 0); - ctx->avail_out = 64; - ctx->next_out = (Bytef *) ZSTR_VAL(out) + buffer_used; + ctx->Z.avail_out = 64; + ctx->Z.next_out = (Bytef *) ZSTR_VAL(out) + buffer_used; } - status = deflate(ctx, flush_type); - buffer_used = ZSTR_LEN(out) - ctx->avail_out; - } while (status == Z_OK && ctx->avail_out == 0); + status = deflate(&ctx->Z, flush_type); + buffer_used = ZSTR_LEN(out) - ctx->Z.avail_out; + } while (status == Z_OK && ctx->Z.avail_out == 0); switch (status) { case Z_OK: - ZSTR_LEN(out) = (char *) ctx->next_out - ZSTR_VAL(out); + ZSTR_LEN(out) = (char *) ctx->Z.next_out - ZSTR_VAL(out); ZSTR_VAL(out)[ZSTR_LEN(out)] = 0; RETURN_STR(out); break; case Z_STREAM_END: - ZSTR_LEN(out) = (char *) ctx->next_out - ZSTR_VAL(out); + ZSTR_LEN(out) = (char *) ctx->Z.next_out - ZSTR_VAL(out); ZSTR_VAL(out)[ZSTR_LEN(out)] = 0; - deflateReset(ctx); + deflateReset(&ctx->Z); RETURN_STR(out); break; default: @@ -1252,190 +1262,11 @@ ZEND_TSRMLS_CACHE_DEFINE() ZEND_GET_MODULE(php_zlib) #endif -/* {{{ arginfo */ -ZEND_BEGIN_ARG_INFO_EX(arginfo_ob_gzhandler, 0, 0, 2) - ZEND_ARG_INFO(0, data) - ZEND_ARG_INFO(0, flags) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_zlib_get_coding_type, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_gzfile, 0, 0, 1) - ZEND_ARG_INFO(0, filename) - ZEND_ARG_INFO(0, use_include_path) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_gzopen, 0, 0, 2) - ZEND_ARG_INFO(0, filename) - ZEND_ARG_INFO(0, mode) - ZEND_ARG_INFO(0, use_include_path) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_readgzfile, 0, 0, 1) - ZEND_ARG_INFO(0, filename) - ZEND_ARG_INFO(0, use_include_path) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_zlib_encode, 0, 0, 2) - ZEND_ARG_INFO(0, data) - ZEND_ARG_INFO(0, encoding) - ZEND_ARG_INFO(0, level) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_zlib_decode, 0, 0, 1) - ZEND_ARG_INFO(0, data) - ZEND_ARG_INFO(0, max_decoded_len) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_gzdeflate, 0, 0, 1) - ZEND_ARG_INFO(0, data) - ZEND_ARG_INFO(0, level) - ZEND_ARG_INFO(0, encoding) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_gzencode, 0, 0, 1) - ZEND_ARG_INFO(0, data) - ZEND_ARG_INFO(0, level) - ZEND_ARG_INFO(0, encoding) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_gzcompress, 0, 0, 1) - ZEND_ARG_INFO(0, data) - ZEND_ARG_INFO(0, level) - ZEND_ARG_INFO(0, encoding) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_gzinflate, 0, 0, 1) - ZEND_ARG_INFO(0, data) - ZEND_ARG_INFO(0, max_decoded_len) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_gzdecode, 0, 0, 1) - ZEND_ARG_INFO(0, data) - ZEND_ARG_INFO(0, max_decoded_len) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_gzuncompress, 0, 0, 1) - ZEND_ARG_INFO(0, data) - ZEND_ARG_INFO(0, max_decoded_len) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_gzputs, 0, 0, 2) - ZEND_ARG_INFO(0, fp) - ZEND_ARG_INFO(0, str) - ZEND_ARG_INFO(0, length) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_gzpassthru, 0) - ZEND_ARG_INFO(0, fp) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_gzseek, 0, 0, 2) - ZEND_ARG_INFO(0, fp) - ZEND_ARG_INFO(0, offset) - ZEND_ARG_INFO(0, whence) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_gzread, 0) - ZEND_ARG_INFO(0, fp) - ZEND_ARG_INFO(0, length) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_gzgetss, 0, 0, 1) - ZEND_ARG_INFO(0, fp) - ZEND_ARG_INFO(0, length) - ZEND_ARG_INFO(0, allowable_tags) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_gzgets, 0, 0, 1) - ZEND_ARG_INFO(0, fp) - ZEND_ARG_INFO(0, length) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_deflate_init, 0, 0, 1) - ZEND_ARG_INFO(0, encoding) - ZEND_ARG_INFO(0, level) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_deflate_add, 0, 0, 2) - ZEND_ARG_INFO(0, resource) - ZEND_ARG_INFO(0, add) - ZEND_ARG_INFO(0, flush_behavior) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_inflate_init, 0, 0, 1) - ZEND_ARG_INFO(0, encoding) - ZEND_ARG_INFO(0, options) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_inflate_add, 0, 0, 2) - ZEND_ARG_INFO(0, context) - ZEND_ARG_INFO(0, encoded_data) - ZEND_ARG_INFO(0, flush_mode) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_inflate_get_status, 0, 0, 1) - ZEND_ARG_INFO(0, resource) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_inflate_get_read_len, 0, 0, 1) - ZEND_ARG_INFO(0, resource) -ZEND_END_ARG_INFO() - -/* }}} */ - -/* {{{ php_zlib_functions[] */ -static const zend_function_entry php_zlib_functions[] = { - PHP_FE(readgzfile, arginfo_readgzfile) - PHP_FALIAS(gzrewind, rewind, arginfo_gzpassthru) - PHP_FALIAS(gzclose, fclose, arginfo_gzpassthru) - PHP_FALIAS(gzeof, feof, arginfo_gzpassthru) - PHP_FALIAS(gzgetc, fgetc, arginfo_gzpassthru) - PHP_FALIAS(gzgets, fgets, arginfo_gzgets) - PHP_DEP_FALIAS(gzgetss, fgetss, arginfo_gzgetss) - PHP_FALIAS(gzread, fread, arginfo_gzread) - PHP_FE(gzopen, arginfo_gzopen) - PHP_FALIAS(gzpassthru, fpassthru, arginfo_gzpassthru) - PHP_FALIAS(gzseek, fseek, arginfo_gzseek) - PHP_FALIAS(gztell, ftell, arginfo_gzpassthru) - PHP_FALIAS(gzwrite, fwrite, arginfo_gzputs) - PHP_FALIAS(gzputs, fwrite, arginfo_gzputs) - PHP_FE(gzfile, arginfo_gzfile) - PHP_FE(gzcompress, arginfo_gzcompress) - PHP_FE(gzuncompress, arginfo_gzuncompress) - PHP_FE(gzdeflate, arginfo_gzdeflate) - PHP_FE(gzinflate, arginfo_gzinflate) - PHP_FE(gzencode, arginfo_gzencode) - PHP_FE(gzdecode, arginfo_gzdecode) - PHP_FE(zlib_encode, arginfo_zlib_encode) - PHP_FE(zlib_decode, arginfo_zlib_decode) - PHP_FE(zlib_get_coding_type, arginfo_zlib_get_coding_type) - PHP_FE(deflate_init, arginfo_deflate_init) - PHP_FE(deflate_add, arginfo_deflate_add) - PHP_FE(inflate_init, arginfo_inflate_init) - PHP_FE(inflate_add, arginfo_inflate_add) - PHP_FE(inflate_get_status, arginfo_inflate_get_status) - PHP_FE(inflate_get_read_len, arginfo_inflate_get_read_len) - PHP_FE(ob_gzhandler, arginfo_ob_gzhandler) - PHP_FE_END -}; -/* }}} */ - /* {{{ OnUpdate_zlib_output_compression */ static PHP_INI_MH(OnUpdate_zlib_output_compression) { int int_value; char *ini_value; - zend_long *p; -#ifndef ZTS - char *base = (char *) mh_arg2; -#else - char *base; - - base = (char *) ts_resource(*((int *) mh_arg2)); -#endif - if (new_value == NULL) { return FAILURE; } @@ -1461,7 +1292,7 @@ static PHP_INI_MH(OnUpdate_zlib_output_compression) } } - p = (zend_long *) (base+(size_t) mh_arg1); + zend_long *p = (zend_long *) ZEND_INI_GET_ADDR(); *p = int_value; ZLIBG(output_compression) = ZLIBG(output_compression_default); @@ -1506,8 +1337,33 @@ static PHP_MINIT_FUNCTION(zlib) php_output_handler_conflict_register(ZEND_STRL("ob_gzhandler"), php_zlib_output_conflict_check); php_output_handler_conflict_register(ZEND_STRL(PHP_ZLIB_OUTPUT_HANDLER_NAME), php_zlib_output_conflict_check); - le_deflate = zend_register_list_destructors_ex(deflate_rsrc_dtor, NULL, "zlib.deflate", module_number); - le_inflate = zend_register_list_destructors_ex(inflate_rsrc_dtor, NULL, "zlib.inflate", module_number); + zend_class_entry inflate_ce; + INIT_CLASS_ENTRY(inflate_ce, "InflateContext", class_InflateContext_methods); + inflate_context_ce = zend_register_internal_class(&inflate_ce); + inflate_context_ce->ce_flags |= ZEND_ACC_FINAL | ZEND_ACC_NO_DYNAMIC_PROPERTIES; + inflate_context_ce->create_object = inflate_context_create_object; + inflate_context_ce->serialize = zend_class_serialize_deny; + inflate_context_ce->unserialize = zend_class_unserialize_deny; + + memcpy(&inflate_context_object_handlers, &std_object_handlers, sizeof(zend_object_handlers)); + inflate_context_object_handlers.offset = XtOffsetOf(php_zlib_context, std); + inflate_context_object_handlers.free_obj = inflate_context_free_obj; + inflate_context_object_handlers.get_constructor = inflate_context_get_constructor; + inflate_context_object_handlers.clone_obj = NULL; + + zend_class_entry deflate_ce; + INIT_CLASS_ENTRY(deflate_ce, "DeflateContext", class_DeflateContext_methods); + deflate_context_ce = zend_register_internal_class(&deflate_ce); + deflate_context_ce->ce_flags |= ZEND_ACC_FINAL | ZEND_ACC_NO_DYNAMIC_PROPERTIES; + deflate_context_ce->create_object = deflate_context_create_object; + deflate_context_ce->serialize = zend_class_serialize_deny; + deflate_context_ce->unserialize = zend_class_unserialize_deny; + + memcpy(&deflate_context_object_handlers, &std_object_handlers, sizeof(zend_object_handlers)); + deflate_context_object_handlers.offset = XtOffsetOf(php_zlib_context, std); + deflate_context_object_handlers.free_obj = deflate_context_free_obj; + deflate_context_object_handlers.get_constructor = deflate_context_get_constructor; + deflate_context_object_handlers.clone_obj = NULL; REGISTER_LONG_CONSTANT("FORCE_GZIP", PHP_ZLIB_ENCODING_GZIP, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FORCE_DEFLATE", PHP_ZLIB_ENCODING_DEFLATE, CONST_CS|CONST_PERSISTENT); @@ -1612,7 +1468,7 @@ static PHP_GINIT_FUNCTION(zlib) zend_module_entry php_zlib_module_entry = { STANDARD_MODULE_HEADER, "zlib", - php_zlib_functions, + ext_functions, PHP_MINIT(zlib), PHP_MSHUTDOWN(zlib), PHP_RINIT(zlib), diff --git a/ext/zlib/zlib.stub.php b/ext/zlib/zlib.stub.php new file mode 100644 index 0000000000..fdb7e7c8ef --- /dev/null +++ b/ext/zlib/zlib.stub.php @@ -0,0 +1,116 @@ +<?php + +/** @generate-function-entries */ + +final class InflateContext +{ +} + +final class DeflateContext +{ +} + +function ob_gzhandler(string $data, int $flags): string|false {} + +function zlib_get_coding_type(): string|false {} + +function gzfile(string $filename, int $use_include_path = 0): array|false {} + +/** @return resource|false */ +function gzopen(string $filename, string $mode, int $use_include_path = 0) {} + +function readgzfile(string $filename, int $use_include_path = 0): int|false {} + +function zlib_encode(string $data, int $encoding, int $level = -1): string|false {} + +function zlib_decode(string $data, int $max_length = 0): string|false {} + +function gzdeflate(string $data, int $level = -1, int $encoding = ZLIB_ENCODING_RAW): string|false {} + +function gzencode(string $data, int $level = -1, int $encoding = ZLIB_ENCODING_GZIP): string|false {} + +function gzcompress(string $data, int $level = -1, int $encoding = ZLIB_ENCODING_DEFLATE): string|false {} + +function gzinflate(string $data, int $max_length = 0): string|false {} + +function gzdecode(string $data, int $max_length = 0): string|false {} + +function gzuncompress(string $data, int $max_length = 0): string|false {} + +/** + * @param resource $stream + * @alias fwrite + */ +function gzwrite($stream, string $data, ?int $length = null): int|false {} + +/** + * @param resource $stream + * @alias fwrite + */ +function gzputs($stream, string $data, ?int $length = null): int|false {} + +/** + * @param resource $stream + * @alias rewind + */ +function gzrewind($stream): bool {} + +/** + * @param resource $stream + * @alias fclose + */ +function gzclose($stream): bool {} + +/** + * @param resource $stream + * @alias feof + */ +function gzeof($stream): bool {} + +/** + * @param resource $stream + * @alias fgetc + */ +function gzgetc($stream): string|false {} + +/** + * @param resource $stream + * @alias fpassthru + */ +function gzpassthru($stream): int {} + +/** + * @param resource $stream + * @alias fseek + */ +function gzseek($stream, int $offset, int $whence = SEEK_SET): int {} + +/** + * @param resource $stream + * @alias ftell + */ +function gztell($stream): int|false {} + +/** + * @param resource $stream + * @alias fread + */ +function gzread($stream, int $length): string|false {} + +/** + * @param resource $stream + * @alias fgets + */ +function gzgets($stream, int $length = 1024): string|false {} + +function deflate_init(int $encoding, array $options = []): DeflateContext|false {} + +function deflate_add(DeflateContext $context, string $data, int $flush_mode = ZLIB_SYNC_FLUSH): string|false {} + +function inflate_init(int $encoding, array $options = []): InflateContext|false {} + +function inflate_add(InflateContext $context, string $data, int $flush_mode = ZLIB_SYNC_FLUSH): string|false {} + +function inflate_get_status(InflateContext $context): int {} + +function inflate_get_read_len(InflateContext $context): int {} diff --git a/ext/zlib/zlib_arginfo.h b/ext/zlib/zlib_arginfo.h new file mode 100644 index 0000000000..76b966093d --- /dev/null +++ b/ext/zlib/zlib_arginfo.h @@ -0,0 +1,209 @@ +/* This is a generated file, edit the .stub.php file instead. + * Stub hash: 4106a50d3930915e47548be72f984420c5af6149 */ + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ob_gzhandler, 0, 2, MAY_BE_STRING|MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, flags, IS_LONG, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_zlib_get_coding_type, 0, 0, MAY_BE_STRING|MAY_BE_FALSE) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_gzfile, 0, 1, MAY_BE_ARRAY|MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, use_include_path, IS_LONG, 0, "0") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_gzopen, 0, 0, 2) + ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, mode, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, use_include_path, IS_LONG, 0, "0") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_readgzfile, 0, 1, MAY_BE_LONG|MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, use_include_path, IS_LONG, 0, "0") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_zlib_encode, 0, 2, MAY_BE_STRING|MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, encoding, IS_LONG, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, level, IS_LONG, 0, "-1") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_zlib_decode, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, max_length, IS_LONG, 0, "0") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_gzdeflate, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, level, IS_LONG, 0, "-1") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_LONG, 0, "ZLIB_ENCODING_RAW") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_gzencode, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, level, IS_LONG, 0, "-1") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_LONG, 0, "ZLIB_ENCODING_GZIP") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_gzcompress, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, level, IS_LONG, 0, "-1") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_LONG, 0, "ZLIB_ENCODING_DEFLATE") +ZEND_END_ARG_INFO() + +#define arginfo_gzinflate arginfo_zlib_decode + +#define arginfo_gzdecode arginfo_zlib_decode + +#define arginfo_gzuncompress arginfo_zlib_decode + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_gzwrite, 0, 2, MAY_BE_LONG|MAY_BE_FALSE) + ZEND_ARG_INFO(0, stream) + ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 1, "null") +ZEND_END_ARG_INFO() + +#define arginfo_gzputs arginfo_gzwrite + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gzrewind, 0, 1, _IS_BOOL, 0) + ZEND_ARG_INFO(0, stream) +ZEND_END_ARG_INFO() + +#define arginfo_gzclose arginfo_gzrewind + +#define arginfo_gzeof arginfo_gzrewind + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_gzgetc, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) + ZEND_ARG_INFO(0, stream) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gzpassthru, 0, 1, IS_LONG, 0) + ZEND_ARG_INFO(0, stream) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gzseek, 0, 2, IS_LONG, 0) + ZEND_ARG_INFO(0, stream) + ZEND_ARG_TYPE_INFO(0, offset, IS_LONG, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, whence, IS_LONG, 0, "SEEK_SET") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_gztell, 0, 1, MAY_BE_LONG|MAY_BE_FALSE) + ZEND_ARG_INFO(0, stream) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_gzread, 0, 2, MAY_BE_STRING|MAY_BE_FALSE) + ZEND_ARG_INFO(0, stream) + ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_gzgets, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) + ZEND_ARG_INFO(0, stream) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 0, "1024") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_deflate_init, 0, 1, DeflateContext, MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, encoding, IS_LONG, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "[]") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_deflate_add, 0, 2, MAY_BE_STRING|MAY_BE_FALSE) + ZEND_ARG_OBJ_INFO(0, context, DeflateContext, 0) + ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flush_mode, IS_LONG, 0, "ZLIB_SYNC_FLUSH") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_inflate_init, 0, 1, InflateContext, MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, encoding, IS_LONG, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "[]") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_inflate_add, 0, 2, MAY_BE_STRING|MAY_BE_FALSE) + ZEND_ARG_OBJ_INFO(0, context, InflateContext, 0) + ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flush_mode, IS_LONG, 0, "ZLIB_SYNC_FLUSH") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_inflate_get_status, 0, 1, IS_LONG, 0) + ZEND_ARG_OBJ_INFO(0, context, InflateContext, 0) +ZEND_END_ARG_INFO() + +#define arginfo_inflate_get_read_len arginfo_inflate_get_status + + +ZEND_FUNCTION(ob_gzhandler); +ZEND_FUNCTION(zlib_get_coding_type); +ZEND_FUNCTION(gzfile); +ZEND_FUNCTION(gzopen); +ZEND_FUNCTION(readgzfile); +ZEND_FUNCTION(zlib_encode); +ZEND_FUNCTION(zlib_decode); +ZEND_FUNCTION(gzdeflate); +ZEND_FUNCTION(gzencode); +ZEND_FUNCTION(gzcompress); +ZEND_FUNCTION(gzinflate); +ZEND_FUNCTION(gzdecode); +ZEND_FUNCTION(gzuncompress); +ZEND_FUNCTION(fwrite); +ZEND_FUNCTION(rewind); +ZEND_FUNCTION(fclose); +ZEND_FUNCTION(feof); +ZEND_FUNCTION(fgetc); +ZEND_FUNCTION(fpassthru); +ZEND_FUNCTION(fseek); +ZEND_FUNCTION(ftell); +ZEND_FUNCTION(fread); +ZEND_FUNCTION(fgets); +ZEND_FUNCTION(deflate_init); +ZEND_FUNCTION(deflate_add); +ZEND_FUNCTION(inflate_init); +ZEND_FUNCTION(inflate_add); +ZEND_FUNCTION(inflate_get_status); +ZEND_FUNCTION(inflate_get_read_len); + + +static const zend_function_entry ext_functions[] = { + ZEND_FE(ob_gzhandler, arginfo_ob_gzhandler) + ZEND_FE(zlib_get_coding_type, arginfo_zlib_get_coding_type) + ZEND_FE(gzfile, arginfo_gzfile) + ZEND_FE(gzopen, arginfo_gzopen) + ZEND_FE(readgzfile, arginfo_readgzfile) + ZEND_FE(zlib_encode, arginfo_zlib_encode) + ZEND_FE(zlib_decode, arginfo_zlib_decode) + ZEND_FE(gzdeflate, arginfo_gzdeflate) + ZEND_FE(gzencode, arginfo_gzencode) + ZEND_FE(gzcompress, arginfo_gzcompress) + ZEND_FE(gzinflate, arginfo_gzinflate) + ZEND_FE(gzdecode, arginfo_gzdecode) + ZEND_FE(gzuncompress, arginfo_gzuncompress) + ZEND_FALIAS(gzwrite, fwrite, arginfo_gzwrite) + ZEND_FALIAS(gzputs, fwrite, arginfo_gzputs) + ZEND_FALIAS(gzrewind, rewind, arginfo_gzrewind) + ZEND_FALIAS(gzclose, fclose, arginfo_gzclose) + ZEND_FALIAS(gzeof, feof, arginfo_gzeof) + ZEND_FALIAS(gzgetc, fgetc, arginfo_gzgetc) + ZEND_FALIAS(gzpassthru, fpassthru, arginfo_gzpassthru) + ZEND_FALIAS(gzseek, fseek, arginfo_gzseek) + ZEND_FALIAS(gztell, ftell, arginfo_gztell) + ZEND_FALIAS(gzread, fread, arginfo_gzread) + ZEND_FALIAS(gzgets, fgets, arginfo_gzgets) + ZEND_FE(deflate_init, arginfo_deflate_init) + ZEND_FE(deflate_add, arginfo_deflate_add) + ZEND_FE(inflate_init, arginfo_inflate_init) + ZEND_FE(inflate_add, arginfo_inflate_add) + ZEND_FE(inflate_get_status, arginfo_inflate_get_status) + ZEND_FE(inflate_get_read_len, arginfo_inflate_get_read_len) + ZEND_FE_END +}; + + +static const zend_function_entry class_InflateContext_methods[] = { + ZEND_FE_END +}; + + +static const zend_function_entry class_DeflateContext_methods[] = { + ZEND_FE_END +}; diff --git a/ext/zlib/zlib_filter.c b/ext/zlib/zlib_filter.c index 3654a140fd..cffa65f488 100644 --- a/ext/zlib/zlib_filter.c +++ b/ext/zlib/zlib_filter.c @@ -1,7 +1,5 @@ /* +----------------------------------------------------------------------+ - | PHP Version 7 | - +----------------------------------------------------------------------+ | Copyright (c) The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | @@ -92,6 +90,7 @@ static php_stream_filter_status_t php_zlib_inflate_filter( exit_status = PSFS_PASS_ON; } else if (status != Z_OK) { /* Something bad happened */ + php_error_docref(NULL, E_NOTICE, "zlib: %s", zError(status)); php_stream_bucket_delref(bucket); /* reset these because despite the error the filter may be used again */ data->strm.next_in = data->inbuf; diff --git a/ext/zlib/zlib_fopen_wrapper.c b/ext/zlib/zlib_fopen_wrapper.c index 514773f2b0..ef26aaf787 100644 --- a/ext/zlib/zlib_fopen_wrapper.c +++ b/ext/zlib/zlib_fopen_wrapper.c @@ -1,7 +1,5 @@ /* +----------------------------------------------------------------------+ - | PHP Version 7 | - +----------------------------------------------------------------------+ | Copyright (c) The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | @@ -114,7 +112,7 @@ php_stream *php_stream_gzopen(php_stream_wrapper *wrapper, const char *path, con /* sanity check the stream: it can be either read-only or write-only */ if (strchr(mode, '+')) { if (options & REPORT_ERRORS) { - php_error_docref(NULL, E_WARNING, "cannot open a zlib stream for reading and writing at the same time!"); + php_error_docref(NULL, E_WARNING, "Cannot open a zlib stream for reading and writing at the same time!"); } return NULL; } |