Skip to content

Commit 7d323bf

Browse files
committed
Declare tentative return types for ext/snmp
1 parent 010d6a4 commit 7d323bf

File tree

2 files changed

+50
-40
lines changed

2 files changed

+50
-40
lines changed

ext/snmp/snmp.stub.php

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ function snmpget(string $hostname, string $community, array|string $object_id, i
66

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

9-
function snmpwalk(string $hostname, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {}
9+
function snmpwalk(string $hostname, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|false {}
1010

11-
function snmprealwalk(string $hostname, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {}
11+
function snmprealwalk(string $hostname, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|false {}
1212

1313
/** @alias snmprealwalk */
14-
function snmpwalkoid(string $hostname, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {}
14+
function snmpwalkoid(string $hostname, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|false {}
1515

16-
function snmpset(string $hostname, string $community, array|string $object_id, array|string $type, array|string $value, int $timeout = -1, int $retries = -1): array|bool {}
16+
function snmpset(string $hostname, string $community, array|string $object_id, array|string $type, array|string $value, int $timeout = -1, int $retries = -1): array|false {}
1717

1818
function snmp_get_quick_print(): bool {}
1919

@@ -30,11 +30,11 @@ function snmp2_get(string $hostname, string $community, array|string $object_id,
3030

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

33-
function snmp2_walk(string $hostname, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {}
33+
function snmp2_walk(string $hostname, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|false {}
3434

35-
function snmp2_real_walk(string $hostname, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {}
35+
function snmp2_real_walk(string $hostname, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|false {}
3636

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

3939
function snmp3_get(
4040
string $hostname, string $security_name, string $security_level,
@@ -52,20 +52,20 @@ function snmp3_walk(
5252
string $hostname, string $security_name, string $security_level,
5353
string $auth_protocol, string $auth_passphrase,
5454
string $privacy_protocol, string $privacy_passphrase,
55-
array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {}
55+
array|string $object_id, int $timeout = -1, int $retries = -1): array|false {}
5656

5757
function snmp3_real_walk(
5858
string $hostname, string $security_name, string $security_level,
5959
string $auth_protocol, string $auth_passphrase,
6060
string $privacy_protocol, string $privacy_passphrase,
61-
array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {}
61+
array|string $object_id, int $timeout = -1, int $retries = -1): array|false {}
6262

6363
function snmp3_set(
6464
string $hostname, string $security_name, string $security_level,
6565
string $auth_protocol, string $auth_passphrase,
6666
string $privacy_protocol, string $privacy_passphrase,
6767
array|string $object_id, array|string $type, array|string $value,
68-
int $timeout = -1, int $retries = -1): array|bool {}
68+
int $timeout = -1, int $retries = -1): bool {}
6969

7070
function snmp_set_valueretrieval(int $method): bool {}
7171

@@ -87,32 +87,32 @@ class SNMP
8787

8888
public function __construct(int $version, string $hostname, string $community, int $timeout = -1, int $retries = -1) {}
8989

90-
/** @return bool */
91-
public function close() {}
90+
/** @tentative-return-type */
91+
public function close(): bool {}
9292

93-
/** @return bool */
93+
/** @tentative-return-type */
9494
public function setSecurity(
9595
string $securityLevel, string $authProtocol = "", string $authPassphrase = "",
9696
string $privacyProtocol = "", string $privacyPassphrase = "",
97-
string $contextName = "", string $contextEngineId = "") {}
97+
string $contextName = "", string $contextEngineId = ""): bool {}
9898

99-
/** @return array|bool */
100-
public function get(array|string $objectId, bool $preserveKeys = false) {}
99+
/** @tentative-return-type */
100+
public function get(array|string $objectId, bool $preserveKeys = false): array|string|false {}
101101

102-
/** @return array|bool */
103-
public function getnext(array|string $objectId) {}
102+
/** @tentative-return-type */
103+
public function getnext(array|string $objectId): array|false {}
104104

105-
/** @return array|bool */
106-
public function walk(array|string $objectId, bool $suffixAsKey = false, int $maxRepetitions = -1, int $nonRepeaters = -1) {}
105+
/** @tentative-return-type */
106+
public function walk(array|string $objectId, bool $suffixAsKey = false, int $maxRepetitions = -1, int $nonRepeaters = -1): array|false {}
107107

108-
/** @return array|bool */
109-
public function set(array|string $objectId, array|string $type, array|string $value) {}
108+
/** @tentative-return-type */
109+
public function set(array|string $objectId, array|string $type, array|string $value): bool {}
110110

111-
/** @return int */
112-
public function getErrno() {}
111+
/** @tentative-return-type */
112+
public function getErrno(): int {}
113113

114-
/** @return string */
115-
public function getError() {}
114+
/** @tentative-return-type */
115+
public function getError(): string {}
116116
}
117117

118118
class SNMPException extends RuntimeException

ext/snmp/snmp_arginfo.h

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 5258c5796aca15e369dd72c0a8ed4dc1df31ce9d */
2+
* Stub hash: 13ffd1383aaf7ea6a8e0373fc3eef96824631e43 */
33

44
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, hostname, IS_STRING, 0)
@@ -11,7 +11,7 @@ ZEND_END_ARG_INFO()
1111

1212
#define arginfo_snmpgetnext arginfo_snmpget
1313

14-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmpwalk, 0, 3, MAY_BE_ARRAY|MAY_BE_BOOL)
14+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmpwalk, 0, 3, MAY_BE_ARRAY|MAY_BE_FALSE)
1515
ZEND_ARG_TYPE_INFO(0, hostname, IS_STRING, 0)
1616
ZEND_ARG_TYPE_INFO(0, community, IS_STRING, 0)
1717
ZEND_ARG_TYPE_MASK(0, object_id, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
@@ -23,7 +23,7 @@ ZEND_END_ARG_INFO()
2323

2424
#define arginfo_snmpwalkoid arginfo_snmpwalk
2525

26-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmpset, 0, 5, MAY_BE_ARRAY|MAY_BE_BOOL)
26+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmpset, 0, 5, MAY_BE_ARRAY|MAY_BE_FALSE)
2727
ZEND_ARG_TYPE_INFO(0, hostname, IS_STRING, 0)
2828
ZEND_ARG_TYPE_INFO(0, community, IS_STRING, 0)
2929
ZEND_ARG_TYPE_MASK(0, object_id, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
@@ -56,7 +56,15 @@ ZEND_END_ARG_INFO()
5656

5757
#define arginfo_snmp2_real_walk arginfo_snmpwalk
5858

59-
#define arginfo_snmp2_set arginfo_snmpset
59+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_snmp2_set, 0, 5, _IS_BOOL, 0)
60+
ZEND_ARG_TYPE_INFO(0, hostname, IS_STRING, 0)
61+
ZEND_ARG_TYPE_INFO(0, community, IS_STRING, 0)
62+
ZEND_ARG_TYPE_MASK(0, object_id, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
63+
ZEND_ARG_TYPE_MASK(0, type, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
64+
ZEND_ARG_TYPE_MASK(0, value, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
65+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timeout, IS_LONG, 0, "-1")
66+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, retries, IS_LONG, 0, "-1")
67+
ZEND_END_ARG_INFO()
6068

6169
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_snmp3_get, 0, 8, stdClass, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_BOOL)
6270
ZEND_ARG_TYPE_INFO(0, hostname, IS_STRING, 0)
@@ -73,7 +81,7 @@ ZEND_END_ARG_INFO()
7381

7482
#define arginfo_snmp3_getnext arginfo_snmp3_get
7583

76-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmp3_walk, 0, 8, MAY_BE_ARRAY|MAY_BE_BOOL)
84+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmp3_walk, 0, 8, MAY_BE_ARRAY|MAY_BE_FALSE)
7785
ZEND_ARG_TYPE_INFO(0, hostname, IS_STRING, 0)
7886
ZEND_ARG_TYPE_INFO(0, security_name, IS_STRING, 0)
7987
ZEND_ARG_TYPE_INFO(0, security_level, IS_STRING, 0)
@@ -88,7 +96,7 @@ ZEND_END_ARG_INFO()
8896

8997
#define arginfo_snmp3_real_walk arginfo_snmp3_walk
9098

91-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmp3_set, 0, 10, MAY_BE_ARRAY|MAY_BE_BOOL)
99+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_snmp3_set, 0, 10, _IS_BOOL, 0)
92100
ZEND_ARG_TYPE_INFO(0, hostname, IS_STRING, 0)
93101
ZEND_ARG_TYPE_INFO(0, security_name, IS_STRING, 0)
94102
ZEND_ARG_TYPE_INFO(0, security_level, IS_STRING, 0)
@@ -122,10 +130,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP___construct, 0, 0, 3)
122130
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, retries, IS_LONG, 0, "-1")
123131
ZEND_END_ARG_INFO()
124132

125-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP_close, 0, 0, 0)
133+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SNMP_close, 0, 0, _IS_BOOL, 0)
126134
ZEND_END_ARG_INFO()
127135

128-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP_setSecurity, 0, 0, 1)
136+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SNMP_setSecurity, 0, 1, _IS_BOOL, 0)
129137
ZEND_ARG_TYPE_INFO(0, securityLevel, IS_STRING, 0)
130138
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, authProtocol, IS_STRING, 0, "\"\"")
131139
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, authPassphrase, IS_STRING, 0, "\"\"")
@@ -135,31 +143,33 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP_setSecurity, 0, 0, 1)
135143
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, contextEngineId, IS_STRING, 0, "\"\"")
136144
ZEND_END_ARG_INFO()
137145

138-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP_get, 0, 0, 1)
146+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_SNMP_get, 0, 1, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_FALSE)
139147
ZEND_ARG_TYPE_MASK(0, objectId, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
140148
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, preserveKeys, _IS_BOOL, 0, "false")
141149
ZEND_END_ARG_INFO()
142150

143-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP_getnext, 0, 0, 1)
151+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_SNMP_getnext, 0, 1, MAY_BE_ARRAY|MAY_BE_FALSE)
144152
ZEND_ARG_TYPE_MASK(0, objectId, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
145153
ZEND_END_ARG_INFO()
146154

147-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP_walk, 0, 0, 1)
155+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_SNMP_walk, 0, 1, MAY_BE_ARRAY|MAY_BE_FALSE)
148156
ZEND_ARG_TYPE_MASK(0, objectId, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
149157
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, suffixAsKey, _IS_BOOL, 0, "false")
150158
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, maxRepetitions, IS_LONG, 0, "-1")
151159
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, nonRepeaters, IS_LONG, 0, "-1")
152160
ZEND_END_ARG_INFO()
153161

154-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP_set, 0, 0, 3)
162+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SNMP_set, 0, 3, _IS_BOOL, 0)
155163
ZEND_ARG_TYPE_MASK(0, objectId, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
156164
ZEND_ARG_TYPE_MASK(0, type, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
157165
ZEND_ARG_TYPE_MASK(0, value, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
158166
ZEND_END_ARG_INFO()
159167

160-
#define arginfo_class_SNMP_getErrno arginfo_class_SNMP_close
168+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SNMP_getErrno, 0, 0, IS_LONG, 0)
169+
ZEND_END_ARG_INFO()
161170

162-
#define arginfo_class_SNMP_getError arginfo_class_SNMP_close
171+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SNMP_getError, 0, 0, IS_STRING, 0)
172+
ZEND_END_ARG_INFO()
163173

164174

165175
ZEND_FUNCTION(snmpget);

0 commit comments

Comments
 (0)