Fix some snmp stubs

As well as some basic mistakes in tests.
This commit is contained in:
Nikita Popov 2020-09-08 17:01:08 +02:00
parent 6e91a2ef5e
commit 905c79c05c
4 changed files with 37 additions and 20 deletions

View File

@ -2,9 +2,9 @@
/** @generate-function-entries */
function snmpget(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {}
function snmpget(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): stdClass|array|string|bool {}
function snmpgetnext(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {}
function snmpgetnext(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): stdClass|array|string|bool {}
function snmpwalk(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {}
@ -26,9 +26,9 @@ function snmp_set_oid_output_format(int $oid_format): bool {}
/** @alias snmp_set_oid_output_format */
function snmp_set_oid_numeric_print(int $oid_format): bool {}
function snmp2_get(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {}
function snmp2_get(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): stdClass|array|string|bool {}
function snmp2_getnext(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {}
function snmp2_getnext(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): stdClass|array|string|bool {}
function snmp2_walk(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {}
@ -36,9 +36,9 @@ function snmp2_real_walk(string $host, string $community, array|string $object_i
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 {}
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 {}
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 {}
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 {}
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 {}
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 {}

View File

@ -1,7 +1,7 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: c9906ff8ef879e567cf8aed9a34dcff850f3e949 */
* Stub hash: 759c8a5e721d1c6c9cb63e59ae14f85831396a4d */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmpget, 0, 3, MAY_BE_ARRAY|MAY_BE_BOOL)
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_snmpget, 0, 3, stdClass, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_BOOL)
ZEND_ARG_TYPE_INFO(0, host, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, community, IS_STRING, 0)
ZEND_ARG_TYPE_MASK(0, object_id, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
@ -11,11 +11,17 @@ ZEND_END_ARG_INFO()
#define arginfo_snmpgetnext arginfo_snmpget
#define arginfo_snmpwalk arginfo_snmpget
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmpwalk, 0, 3, MAY_BE_ARRAY|MAY_BE_BOOL)
ZEND_ARG_TYPE_INFO(0, host, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, community, IS_STRING, 0)
ZEND_ARG_TYPE_MASK(0, object_id, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timeout, IS_LONG, 0, "-1")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, retries, IS_LONG, 0, "-1")
ZEND_END_ARG_INFO()
#define arginfo_snmprealwalk arginfo_snmpget
#define arginfo_snmprealwalk arginfo_snmpwalk
#define arginfo_snmpwalkoid arginfo_snmpget
#define arginfo_snmpwalkoid arginfo_snmpwalk
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmpset, 0, 5, MAY_BE_ARRAY|MAY_BE_BOOL)
ZEND_ARG_TYPE_INFO(0, host, IS_STRING, 0)
@ -48,13 +54,13 @@ ZEND_END_ARG_INFO()
#define arginfo_snmp2_getnext arginfo_snmpget
#define arginfo_snmp2_walk arginfo_snmpget
#define arginfo_snmp2_walk arginfo_snmpwalk
#define arginfo_snmp2_real_walk arginfo_snmpget
#define arginfo_snmp2_real_walk arginfo_snmpwalk
#define arginfo_snmp2_set arginfo_snmpset
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmp3_get, 0, 8, MAY_BE_ARRAY|MAY_BE_BOOL)
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_snmp3_get, 0, 8, stdClass, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_BOOL)
ZEND_ARG_TYPE_INFO(0, host, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, sec_name, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, sec_level, IS_STRING, 0)
@ -69,9 +75,20 @@ ZEND_END_ARG_INFO()
#define arginfo_snmp3_getnext arginfo_snmp3_get
#define arginfo_snmp3_walk arginfo_snmp3_get
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmp3_walk, 0, 8, MAY_BE_ARRAY|MAY_BE_BOOL)
ZEND_ARG_TYPE_INFO(0, host, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, sec_name, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, sec_level, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, auth_protocol, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, auth_passphrase, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, priv_protocol, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, priv_passphrase, IS_STRING, 0)
ZEND_ARG_TYPE_MASK(0, object_id, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timeout, IS_LONG, 0, "-1")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, retries, IS_LONG, 0, "-1")
ZEND_END_ARG_INFO()
#define arginfo_snmp3_real_walk arginfo_snmp3_get
#define arginfo_snmp3_real_walk arginfo_snmp3_walk
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmp3_set, 0, 10, MAY_BE_ARRAY|MAY_BE_BOOL)
ZEND_ARG_TYPE_INFO(0, host, IS_STRING, 0)

View File

@ -31,7 +31,7 @@ try {
}
try {
var_dump(new SNMP(7, $hostname, $community));
} catch (Exception $e) {
} catch (ValueError $e) {
print $e->getMessage() . "\n";
}
@ -70,8 +70,8 @@ var_dump($session->max_oids);
?>
--EXPECTF--
SNMP::__construct() expects at least 3 parameters, 2 given
SNMP::__construct(): Argument #4 must be of type int, string given
SNMP::__construct(): Argument #5 must be of type int, string given
SNMP::__construct(): Argument #4 ($timeout) must be of type int, string given
SNMP::__construct(): Argument #5 ($retries) must be of type int, string given
SNMP::__construct(): Argument #1 ($version) must be a valid SNMP protocol version
Exception handling

View File

@ -184,7 +184,7 @@ string(11) "param_value"
bool(true)
Error handling
Notice: Undefined property: SNMP::$there is no such parameter in %s on line %d
Warning: Undefined property: SNMP::$there is no such parameter in %s on line %d
NULL
bool(false)