Skip to content

Commit 905c79c

Browse files
committed
Fix some snmp stubs
As well as some basic mistakes in tests.
1 parent 6e91a2e commit 905c79c

File tree

4 files changed

+37
-20
lines changed

4 files changed

+37
-20
lines changed

ext/snmp/snmp.stub.php

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

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

5-
function snmpget(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {}
5+
function snmpget(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): stdClass|array|string|bool {}
66

7-
function snmpgetnext(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {}
7+
function snmpgetnext(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): stdClass|array|string|bool {}
88

99
function snmpwalk(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {}
1010

@@ -26,19 +26,19 @@ function snmp_set_oid_output_format(int $oid_format): bool {}
2626
/** @alias snmp_set_oid_output_format */
2727
function snmp_set_oid_numeric_print(int $oid_format): bool {}
2828

29-
function snmp2_get(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {}
29+
function snmp2_get(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): stdClass|array|string|bool {}
3030

31-
function snmp2_getnext(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {}
31+
function snmp2_getnext(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): stdClass|array|string|bool {}
3232

3333
function snmp2_walk(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {}
3434

3535
function snmp2_real_walk(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {}
3636

3737
function snmp2_set(string $host, string $community, array|string $object_id, array|string $type, array|string $value, int $timeout = -1, int $retries = -1): array|bool {}
3838

39-
function snmp3_get(string $host, string $sec_name, string $sec_level, string $auth_protocol, string $auth_passphrase, string $priv_protocol, string $priv_passphrase, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {}
39+
function snmp3_get(string $host, string $sec_name, string $sec_level, string $auth_protocol, string $auth_passphrase, string $priv_protocol, string $priv_passphrase, array|string $object_id, int $timeout = -1, int $retries = -1): stdClass|array|string|bool {}
4040

41-
function snmp3_getnext(string $host, string $sec_name, string $sec_level, string $auth_protocol, string $auth_passphrase, string $priv_protocol, string $priv_passphrase, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {}
41+
function snmp3_getnext(string $host, string $sec_name, string $sec_level, string $auth_protocol, string $auth_passphrase, string $priv_protocol, string $priv_passphrase, array|string $object_id, int $timeout = -1, int $retries = -1): stdClass|array|string|bool {}
4242

4343
function snmp3_walk(string $host, string $sec_name, string $sec_level, string $auth_protocol, string $auth_passphrase, string $priv_protocol, string $priv_passphrase, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {}
4444

ext/snmp/snmp_arginfo.h

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: c9906ff8ef879e567cf8aed9a34dcff850f3e949 */
2+
* Stub hash: 759c8a5e721d1c6c9cb63e59ae14f85831396a4d */
33

4-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmpget, 0, 3, MAY_BE_ARRAY|MAY_BE_BOOL)
4+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_snmpget, 0, 3, stdClass, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_BOOL)
55
ZEND_ARG_TYPE_INFO(0, host, IS_STRING, 0)
66
ZEND_ARG_TYPE_INFO(0, community, IS_STRING, 0)
77
ZEND_ARG_TYPE_MASK(0, object_id, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
@@ -11,11 +11,17 @@ ZEND_END_ARG_INFO()
1111

1212
#define arginfo_snmpgetnext arginfo_snmpget
1313

14-
#define arginfo_snmpwalk arginfo_snmpget
14+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmpwalk, 0, 3, MAY_BE_ARRAY|MAY_BE_BOOL)
15+
ZEND_ARG_TYPE_INFO(0, host, IS_STRING, 0)
16+
ZEND_ARG_TYPE_INFO(0, community, IS_STRING, 0)
17+
ZEND_ARG_TYPE_MASK(0, object_id, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
18+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timeout, IS_LONG, 0, "-1")
19+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, retries, IS_LONG, 0, "-1")
20+
ZEND_END_ARG_INFO()
1521

16-
#define arginfo_snmprealwalk arginfo_snmpget
22+
#define arginfo_snmprealwalk arginfo_snmpwalk
1723

18-
#define arginfo_snmpwalkoid arginfo_snmpget
24+
#define arginfo_snmpwalkoid arginfo_snmpwalk
1925

2026
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmpset, 0, 5, MAY_BE_ARRAY|MAY_BE_BOOL)
2127
ZEND_ARG_TYPE_INFO(0, host, IS_STRING, 0)
@@ -48,13 +54,13 @@ ZEND_END_ARG_INFO()
4854

4955
#define arginfo_snmp2_getnext arginfo_snmpget
5056

51-
#define arginfo_snmp2_walk arginfo_snmpget
57+
#define arginfo_snmp2_walk arginfo_snmpwalk
5258

53-
#define arginfo_snmp2_real_walk arginfo_snmpget
59+
#define arginfo_snmp2_real_walk arginfo_snmpwalk
5460

5561
#define arginfo_snmp2_set arginfo_snmpset
5662

57-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmp3_get, 0, 8, MAY_BE_ARRAY|MAY_BE_BOOL)
63+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_snmp3_get, 0, 8, stdClass, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_BOOL)
5864
ZEND_ARG_TYPE_INFO(0, host, IS_STRING, 0)
5965
ZEND_ARG_TYPE_INFO(0, sec_name, IS_STRING, 0)
6066
ZEND_ARG_TYPE_INFO(0, sec_level, IS_STRING, 0)
@@ -69,9 +75,20 @@ ZEND_END_ARG_INFO()
6975

7076
#define arginfo_snmp3_getnext arginfo_snmp3_get
7177

72-
#define arginfo_snmp3_walk arginfo_snmp3_get
78+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmp3_walk, 0, 8, MAY_BE_ARRAY|MAY_BE_BOOL)
79+
ZEND_ARG_TYPE_INFO(0, host, IS_STRING, 0)
80+
ZEND_ARG_TYPE_INFO(0, sec_name, IS_STRING, 0)
81+
ZEND_ARG_TYPE_INFO(0, sec_level, IS_STRING, 0)
82+
ZEND_ARG_TYPE_INFO(0, auth_protocol, IS_STRING, 0)
83+
ZEND_ARG_TYPE_INFO(0, auth_passphrase, IS_STRING, 0)
84+
ZEND_ARG_TYPE_INFO(0, priv_protocol, IS_STRING, 0)
85+
ZEND_ARG_TYPE_INFO(0, priv_passphrase, IS_STRING, 0)
86+
ZEND_ARG_TYPE_MASK(0, object_id, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
87+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timeout, IS_LONG, 0, "-1")
88+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, retries, IS_LONG, 0, "-1")
89+
ZEND_END_ARG_INFO()
7390

74-
#define arginfo_snmp3_real_walk arginfo_snmp3_get
91+
#define arginfo_snmp3_real_walk arginfo_snmp3_walk
7592

7693
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmp3_set, 0, 10, MAY_BE_ARRAY|MAY_BE_BOOL)
7794
ZEND_ARG_TYPE_INFO(0, host, IS_STRING, 0)

ext/snmp/tests/snmp-object-error.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ try {
3131
}
3232
try {
3333
var_dump(new SNMP(7, $hostname, $community));
34-
} catch (Exception $e) {
34+
} catch (ValueError $e) {
3535
print $e->getMessage() . "\n";
3636
}
3737

@@ -70,8 +70,8 @@ var_dump($session->max_oids);
7070
?>
7171
--EXPECTF--
7272
SNMP::__construct() expects at least 3 parameters, 2 given
73-
SNMP::__construct(): Argument #4 must be of type int, string given
74-
SNMP::__construct(): Argument #5 must be of type int, string given
73+
SNMP::__construct(): Argument #4 ($timeout) must be of type int, string given
74+
SNMP::__construct(): Argument #5 ($retries) must be of type int, string given
7575
SNMP::__construct(): Argument #1 ($version) must be a valid SNMP protocol version
7676
Exception handling
7777

ext/snmp/tests/snmp-object-properties.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ string(11) "param_value"
184184
bool(true)
185185
Error handling
186186

187-
Notice: Undefined property: SNMP::$there is no such parameter in %s on line %d
187+
Warning: Undefined property: SNMP::$there is no such parameter in %s on line %d
188188
NULL
189189
bool(false)
190190

0 commit comments

Comments
 (0)