Skip to content

Improve parameter names in ext/hash #6156

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 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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
26 changes: 13 additions & 13 deletions ext/hash/hash.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,48 @@

/** @generate-function-entries */

function hash(string $algo, string $data, bool $raw_output = false): string|false {}
function hash(string $algorithm, string $data, bool $binary_output = false): string|false {}

function hash_file(string $algo, string $filename, bool $raw_output = false): string|false {}
function hash_file(string $algorithm, string $filename, bool $binary_output = false): string|false {}

function hash_hmac(string $algo, string $data, string $key, bool $raw_output = false): string|false {}
function hash_hmac(string $algorithm, string $data, string $key, bool $binary_output = false): string|false {}

function hash_hmac_file(string $algo, string $data, string $key, bool $raw_output = false): string|false {}
function hash_hmac_file(string $algorithm, string $data, string $key, bool $binary_output = false): string|false {}

function hash_init(string $algo, int $options = 0, string $key = ""): HashContext {}
function hash_init(string $algorithm, int $options = 0, string $key = ""): HashContext {}

function hash_update(HashContext $context, string $data): bool {}

/** @param resource $handle */
function hash_update_stream(HashContext $context, $handle, int $length = -1): int {}

/** @param resource $stream_context */
/** @param resource|null $stream_context */
function hash_update_file(HashContext $context, string $filename, $stream_context = null): bool {}

function hash_final(HashContext $context, bool $raw_output = false): string {}
function hash_final(HashContext $context, bool $binary_output = false): string {}

function hash_copy(HashContext $context): HashContext {}

function hash_algos(): array {}

function hash_hmac_algos(): array {}

function hash_pbkdf2(string $algo, string $password, string $salt, int $iterations, int $length = 0, bool $raw_output = false): string {}
function hash_pbkdf2(string $algorithm, string $password, string $salt, int $iterations, int $length = 0, bool $binary_output = false): string {}

function hash_equals(string $known_string, string $user_string): bool {}

function hash_hkdf(string $algo, string $ikm, int $length = 0, string $info = "", string $salt = ""): string {}
function hash_hkdf(string $algorithm, string $key, int $length = 0, string $info = "", string $salt = ""): string {}

#ifdef PHP_MHASH_BC
function mhash_get_block_size(int $hash): int|false {}
function mhash_get_block_size(int $algorithm): int|false {}

function mhash_get_hash_name(int $hash): string|false {}
function mhash_get_hash_name(int $algorithm): string|false {}

function mhash_keygen_s2k(int $hash, string $input_password, string $salt, int $bytes): string|false {}
function mhash_keygen_s2k(int $algorithm, string $password, string $salt, int $bytes): string|false {}

function mhash_count(): int {}

function mhash(int $hash, string $data, ?string $key = null): string|false {}
function mhash(int $algorithm, string $data, ?string $key = null): string|false {}
#endif

final class HashContext
Expand Down
36 changes: 18 additions & 18 deletions ext/hash/hash_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 28ec46ceae7550c9a4103c98fd7c20364f078289 */
* Stub hash: fa9f8e9c190a8f572a0241877ddb07ccf022fd56 */

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_hash, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, algo, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, algorithm, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, raw_output, _IS_BOOL, 0, "false")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, binary_output, _IS_BOOL, 0, "false")
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_hash_file, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, algo, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, algorithm, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, raw_output, _IS_BOOL, 0, "false")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, binary_output, _IS_BOOL, 0, "false")
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_hash_hmac, 0, 3, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, algo, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, algorithm, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, raw_output, _IS_BOOL, 0, "false")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, binary_output, _IS_BOOL, 0, "false")
ZEND_END_ARG_INFO()

#define arginfo_hash_hmac_file arginfo_hash_hmac

ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_hash_init, 0, 1, HashContext, 0)
ZEND_ARG_TYPE_INFO(0, algo, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, algorithm, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_LONG, 0, "0")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, key, IS_STRING, 0, "\"\"")
ZEND_END_ARG_INFO()
Expand All @@ -47,7 +47,7 @@ ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_hash_final, 0, 1, IS_STRING, 0)
ZEND_ARG_OBJ_INFO(0, context, HashContext, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, raw_output, _IS_BOOL, 0, "false")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, binary_output, _IS_BOOL, 0, "false")
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_hash_copy, 0, 1, HashContext, 0)
Expand All @@ -60,12 +60,12 @@ ZEND_END_ARG_INFO()
#define arginfo_hash_hmac_algos arginfo_hash_algos

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_hash_pbkdf2, 0, 4, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, algo, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, algorithm, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, password, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, salt, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, iterations, IS_LONG, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 0, "0")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, raw_output, _IS_BOOL, 0, "false")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, binary_output, _IS_BOOL, 0, "false")
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_hash_equals, 0, 2, _IS_BOOL, 0)
Expand All @@ -74,29 +74,29 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_hash_equals, 0, 2, _IS_BOOL, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_hash_hkdf, 0, 2, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, algo, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, ikm, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, algorithm, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 0, "0")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, info, IS_STRING, 0, "\"\"")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, salt, IS_STRING, 0, "\"\"")
ZEND_END_ARG_INFO()

#if defined(PHP_MHASH_BC)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mhash_get_block_size, 0, 1, MAY_BE_LONG|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, hash, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, algorithm, IS_LONG, 0)
ZEND_END_ARG_INFO()
#endif

#if defined(PHP_MHASH_BC)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mhash_get_hash_name, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, hash, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, algorithm, IS_LONG, 0)
ZEND_END_ARG_INFO()
#endif

#if defined(PHP_MHASH_BC)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mhash_keygen_s2k, 0, 4, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, hash, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, input_password, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, algorithm, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, password, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, salt, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, bytes, IS_LONG, 0)
ZEND_END_ARG_INFO()
Expand All @@ -109,7 +109,7 @@ ZEND_END_ARG_INFO()

#if defined(PHP_MHASH_BC)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mhash, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, hash, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, algorithm, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, key, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
Expand Down
2 changes: 1 addition & 1 deletion ext/hash/tests/hash_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ try {
*** Testing hash() : error conditions ***

-- Testing hash() function with invalid hash algorithm --
hash(): Argument #1 ($algo) must be a valid hashing algorithm
hash(): Argument #1 ($algorithm) must be a valid hashing algorithm
2 changes: 1 addition & 1 deletion ext/hash/tests/hash_file_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ unlink( $filename );
*** Testing hash_file() : error conditions ***

-- Testing hash_file() function with an unknown algorithm --
hash_file(): Argument #1 ($algo) must be a valid hashing algorithm
hash_file(): Argument #1 ($algorithm) must be a valid hashing algorithm

-- Testing hash_file() function with a non-existent file --

Expand Down
2 changes: 1 addition & 1 deletion ext/hash/tests/hash_hkdf_edges.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ Length < digestSize: 98b16391063ece
Length % digestSize != 0: 98b16391063ecee006a3ca8ee5776b1e5f
Algo name case-sensitivity: true
Non-crypto algo name case-sensitivity:
[Error] hash_hkdf(): Argument #1 ($algo) must be a valid cryptographic hashing algorithm
[Error] hash_hkdf(): Argument #1 ($algorithm) must be a valid cryptographic hashing algorithm
20 changes: 10 additions & 10 deletions ext/hash/tests/hash_hkdf_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ trycatch_dump(
*** Testing hash_hkdf(): error conditions ***

-- Testing hash_hkdf() function with invalid hash algorithm --
[ValueError] hash_hkdf(): Argument #1 ($algo) must be a valid cryptographic hashing algorithm
[ValueError] hash_hkdf(): Argument #1 ($algorithm) must be a valid cryptographic hashing algorithm

-- Testing hash_hkdf() function with non-cryptographic hash algorithm --
[ValueError] hash_hkdf(): Argument #1 ($algo) must be a valid cryptographic hashing algorithm
[ValueError] hash_hkdf(): Argument #1 ($algo) must be a valid cryptographic hashing algorithm
[ValueError] hash_hkdf(): Argument #1 ($algo) must be a valid cryptographic hashing algorithm
[ValueError] hash_hkdf(): Argument #1 ($algo) must be a valid cryptographic hashing algorithm
[ValueError] hash_hkdf(): Argument #1 ($algo) must be a valid cryptographic hashing algorithm
[ValueError] hash_hkdf(): Argument #1 ($algo) must be a valid cryptographic hashing algorithm
[ValueError] hash_hkdf(): Argument #1 ($algo) must be a valid cryptographic hashing algorithm
[ValueError] hash_hkdf(): Argument #1 ($algo) must be a valid cryptographic hashing algorithm
[ValueError] hash_hkdf(): Argument #1 ($algorithm) must be a valid cryptographic hashing algorithm
[ValueError] hash_hkdf(): Argument #1 ($algorithm) must be a valid cryptographic hashing algorithm
[ValueError] hash_hkdf(): Argument #1 ($algorithm) must be a valid cryptographic hashing algorithm
[ValueError] hash_hkdf(): Argument #1 ($algorithm) must be a valid cryptographic hashing algorithm
[ValueError] hash_hkdf(): Argument #1 ($algorithm) must be a valid cryptographic hashing algorithm
[ValueError] hash_hkdf(): Argument #1 ($algorithm) must be a valid cryptographic hashing algorithm
[ValueError] hash_hkdf(): Argument #1 ($algorithm) must be a valid cryptographic hashing algorithm
[ValueError] hash_hkdf(): Argument #1 ($algorithm) must be a valid cryptographic hashing algorithm

-- Testing hash_hkdf() function with invalid parameters --
[ValueError] hash_hkdf(): Argument #2 ($ikm) cannot be empty
[ValueError] hash_hkdf(): Argument #2 ($key) cannot be empty
[ValueError] hash_hkdf(): Argument #3 ($length) must be greater than or equal to 0
[ValueError] hash_hkdf(): Argument #3 ($length) must be less than or equal to 5100
4 changes: 2 additions & 2 deletions ext/hash/tests/hash_hmac_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ catch (\Error $e) {
*** Testing hash_hmac() : error conditions ***

-- Testing hash_hmac() function with invalid hash algorithm --
hash_hmac(): Argument #1 ($algo) must be a valid cryptographic hashing algorithm
hash_hmac(): Argument #1 ($algorithm) must be a valid cryptographic hashing algorithm

-- Testing hash_hmac() function with non-cryptographic hash algorithm --
hash_hmac(): Argument #1 ($algo) must be a valid cryptographic hashing algorithm
hash_hmac(): Argument #1 ($algorithm) must be a valid cryptographic hashing algorithm
4 changes: 2 additions & 2 deletions ext/hash/tests/hash_hmac_file_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ catch (ValueError $e) {
*** Testing hash() : error conditions ***

-- Testing hash_hmac_file() function with invalid hash algorithm --
hash_hmac_file(): Argument #1 ($algo) must be a valid cryptographic hashing algorithm
hash_hmac_file(): Argument #1 ($algorithm) must be a valid cryptographic hashing algorithm

-- Testing hash_hmac_file() function with non-cryptographic hash algorithm --
hash_hmac_file(): Argument #1 ($algo) must be a valid cryptographic hashing algorithm
hash_hmac_file(): Argument #1 ($algorithm) must be a valid cryptographic hashing algorithm

-- Testing hash_hmac_file() function with bad path --
hash_hmac_file(): Argument #2 ($data) must not contain any null bytes
4 changes: 2 additions & 2 deletions ext/hash/tests/hash_init_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ catch (\Error $e) {
*** Testing hash_init(): error conditions ***

-- Testing hash_init() function with unknown algorithms --
hash_init(): Argument #1 ($algo) must be a valid hashing algorithm
hash_init(): Argument #1 ($algorithm) must be a valid hashing algorithm

-- Testing hash_init() function with HASH_HMAC and non-cryptographic algorithms --
hash_init(): Argument #1 ($algo) must be a cryptographic hashing algorithm if HMAC is requested
hash_init(): Argument #1 ($algorithm) must be a cryptographic hashing algorithm if HMAC is requested

-- Testing hash_init() function with HASH_HMAC and no key --
hash_init(): Argument #3 ($key) cannot be empty when HMAC is requested
Expand Down
4 changes: 2 additions & 2 deletions ext/hash/tests/hash_pbkdf2_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ catch (\Error $e) {
*** Testing hash_pbkdf2() : error conditions ***

-- Testing hash_pbkdf2() function with invalid hash algorithm --
hash_pbkdf2(): Argument #1 ($algo) must be a valid cryptographic hashing algorithm
hash_pbkdf2(): Argument #1 ($algorithm) must be a valid cryptographic hashing algorithm

-- Testing hash_pbkdf2() function with non-cryptographic hash algorithm --
hash_pbkdf2(): Argument #1 ($algo) must be a valid cryptographic hashing algorithm
hash_pbkdf2(): Argument #1 ($algorithm) must be a valid cryptographic hashing algorithm

-- Testing hash_pbkdf2() function with invalid iterations --
hash_pbkdf2(): Argument #4 ($iterations) must be greater than 0
Expand Down