Skip to content

Declare tentative return types for ext/snmp #7064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 32 additions & 32 deletions ext/snmp/snmp.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

/** @generate-class-entries */

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

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

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

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

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

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

function snmp_get_quick_print(): bool {}

Expand All @@ -26,46 +26,46 @@ function snmp_set_oid_output_format(int $format): bool {}
/** @alias snmp_set_oid_output_format */
function snmp_set_oid_numeric_print(int $format): bool {}

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

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

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

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

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 {}
function snmp2_set(string $hostname, string $community, array|string $object_id, array|string $type, array|string $value, int $timeout = -1, int $retries = -1): bool {}

function snmp3_get(
string $hostname, string $security_name, string $security_level,
string $auth_protocol, string $auth_passphrase,
string $privacy_protocol, string $privacy_passphrase,
array|string $object_id, int $timeout = -1, int $retries = -1): stdClass|array|string|bool {}
array|string $object_id, int $timeout = -1, int $retries = -1): mixed {}

function snmp3_getnext(
string $hostname, string $security_name, string $security_level,
string $auth_protocol, string $auth_passphrase,
string $privacy_protocol, string $privacy_passphrase,
array|string $object_id, int $timeout = -1, int $retries = -1): stdClass|array|string|bool {}
array|string $object_id, int $timeout = -1, int $retries = -1): mixed {}

function snmp3_walk(
string $hostname, string $security_name, string $security_level,
string $auth_protocol, string $auth_passphrase,
string $privacy_protocol, string $privacy_passphrase,
array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {}
array|string $object_id, int $timeout = -1, int $retries = -1): array|false {}

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

function snmp3_set(
string $hostname, string $security_name, string $security_level,
string $auth_protocol, string $auth_passphrase,
string $privacy_protocol, string $privacy_passphrase,
array|string $object_id, array|string $type, array|string $value,
int $timeout = -1, int $retries = -1): array|bool {}
int $timeout = -1, int $retries = -1): bool {}

function snmp_set_valueretrieval(int $method): bool {}

Expand All @@ -87,32 +87,32 @@ class SNMP

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

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

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

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

/** @return array|bool */
public function getnext(array|string $objectId) {}
/** @tentative-return-type */
public function getnext(array|string $objectId): mixed {}

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

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

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

/** @return string */
public function getError() {}
/** @tentative-return-type */
public function getError(): string {}
}

class SNMPException extends RuntimeException
Expand Down
32 changes: 17 additions & 15 deletions ext/snmp/snmp_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 5258c5796aca15e369dd72c0a8ed4dc1df31ce9d */
* Stub hash: 75ba939cab1a18a8e1c2836e0c0bbab9d310ba2b */

ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_snmpget, 0, 3, stdClass, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_BOOL)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_snmpget, 0, 3, IS_MIXED, 0)
ZEND_ARG_TYPE_INFO(0, hostname, 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)
Expand All @@ -11,7 +11,7 @@ ZEND_END_ARG_INFO()

#define arginfo_snmpgetnext arginfo_snmpget

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmpwalk, 0, 3, MAY_BE_ARRAY|MAY_BE_BOOL)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmpwalk, 0, 3, MAY_BE_ARRAY|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, hostname, 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)
Expand All @@ -23,7 +23,7 @@ ZEND_END_ARG_INFO()

#define arginfo_snmpwalkoid arginfo_snmpwalk

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmpset, 0, 5, MAY_BE_ARRAY|MAY_BE_BOOL)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_snmpset, 0, 5, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, hostname, 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)
Expand Down Expand Up @@ -58,7 +58,7 @@ ZEND_END_ARG_INFO()

#define arginfo_snmp2_set arginfo_snmpset

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_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_snmp3_get, 0, 8, IS_MIXED, 0)
ZEND_ARG_TYPE_INFO(0, hostname, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, security_name, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, security_level, IS_STRING, 0)
Expand All @@ -73,7 +73,7 @@ ZEND_END_ARG_INFO()

#define arginfo_snmp3_getnext arginfo_snmp3_get

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmp3_walk, 0, 8, MAY_BE_ARRAY|MAY_BE_BOOL)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmp3_walk, 0, 8, MAY_BE_ARRAY|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, hostname, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, security_name, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, security_level, IS_STRING, 0)
Expand All @@ -88,7 +88,7 @@ ZEND_END_ARG_INFO()

#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_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_snmp3_set, 0, 10, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, hostname, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, security_name, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, security_level, IS_STRING, 0)
Expand Down Expand Up @@ -122,10 +122,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP___construct, 0, 0, 3)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, retries, IS_LONG, 0, "-1")
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP_close, 0, 0, 0)
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SNMP_close, 0, 0, _IS_BOOL, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP_setSecurity, 0, 0, 1)
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SNMP_setSecurity, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, securityLevel, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, authProtocol, IS_STRING, 0, "\"\"")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, authPassphrase, IS_STRING, 0, "\"\"")
Expand All @@ -135,31 +135,33 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP_setSecurity, 0, 0, 1)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, contextEngineId, IS_STRING, 0, "\"\"")
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP_get, 0, 0, 1)
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SNMP_get, 0, 1, IS_MIXED, 0)
ZEND_ARG_TYPE_MASK(0, objectId, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, preserveKeys, _IS_BOOL, 0, "false")
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP_getnext, 0, 0, 1)
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SNMP_getnext, 0, 1, IS_MIXED, 0)
ZEND_ARG_TYPE_MASK(0, objectId, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP_walk, 0, 0, 1)
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_SNMP_walk, 0, 1, MAY_BE_ARRAY|MAY_BE_FALSE)
ZEND_ARG_TYPE_MASK(0, objectId, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, suffixAsKey, _IS_BOOL, 0, "false")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, maxRepetitions, IS_LONG, 0, "-1")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, nonRepeaters, IS_LONG, 0, "-1")
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP_set, 0, 0, 3)
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SNMP_set, 0, 3, _IS_BOOL, 0)
ZEND_ARG_TYPE_MASK(0, objectId, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
ZEND_ARG_TYPE_MASK(0, type, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
ZEND_ARG_TYPE_MASK(0, value, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
ZEND_END_ARG_INFO()

#define arginfo_class_SNMP_getErrno arginfo_class_SNMP_close
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SNMP_getErrno, 0, 0, IS_LONG, 0)
ZEND_END_ARG_INFO()

#define arginfo_class_SNMP_getError arginfo_class_SNMP_close
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SNMP_getError, 0, 0, IS_STRING, 0)
ZEND_END_ARG_INFO()


ZEND_FUNCTION(snmpget);
Expand Down