Skip to content

Commit fc403a0

Browse files
Thomas Kerinafk11
Thomas Kerin
authored andcommittedJul 11, 2018
type hints for secp256k1_ec_pubkey_combine
1 parent 84448f3 commit fc403a0

4 files changed

+14
-16
lines changed
 

‎secp256k1/secp256k1.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,11 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_secp256k1_context_randomize, IS_LON
228228
ZEND_ARG_TYPE_INFO(0, seed32, IS_STRING, 1)
229229
ZEND_END_ARG_INFO();
230230

231-
ZEND_BEGIN_ARG_INFO(arginfo_secp256k1_ec_pubkey_combine, 0)
231+
#if (PHP_VERSION_ID >= 70000 && PHP_VERSION_ID <= 70200)
232+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_secp256k1_ec_pubkey_combine, IS_LONG, NULL, 0)
233+
#else
234+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_secp256k1_ec_pubkey_combine, IS_LONG, 0)
235+
#endif
232236
ZEND_ARG_TYPE_INFO(0, context, IS_RESOURCE, 0)
233237
ZEND_ARG_TYPE_INFO(1, combinedEcPublicKey, IS_RESOURCE, 1)
234238
ZEND_ARG_TYPE_INFO(0, publicKeys, IS_ARRAY, 0)
@@ -1174,11 +1178,11 @@ PHP_FUNCTION(secp256k1_ec_pubkey_combine)
11741178
size_t array_count;
11751179

11761180
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz/a", &zCtx, &zPubkeyCombined, &arr) == FAILURE) {
1177-
RETURN_FALSE;
1181+
RETURN_LONG(result);
11781182
}
11791183

11801184
if ((ctx = php_get_secp256k1_context(zCtx)) == NULL) {
1181-
RETURN_FALSE;
1185+
RETURN_LONG(result);
11821186
}
11831187

11841188
arr_hash = Z_ARRVAL_P(arr);
@@ -1187,7 +1191,7 @@ PHP_FUNCTION(secp256k1_ec_pubkey_combine)
11871191

11881192
ZEND_HASH_FOREACH_KEY_VAL(arr_hash, i, arrayKeyStr, arrayPubKey) {
11891193
if ((ptr = php_get_secp256k1_pubkey(arrayPubKey)) == NULL) {
1190-
RETURN_FALSE;
1194+
RETURN_LONG(result);
11911195
}
11921196

11931197
pubkeys[i++] = ptr;

‎secp256k1/tests/secp256k1_ec_pubkey_combine_error1.phpt

+2-4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@ if (!extension_loaded("secp256k1")) print "skip extension not loaded";
1010
set_error_handler(function($code, $str) { echo $str . PHP_EOL; });
1111

1212
$result = secp256k1_ec_pubkey_combine();
13-
echo gettype($result) . PHP_EOL;
14-
echo ($result ? "true" : "false") . PHP_EOL;
13+
echo $result . PHP_EOL;
1514

1615
?>
1716
--EXPECT--
1817
secp256k1_ec_pubkey_combine() expects exactly 3 parameters, 0 given
19-
boolean
20-
false
18+
0

‎secp256k1/tests/secp256k1_ec_pubkey_combine_error2.phpt

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ set_error_handler(function($code, $str) { echo $str . PHP_EOL; });
1212
$combinedPubKey = null;
1313
$badCtx = tmpfile();
1414
$result = secp256k1_ec_pubkey_combine($badCtx, $combinedPubKey, []);
15-
echo gettype($result) . PHP_EOL;
16-
echo ($result ? "true" : "false") . PHP_EOL;
15+
echo $result . PHP_EOL;
1716

1817
?>
1918
--EXPECT--
2019
secp256k1_ec_pubkey_combine(): supplied resource is not a valid secp256k1_context resource
21-
boolean
22-
false
20+
0

‎secp256k1/tests/secp256k1_ec_pubkey_combine_error3.phpt

+2-4
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@ $pubKeys = [tmpfile()];
1515

1616
$combinedPubKey = null;
1717
$result = secp256k1_ec_pubkey_combine($ctx, $combinedPubKey, $pubKeys);
18-
echo gettype($result) . PHP_EOL;
19-
echo ($result ? "true" : "false") . PHP_EOL;
18+
echo $result . PHP_EOL;
2019

2120
?>
2221
--EXPECT--
2322
secp256k1_ec_pubkey_combine(): supplied resource is not a valid secp256k1_pubkey resource
24-
boolean
25-
false
23+
0

0 commit comments

Comments
 (0)
Please sign in to comment.