Skip to content

Review parameter names in ext/zlib #6250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/bz2/bz2.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function bzread($bz, int $length = 1024): string|false {}
* @param resource $bz
* @alias fwrite
*/
function bzwrite($bz, string $str, ?int $length = null): int|false {}
function bzwrite($bz, string $data, ?int $max_length = null): int|false {}

/**
* @param resource $bz
Expand Down
6 changes: 3 additions & 3 deletions ext/bz2/bz2_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 9bcd75ddbde225e65ee9f00d86d16677d671b4e4 */
* Stub hash: e18326d2ddbe564858abb531fc41b7907fba35c4 */

ZEND_BEGIN_ARG_INFO_EX(arginfo_bzopen, 0, 0, 2)
ZEND_ARG_INFO(0, file)
Expand All @@ -13,8 +13,8 @@ ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_bzwrite, 0, 2, MAY_BE_LONG|MAY_BE_FALSE)
ZEND_ARG_INFO(0, bz)
ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 1, "null")
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, max_length, IS_LONG, 1, "null")
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_bzflush, 0, 1, _IS_BOOL, 0)
Expand Down
4 changes: 2 additions & 2 deletions ext/standard/basic_functions.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -823,13 +823,13 @@ function ftell($stream): int|false {}
function fflush($stream): bool {}

/** @param resource $stream */
function fwrite($stream, string $string, ?int $max_length = null): int|false {}
function fwrite($stream, string $data, ?int $max_length = null): int|false {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I see a compelling reason to deviate from the usual $string name here. For that matter, if we s/$data/$string in all those gz APIs, I don't think things get worse. Do they?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not opposed to use $string, but I'd prefer $data much more than $string since it describes the purpose of the parameter much better. And actually, we used $data in case of SessionHandler::write() and shmop_write(), that's why I'd like to follow the practice here as well

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I'm fine with that. It might make sense to also adjust file_put_contents() while you're already here.

Copy link
Member Author

@kocsismate kocsismate Oct 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just applied this to master


/**
* @param resource $stream
* @alias fwrite
*/
function fputs($stream, string $string, ?int $max_length = null): int|false {}
function fputs($stream, string $data, ?int $max_length = null): int|false {}

/** @param resource|null $context */
function mkdir(string $directory, int $mode = 0777, bool $recursive = false, $context = null): bool {}
Expand Down
4 changes: 2 additions & 2 deletions ext/standard/basic_functions_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: af5b921b66f7dd68ba8c771199825a439a07dba0 */
* Stub hash: f28c0c03c9c391c3606f45de3aee6ffe12703069 */

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, seconds, IS_LONG, 0)
Expand Down Expand Up @@ -1267,7 +1267,7 @@ ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_fwrite, 0, 2, MAY_BE_LONG|MAY_BE_FALSE)
ZEND_ARG_INFO(0, stream)
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, max_length, IS_LONG, 1, "null")
ZEND_END_ARG_INFO()

Expand Down
2 changes: 1 addition & 1 deletion ext/zlib/tests/005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ string(%d) "%a"

Warning: gzuncompress(): %s error in %s on line %d
bool(false)
gzuncompress(): Argument #2 ($max_decoded_len) must be greater than or equal to 0
gzuncompress(): Argument #2 ($max_length) must be greater than or equal to 0

Warning: gzuncompress(): %s error in %s on line %d
bool(false)
Expand Down
2 changes: 1 addition & 1 deletion ext/zlib/tests/006.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ bool(false)

Warning: gzinflate(): data error in %s on line %d
bool(false)
gzinflate(): Argument #2 ($max_decoded_len) must be greater than or equal to 0
gzinflate(): Argument #2 ($max_length) must be greater than or equal to 0

Warning: gzinflate(): data error in %s on line %d
bool(false)
Expand Down
2 changes: 1 addition & 1 deletion ext/zlib/tests/deflate_add_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ try {
?>
--EXPECT--
deflate_add(): Argument #1 ($context) must be of type DeflateContext, resource given
deflate_add(): Argument #3 ($flush_behavior) must be one of ZLIB_NO_FLUSH, ZLIB_PARTIAL_FLUSH, ZLIB_SYNC_FLUSH, ZLIB_FULL_FLUSH, ZLIB_BLOCK, or ZLIB_FINISH
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
56 changes: 28 additions & 28 deletions ext/zlib/zlib.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,93 +23,93 @@ 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_decoded_len = 0): 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_decoded_len = 0): string|false {}
function gzinflate(string $data, int $max_length = 0): string|false {}

function gzdecode(string $data, int $max_decoded_len = 0): string|false {}
function gzdecode(string $data, int $max_length = 0): string|false {}

function gzuncompress(string $data, int $max_decoded_len = 0): string|false {}
function gzuncompress(string $data, int $max_length = 0): string|false {}

/**
* @param resource $fp
* @param resource $stream
* @alias fwrite
*/
function gzwrite($fp, string $str, ?int $length = null): int|false {}
function gzwrite($stream, string $data, ?int $max_length = null): int|false {}

/**
* @param resource $fp
* @param resource $stream
* @alias fwrite
*/
function gzputs($fp, string $str, ?int $length = null): int|false {}
function gzputs($stream, string $data, ?int $max_length = null): int|false {}

/**
* @param resource $fp
* @param resource $stream
* @alias rewind
*/
function gzrewind($fp): bool {}
function gzrewind($stream): bool {}

/**
* @param resource $fp
* @param resource $stream
* @alias fclose
*/
function gzclose($fp): bool {}
function gzclose($stream): bool {}

/**
* @param resource $fp
* @param resource $stream
* @alias feof
*/
function gzeof($fp): bool {}
function gzeof($stream): bool {}

/**
* @param resource $fp
* @param resource $stream
* @alias fgetc
*/
function gzgetc($fp): string|false {}
function gzgetc($stream): string|false {}

/**
* @param resource $fp
* @param resource $stream
* @alias fpassthru
*/
function gzpassthru($fp): int {}
function gzpassthru($stream): int {}

/**
* @param resource $fp
* @param resource $stream
* @alias fseek
*/
function gzseek($fp, int $offset, int $whence = SEEK_SET): int {}
function gzseek($stream, int $offset, int $whence = SEEK_SET): int {}

/**
* @param resource $fp
* @param resource $stream
* @alias ftell
*/
function gztell($fp): int|false {}
function gztell($stream): int|false {}

/**
* @param resource $fp
* @param resource $stream
* @alias fread
*/
function gzread($fp, int $length): string|false {}
function gzread($stream, int $length): string|false {}

/**
* @param resource $fp
* @param resource $stream
* @alias fgets
*/
function gzgets($fp, int $length = 1024): string|false {}
function gzgets($stream, int $length = 1024): string|false {}

function deflate_init(int $encoding, array $options = []): DeflateContext|false {}

function deflate_add(DeflateContext $context, string $add, int $flush_behavior = ZLIB_SYNC_FLUSH): string|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 $encoded_data, int $flush_mode = ZLIB_SYNC_FLUSH): string|false {}
function inflate_add(InflateContext $context, string $data, int $flush_mode = ZLIB_SYNC_FLUSH): string|false {}

function inflate_get_status(InflateContext $context): int {}

Expand Down
30 changes: 15 additions & 15 deletions ext/zlib/zlib_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: b31cdbe9a5d719194753bfe303d32319478048bb */
* Stub hash: e9347c139d418c36d889d2becf57535f1c76efed */

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)
Expand Down Expand Up @@ -33,7 +33,7 @@ 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_decoded_len, IS_LONG, 0, "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)
Expand Down Expand Up @@ -61,46 +61,46 @@ ZEND_END_ARG_INFO()
#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, fp)
ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 1, "null")
ZEND_ARG_INFO(0, stream)
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, max_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, fp)
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, fp)
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, fp)
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, fp)
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, fp)
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, fp)
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, fp)
ZEND_ARG_INFO(0, stream)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 0, "1024")
ZEND_END_ARG_INFO()

Expand All @@ -111,8 +111,8 @@ 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, add, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flush_behavior, IS_LONG, 0, "ZLIB_SYNC_FLUSH")
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)
Expand All @@ -122,7 +122,7 @@ 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, encoded_data, IS_STRING, 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()

Expand Down