Skip to content

Commit ab8f256

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

File tree

2 files changed

+41
-39
lines changed

2 files changed

+41
-39
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): bool {}
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|string|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: 15 additions & 13 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: 075f404418ef02064022c5efcfed8174683376c8 */
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_INFO_EX(arginfo_snmpset, 0, 5, _IS_BOOL, 0)
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)
@@ -73,7 +73,7 @@ ZEND_END_ARG_INFO()
7373

7474
#define arginfo_snmp3_getnext arginfo_snmp3_get
7575

76-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmp3_walk, 0, 8, MAY_BE_ARRAY|MAY_BE_BOOL)
76+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmp3_walk, 0, 8, MAY_BE_ARRAY|MAY_BE_FALSE)
7777
ZEND_ARG_TYPE_INFO(0, hostname, IS_STRING, 0)
7878
ZEND_ARG_TYPE_INFO(0, security_name, IS_STRING, 0)
7979
ZEND_ARG_TYPE_INFO(0, security_level, IS_STRING, 0)
@@ -88,7 +88,7 @@ ZEND_END_ARG_INFO()
8888

8989
#define arginfo_snmp3_real_walk arginfo_snmp3_walk
9090

91-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmp3_set, 0, 10, MAY_BE_ARRAY|MAY_BE_BOOL)
91+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_snmp3_set, 0, 10, _IS_BOOL, 0)
9292
ZEND_ARG_TYPE_INFO(0, hostname, IS_STRING, 0)
9393
ZEND_ARG_TYPE_INFO(0, security_name, IS_STRING, 0)
9494
ZEND_ARG_TYPE_INFO(0, security_level, IS_STRING, 0)
@@ -122,10 +122,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP___construct, 0, 0, 3)
122122
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, retries, IS_LONG, 0, "-1")
123123
ZEND_END_ARG_INFO()
124124

125-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP_close, 0, 0, 0)
125+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SNMP_close, 0, 0, _IS_BOOL, 0)
126126
ZEND_END_ARG_INFO()
127127

128-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP_setSecurity, 0, 0, 1)
128+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SNMP_setSecurity, 0, 1, _IS_BOOL, 0)
129129
ZEND_ARG_TYPE_INFO(0, securityLevel, IS_STRING, 0)
130130
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, authProtocol, IS_STRING, 0, "\"\"")
131131
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, authPassphrase, IS_STRING, 0, "\"\"")
@@ -135,31 +135,33 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP_setSecurity, 0, 0, 1)
135135
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, contextEngineId, IS_STRING, 0, "\"\"")
136136
ZEND_END_ARG_INFO()
137137

138-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP_get, 0, 0, 1)
138+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_SNMP_get, 0, 1, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_FALSE)
139139
ZEND_ARG_TYPE_MASK(0, objectId, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
140140
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, preserveKeys, _IS_BOOL, 0, "false")
141141
ZEND_END_ARG_INFO()
142142

143-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP_getnext, 0, 0, 1)
143+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_SNMP_getnext, 0, 1, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_FALSE)
144144
ZEND_ARG_TYPE_MASK(0, objectId, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
145145
ZEND_END_ARG_INFO()
146146

147-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP_walk, 0, 0, 1)
147+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_SNMP_walk, 0, 1, MAY_BE_ARRAY|MAY_BE_FALSE)
148148
ZEND_ARG_TYPE_MASK(0, objectId, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
149149
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, suffixAsKey, _IS_BOOL, 0, "false")
150150
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, maxRepetitions, IS_LONG, 0, "-1")
151151
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, nonRepeaters, IS_LONG, 0, "-1")
152152
ZEND_END_ARG_INFO()
153153

154-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP_set, 0, 0, 3)
154+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SNMP_set, 0, 3, _IS_BOOL, 0)
155155
ZEND_ARG_TYPE_MASK(0, objectId, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
156156
ZEND_ARG_TYPE_MASK(0, type, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
157157
ZEND_ARG_TYPE_MASK(0, value, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
158158
ZEND_END_ARG_INFO()
159159

160-
#define arginfo_class_SNMP_getErrno arginfo_class_SNMP_close
160+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SNMP_getErrno, 0, 0, IS_LONG, 0)
161+
ZEND_END_ARG_INFO()
161162

162-
#define arginfo_class_SNMP_getError arginfo_class_SNMP_close
163+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SNMP_getError, 0, 0, IS_STRING, 0)
164+
ZEND_END_ARG_INFO()
163165

164166

165167
ZEND_FUNCTION(snmpget);

0 commit comments

Comments
 (0)