Skip to content

Commit 9d9bcc2

Browse files
committed
Improve parameter names in ext/hash and ext/openssl
Closes GH-6156
1 parent 25b9ba8 commit 9d9bcc2

File tree

5 files changed

+57
-57
lines changed

5 files changed

+57
-57
lines changed

ext/hash/hash.stub.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,48 @@
22

33
/** @generate-function-entries */
44

5-
function hash(string $algo, string $data, bool $raw_output = false): string|false {}
5+
function hash(string $algo, string $data, bool $binary = false): string|false {}
66

7-
function hash_file(string $algo, string $filename, bool $raw_output = false): string|false {}
7+
function hash_file(string $algo, string $filename, bool $binary = false): string|false {}
88

9-
function hash_hmac(string $algo, string $data, string $key, bool $raw_output = false): string|false {}
9+
function hash_hmac(string $algo, string $data, string $key, bool $binary = false): string|false {}
1010

11-
function hash_hmac_file(string $algo, string $data, string $key, bool $raw_output = false): string|false {}
11+
function hash_hmac_file(string $algo, string $data, string $key, bool $binary = false): string|false {}
1212

13-
function hash_init(string $algo, int $options = 0, string $key = ""): HashContext {}
13+
function hash_init(string $algo, int $flags = 0, string $key = ""): HashContext {}
1414

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

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

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

23-
function hash_final(HashContext $context, bool $raw_output = false): string {}
23+
function hash_final(HashContext $context, bool $binary = false): string {}
2424

2525
function hash_copy(HashContext $context): HashContext {}
2626

2727
function hash_algos(): array {}
2828

2929
function hash_hmac_algos(): array {}
3030

31-
function hash_pbkdf2(string $algo, string $password, string $salt, int $iterations, int $length = 0, bool $raw_output = false): string {}
31+
function hash_pbkdf2(string $algo, string $password, string $salt, int $iterations, int $length = 0, bool $binary = false): string {}
3232

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

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

3737
#ifdef PHP_MHASH_BC
38-
function mhash_get_block_size(int $hash): int|false {}
38+
function mhash_get_block_size(int $algo): int|false {}
3939

40-
function mhash_get_hash_name(int $hash): string|false {}
40+
function mhash_get_hash_name(int $algo): string|false {}
4141

42-
function mhash_keygen_s2k(int $hash, string $input_password, string $salt, int $bytes): string|false {}
42+
function mhash_keygen_s2k(int $algo, string $password, string $salt, int $length): string|false {}
4343

4444
function mhash_count(): int {}
4545

46-
function mhash(int $hash, string $data, ?string $key = null): string|false {}
46+
function mhash(int $algo, string $data, ?string $key = null): string|false {}
4747
#endif
4848

4949
final class HashContext

ext/hash/hash_arginfo.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 28ec46ceae7550c9a4103c98fd7c20364f078289 */
2+
* Stub hash: 5298231334ab85edd67ae46c33b7e6cffb2ecc53 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_hash, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
55
ZEND_ARG_TYPE_INFO(0, algo, IS_STRING, 0)
66
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
7-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, raw_output, _IS_BOOL, 0, "false")
7+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, binary, _IS_BOOL, 0, "false")
88
ZEND_END_ARG_INFO()
99

1010
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_hash_file, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
1111
ZEND_ARG_TYPE_INFO(0, algo, IS_STRING, 0)
1212
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
13-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, raw_output, _IS_BOOL, 0, "false")
13+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, binary, _IS_BOOL, 0, "false")
1414
ZEND_END_ARG_INFO()
1515

1616
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_hash_hmac, 0, 3, MAY_BE_STRING|MAY_BE_FALSE)
1717
ZEND_ARG_TYPE_INFO(0, algo, IS_STRING, 0)
1818
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
1919
ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0)
20-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, raw_output, _IS_BOOL, 0, "false")
20+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, binary, _IS_BOOL, 0, "false")
2121
ZEND_END_ARG_INFO()
2222

2323
#define arginfo_hash_hmac_file arginfo_hash_hmac
2424

2525
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_hash_init, 0, 1, HashContext, 0)
2626
ZEND_ARG_TYPE_INFO(0, algo, IS_STRING, 0)
27-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_LONG, 0, "0")
27+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "0")
2828
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, key, IS_STRING, 0, "\"\"")
2929
ZEND_END_ARG_INFO()
3030

@@ -35,7 +35,7 @@ ZEND_END_ARG_INFO()
3535

3636
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_hash_update_stream, 0, 2, IS_LONG, 0)
3737
ZEND_ARG_OBJ_INFO(0, context, HashContext, 0)
38-
ZEND_ARG_INFO(0, handle)
38+
ZEND_ARG_INFO(0, stream)
3939
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 0, "-1")
4040
ZEND_END_ARG_INFO()
4141

@@ -47,7 +47,7 @@ ZEND_END_ARG_INFO()
4747

4848
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_hash_final, 0, 1, IS_STRING, 0)
4949
ZEND_ARG_OBJ_INFO(0, context, HashContext, 0)
50-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, raw_output, _IS_BOOL, 0, "false")
50+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, binary, _IS_BOOL, 0, "false")
5151
ZEND_END_ARG_INFO()
5252

5353
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_hash_copy, 0, 1, HashContext, 0)
@@ -65,7 +65,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_hash_pbkdf2, 0, 4, IS_STRING, 0)
6565
ZEND_ARG_TYPE_INFO(0, salt, IS_STRING, 0)
6666
ZEND_ARG_TYPE_INFO(0, iterations, IS_LONG, 0)
6767
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 0, "0")
68-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, raw_output, _IS_BOOL, 0, "false")
68+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, binary, _IS_BOOL, 0, "false")
6969
ZEND_END_ARG_INFO()
7070

7171
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_hash_equals, 0, 2, _IS_BOOL, 0)
@@ -75,30 +75,30 @@ ZEND_END_ARG_INFO()
7575

7676
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_hash_hkdf, 0, 2, IS_STRING, 0)
7777
ZEND_ARG_TYPE_INFO(0, algo, IS_STRING, 0)
78-
ZEND_ARG_TYPE_INFO(0, ikm, IS_STRING, 0)
78+
ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0)
7979
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 0, "0")
8080
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, info, IS_STRING, 0, "\"\"")
8181
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, salt, IS_STRING, 0, "\"\"")
8282
ZEND_END_ARG_INFO()
8383

8484
#if defined(PHP_MHASH_BC)
8585
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mhash_get_block_size, 0, 1, MAY_BE_LONG|MAY_BE_FALSE)
86-
ZEND_ARG_TYPE_INFO(0, hash, IS_LONG, 0)
86+
ZEND_ARG_TYPE_INFO(0, algo, IS_LONG, 0)
8787
ZEND_END_ARG_INFO()
8888
#endif
8989

9090
#if defined(PHP_MHASH_BC)
9191
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mhash_get_hash_name, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
92-
ZEND_ARG_TYPE_INFO(0, hash, IS_LONG, 0)
92+
ZEND_ARG_TYPE_INFO(0, algo, IS_LONG, 0)
9393
ZEND_END_ARG_INFO()
9494
#endif
9595

9696
#if defined(PHP_MHASH_BC)
9797
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mhash_keygen_s2k, 0, 4, MAY_BE_STRING|MAY_BE_FALSE)
98-
ZEND_ARG_TYPE_INFO(0, hash, IS_LONG, 0)
99-
ZEND_ARG_TYPE_INFO(0, input_password, IS_STRING, 0)
98+
ZEND_ARG_TYPE_INFO(0, algo, IS_LONG, 0)
99+
ZEND_ARG_TYPE_INFO(0, password, IS_STRING, 0)
100100
ZEND_ARG_TYPE_INFO(0, salt, IS_STRING, 0)
101-
ZEND_ARG_TYPE_INFO(0, bytes, IS_LONG, 0)
101+
ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0)
102102
ZEND_END_ARG_INFO()
103103
#endif
104104

@@ -109,7 +109,7 @@ ZEND_END_ARG_INFO()
109109

110110
#if defined(PHP_MHASH_BC)
111111
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mhash, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
112-
ZEND_ARG_TYPE_INFO(0, hash, IS_LONG, 0)
112+
ZEND_ARG_TYPE_INFO(0, algo, IS_LONG, 0)
113113
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
114114
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, key, IS_STRING, 1, "null")
115115
ZEND_END_ARG_INFO()

ext/hash/tests/hash_hkdf_error.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ trycatch_dump(
6161
[ValueError] hash_hkdf(): Argument #1 ($algo) must be a valid cryptographic hashing algorithm
6262

6363
-- Testing hash_hkdf() function with invalid parameters --
64-
[ValueError] hash_hkdf(): Argument #2 ($ikm) cannot be empty
64+
[ValueError] hash_hkdf(): Argument #2 ($key) cannot be empty
6565
[ValueError] hash_hkdf(): Argument #3 ($length) must be greater than or equal to 0
6666
[ValueError] hash_hkdf(): Argument #3 ($length) must be less than or equal to 5100

ext/openssl/openssl.stub.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function openssl_x509_export_to_file(OpenSSLCertificate|string $certificate, str
1919
/** @param string $output */
2020
function openssl_x509_export(OpenSSLCertificate|string $certificate, &$output, bool $no_text = true): bool {}
2121

22-
function openssl_x509_fingerprint(OpenSSLCertificate|string $certificate, string $digest_algorithm = "sha1", bool $raw_output = false): string|false {}
22+
function openssl_x509_fingerprint(OpenSSLCertificate|string $certificate, string $digest_algo = "sha1", bool $binary = false): string|false {}
2323

2424
/** @param OpenSSLAsymmetricKey|OpenSSLCertificate|array|string $private_key */
2525
function openssl_x509_check_private_key(OpenSSLCertificate|string $certificate, $private_key): bool {}
@@ -103,12 +103,12 @@ function openssl_get_privatekey($private_key, ?string $passphrase = null): OpenS
103103

104104
function openssl_pkey_get_details(OpenSSLAsymmetricKey $key): array|false {}
105105

106-
function openssl_pbkdf2(string $passphrase, string $salt, int $key_length, int $iterations, string $digest_algorithm = "sha1"): string|false {}
106+
function openssl_pbkdf2(string $password, string $salt, int $key_length, int $iterations, string $digest_algo = "sha1"): string|false {}
107107

108108
function openssl_pkcs7_verify(string $input_filename, int $flags, ?string $signers_certificates_filename = null, array $ca_info = [], ?string $untrusted_certificates_filename = null, ?string $content = null, ?string $output_filename = null): bool|int {}
109109

110110
/** @param OpenSSLCertificate|array|string $certificate */
111-
function openssl_pkcs7_encrypt(string $input_filename, string $output_filename, $certificate, ?array $headers, int $flags = 0, int $cipher_algorithm = OPENSSL_CIPHER_RC2_40): bool {}
111+
function openssl_pkcs7_encrypt(string $input_filename, string $output_filename, $certificate, ?array $headers, int $flags = 0, int $cipher_algo = OPENSSL_CIPHER_RC2_40): bool {}
112112

113113
/** @param OpenSSLAsymmetricKey|OpenSSLCertificate|array|string $private_key */
114114
function openssl_pkcs7_sign(string $input_filename, string $output_filename, OpenSSLCertificate|string $certificate, $private_key, ?array $headers, int $flags = PKCS7_DETACHED, ?string $untrusted_certificates_filename = null): bool {}
@@ -125,7 +125,7 @@ function openssl_pkcs7_read(string $input_filename, &$certificates): bool {}
125125
function openssl_cms_verify(string $input_filename, int $flags = 0, ?string $certificates = null, array $ca_info = [], ?string $untrusted_certificates_filename = null, ?string $content = null, ?string $pk7 = null, ?string $sigfile = null, int $encoding = OPENSSL_ENCODING_SMIME): bool {}
126126

127127
/** @param OpenSSLCertificate|array|string $certificate */
128-
function openssl_cms_encrypt(string $input_filename, string $output_filename, $certificate, ?array $headers, int $flags = 0, int $encoding = OPENSSL_ENCODING_SMIME, int $cipher_algorithm = OPENSSL_CIPHER_RC2_40): bool {}
128+
function openssl_cms_encrypt(string $input_filename, string $output_filename, $certificate, ?array $headers, int $flags = 0, int $encoding = OPENSSL_ENCODING_SMIME, int $cipher_algo = OPENSSL_CIPHER_RC2_40): bool {}
129129

130130
/** @param OpenSSLAsymmetricKey|OpenSSLCertificate|array|string $private_key */
131131
function openssl_cms_sign(string $input_filename, string $output_filename, OpenSSLCertificate|string $certificate, $private_key, ?array $headers, int $flags = 0, int $encoding = OPENSSL_ENCODING_SMIME, ?string $untrusted_certificates_filename = null): bool {}
@@ -179,13 +179,13 @@ function openssl_verify(string $data, string $signature, $public_key, string|int
179179
* @param array $encrypted_keys
180180
* @param string $iv
181181
*/
182-
function openssl_seal(string $data, &$sealed_data, &$encrypted_keys, array $public_key, string $cipher_algorithm, &$iv = null): int|false {}
182+
function openssl_seal(string $data, &$sealed_data, &$encrypted_keys, array $public_key, string $cipher_algo, &$iv = null): int|false {}
183183

184184
/**
185185
* @param string $output
186186
* @param OpenSSLAsymmetricKey|OpenSSLCertificate|array|string $private_key
187187
*/
188-
function openssl_open(string $data, &$output, string $encrypted_key, $private_key, string $cipher_algorithm, ?string $iv = null): bool {}
188+
function openssl_open(string $data, &$output, string $encrypted_key, $private_key, string $cipher_algo, ?string $iv = null): bool {}
189189

190190
function openssl_get_md_methods(bool $aliases = false): array {}
191191

@@ -195,14 +195,14 @@ function openssl_get_cipher_methods(bool $aliases = false): array {}
195195
function openssl_get_curve_names(): array|false {}
196196
#endif
197197

198-
function openssl_digest(string $data, string $digest_algorithm, bool $raw_output = false): string|false {}
198+
function openssl_digest(string $data, string $digest_algo, bool $binary = false): string|false {}
199199

200200
/** @param string $tag */
201-
function openssl_encrypt(string $data, string $cipher_algorithm, string $passphrase, int $options = 0, string $iv = "", &$tag = null, string $aad = "", int $tag_length = 16): string|false {}
201+
function openssl_encrypt(string $data, string $cipher_algo, string $passphrase, int $options = 0, string $iv = "", &$tag = null, string $aad = "", int $tag_length = 16): string|false {}
202202

203-
function openssl_decrypt(string $data, string $cipher_algorithm, string $passphrase, int $options = 0, string $iv = "", string $tag = "", string $aad = ""): string|false {}
203+
function openssl_decrypt(string $data, string $cipher_algo, string $passphrase, int $options = 0, string $iv = "", string $tag = "", string $aad = ""): string|false {}
204204

205-
function openssl_cipher_iv_length(string $cipher_algorithm): int|false {}
205+
function openssl_cipher_iv_length(string $cipher_algo): int|false {}
206206

207207
function openssl_dh_compute_key(string $public_key, OpenSSLAsymmetricKey $private_key): string|false {}
208208

@@ -215,7 +215,7 @@ function openssl_pkey_derive($public_key, $private_key, int $key_length = 0): st
215215
/** @param bool $strong_result */
216216
function openssl_random_pseudo_bytes(int $length, &$strong_result = null): string {}
217217

218-
function openssl_spki_new(OpenSSLAsymmetricKey $private_key, string $challenge, int $digest_algorithm = OPENSSL_ALGO_MD5): string|false {}
218+
function openssl_spki_new(OpenSSLAsymmetricKey $private_key, string $challenge, int $digest_algo = OPENSSL_ALGO_MD5): string|false {}
219219

220220
function openssl_spki_verify(string $spki): bool {}
221221

0 commit comments

Comments
 (0)