We can add these types as a native type declaration to stubs as a side-effect. Closes GH-6068
public function parseCurrency(string $value, &$currency, &$position = null) {}
/**
- * @param int|float $value
* @return bool
* @alias numfmt_set_attribute
*/
- public function setAttribute(int $attr, $value) {}
+ public function setAttribute(int $attr, int|float $value) {}
/**
* @return int|float|false
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 041569278b83b65f67fb4848d00d5423e6728165 */
+ * Stub hash: 60a05cccb434edadeec01cb7d43f919c276ce24d */
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_NumberFormatter___construct, 0, 0, 2)
ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 0)
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_NumberFormatter_setAttribute, 0, 0, 2)
ZEND_ARG_TYPE_INFO(0, attr, IS_LONG, 0)
- ZEND_ARG_INFO(0, value)
+ ZEND_ARG_TYPE_MASK(0, value, MAY_BE_LONG|MAY_BE_DOUBLE, NULL)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_NumberFormatter_getAttribute, 0, 0, 1)
FORMATTER_METHOD_INIT_VARS;
/* Parse parameters. */
- if( zend_parse_method_parameters( ZEND_NUM_ARGS(), getThis(), "Olz",
+ if( zend_parse_method_parameters( ZEND_NUM_ARGS(), getThis(), "Oln",
&object, NumberFormatter_ce_ptr, &attribute, &value ) == FAILURE)
{
RETURN_THROWS();
*/
function numfmt_parse_currency(NumberFormatter $fmt, string $value, &$currency, &$position = null): float|false {}
-/** @param int|float $value */
-function numfmt_set_attribute(NumberFormatter $fmt, int $attr, $value): bool {}
+function numfmt_set_attribute(NumberFormatter $fmt, int $attr, int|float $value): bool {}
function numfmt_get_attribute(NumberFormatter $fmt, int $attr): int|float|false {}
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 9284fbafde8c7430a30a8fff5537bf9e6d9c6125 */
+ * Stub hash: fdc7c500ddc5bc560ec54b7ce12d5961a4697a63 */
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_intlcal_create_instance, 0, 0, IntlCalendar, 1)
ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, timeZone, "null")
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_numfmt_set_attribute, 0, 3, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, fmt, NumberFormatter, 0)
ZEND_ARG_TYPE_INFO(0, attr, IS_LONG, 0)
- ZEND_ARG_INFO(0, value)
+ ZEND_ARG_TYPE_MASK(0, value, MAY_BE_LONG|MAY_BE_DOUBLE, NULL)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_numfmt_get_attribute, 0, 2, MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_FALSE)
/* {{{ php_ldap_do_search */
static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
{
- zval *link, *base_dn, *filter, *attrs = NULL, *attr, *serverctrls = NULL;
+ zval *link, *attrs = NULL, *attr, *serverctrls = NULL;
+ zend_string *base_dn_str, *filter_str;
+ HashTable *base_dn_ht, *filter_ht;
zend_long attrsonly, sizelimit, timelimit, deref;
zend_string *ldap_filter = NULL, *ldap_base_dn = NULL;
char **ldap_attrs = NULL;
int old_ldap_sizelimit = -1, old_ldap_timelimit = -1, old_ldap_deref = -1;
int num_attribs = 0, ret = 1, i, errno, argcount = ZEND_NUM_ARGS();
- if (zend_parse_parameters(argcount, "zzz|a/lllla/", &link, &base_dn, &filter, &attrs, &attrsonly,
- &sizelimit, &timelimit, &deref, &serverctrls) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(3, 9)
+ Z_PARAM_ZVAL(link)
+ Z_PARAM_STR_OR_ARRAY_HT(base_dn_str, base_dn_ht)
+ Z_PARAM_STR_OR_ARRAY_HT(filter_str, filter_ht)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_ARRAY_EX(attrs, 0, 1)
+ Z_PARAM_LONG(attrsonly)
+ Z_PARAM_LONG(sizelimit)
+ Z_PARAM_LONG(timelimit)
+ Z_PARAM_LONG(deref)
+ Z_PARAM_ARRAY_EX(serverctrls, 0, 1)
+ ZEND_PARSE_PARAMETERS_END();
/* Reverse -> fall through */
switch (argcount) {
goto cleanup;
}
- if (Z_TYPE_P(base_dn) == IS_ARRAY) {
- nbases = zend_hash_num_elements(Z_ARRVAL_P(base_dn));
+ if (base_dn_ht) {
+ nbases = zend_hash_num_elements(base_dn_ht);
if (nbases != nlinks) {
php_error_docref(NULL, E_WARNING, "Base must either be a string, or an array with the same number of elements as the links array");
ret = 0;
goto cleanup;
}
- zend_hash_internal_pointer_reset(Z_ARRVAL_P(base_dn));
+ zend_hash_internal_pointer_reset(base_dn_ht);
} else {
nbases = 0; /* this means string, not array */
- ldap_base_dn = zval_get_string(base_dn);
+ ldap_base_dn = zend_string_copy(base_dn_str);
if (EG(exception)) {
ret = 0;
goto cleanup;
}
}
- if (Z_TYPE_P(filter) == IS_ARRAY) {
- nfilters = zend_hash_num_elements(Z_ARRVAL_P(filter));
+ if (filter_ht) {
+ nfilters = zend_hash_num_elements(filter_ht);
if (nfilters != nlinks) {
php_error_docref(NULL, E_WARNING, "Filter must either be a string, or an array with the same number of elements as the links array");
ret = 0;
goto cleanup;
}
- zend_hash_internal_pointer_reset(Z_ARRVAL_P(filter));
+ zend_hash_internal_pointer_reset(filter_ht);
} else {
nfilters = 0; /* this means string, not array */
- ldap_filter = zval_get_string(filter);
- if (EG(exception)) {
- ret = 0;
- goto cleanup;
- }
+ ldap_filter = zend_string_copy(filter_str);
}
lds = safe_emalloc(nlinks, sizeof(ldap_linkdata), 0);
goto cleanup_parallel;
}
if (nbases != 0) { /* base_dn an array? */
- entry = zend_hash_get_current_data(Z_ARRVAL_P(base_dn));
- zend_hash_move_forward(Z_ARRVAL_P(base_dn));
+ entry = zend_hash_get_current_data(base_dn_ht);
+ zend_hash_move_forward(base_dn_ht);
ldap_base_dn = zval_get_string(entry);
if (EG(exception)) {
ret = 0;
}
}
if (nfilters != 0) { /* filter an array? */
- entry = zend_hash_get_current_data(Z_ARRVAL_P(filter));
- zend_hash_move_forward(Z_ARRVAL_P(filter));
+ entry = zend_hash_get_current_data(filter_ht);
+ zend_hash_move_forward(filter_ht);
ldap_filter = zval_get_string(entry);
if (EG(exception)) {
ret = 0;
efree(lds);
efree(rcs);
} else {
- ldap_filter = zval_get_string(filter);
- if (EG(exception)) {
+ ld = (ldap_linkdata *) zend_fetch_resource_ex(link, "ldap link", le_link);
+ if (ld == NULL) {
ret = 0;
goto cleanup;
}
- ldap_base_dn = zval_get_string(base_dn);
- if (EG(exception)) {
- ret = 0;
- goto cleanup;
+ if (!base_dn_str) {
+ zend_argument_type_error(2, "must be of type string when argument #1 ($link_identifier) is a resource");
}
+ ldap_base_dn = zend_string_copy(base_dn_str);
- ld = (ldap_linkdata *) zend_fetch_resource_ex(link, "ldap link", le_link);
- if (ld == NULL) {
- ret = 0;
- goto cleanup;
+ if (!filter_str) {
+ zend_argument_type_error(3, "must be of type string when argument #1 ($link_identifier) is a resource");
}
+ ldap_filter = zend_string_copy(filter_str);
if (argcount > 8) {
lserverctrls = _php_ldap_controls_from_array(ld->link, serverctrls);
/**
* @param resource|array $link_identifier
- * @param string|array $base_dn
- * @param string|array $filter
* @return resource|false
*/
-function ldap_read($link_identifier, $base_dn, $filter, array $attributes = [], int $attrsonly = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, array $servercontrols = []) {}
+function ldap_read($link_identifier, array|string $base_dn, array|string $filter, array $attributes = [], int $attrsonly = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, array $servercontrols = []) {}
/**
* @param resource|array $link_identifier
- * @param string|array $base_dn
- * @param string|array $filter
* @return resource|false
*/
-function ldap_list($link_identifier, $base_dn, $filter, array $attributes = [], int $attrsonly = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, array $servercontrols = []) {}
+function ldap_list($link_identifier, array|string $base_dn, array|string $filter, array $attributes = [], int $attrsonly = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, array $servercontrols = []) {}
/**
* @param resource|array $link_identifier
- * @param string|array $base_dn
- * @param string|array $filter
* @return resource|false
*/
-function ldap_search($link_identifier, $base_dn, $filter, array $attributes = [], int $attrsonly = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, array $servercontrols = []) {}
+function ldap_search($link_identifier, array|string $base_dn, array|string $filter, array $attributes = [], int $attrsonly = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, array $servercontrols = []) {}
/** @param resource $link_identifier */
function ldap_free_result($link_identifier): bool {}
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 6b5e8ddfbdc436fab3a263d6922146ca7c2f3845 */
+ * Stub hash: c247d438a69d40353a629b09c5200d33ed8218ee */
#if defined(HAVE_ORALDAP)
ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_connect, 0, 0, 0)
ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_read, 0, 0, 3)
ZEND_ARG_INFO(0, link_identifier)
- ZEND_ARG_INFO(0, base_dn)
- ZEND_ARG_INFO(0, filter)
+ ZEND_ARG_TYPE_MASK(0, base_dn, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
+ ZEND_ARG_TYPE_MASK(0, filter, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, attributes, IS_ARRAY, 0, "[]")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, attrsonly, IS_LONG, 0, "0")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, sizelimit, IS_LONG, 0, "-1")
/* {{{ reflection_class_object_ctor */
static void reflection_class_object_ctor(INTERNAL_FUNCTION_PARAMETERS, int is_object)
{
- zval *argument;
zval *object;
+ zend_string *arg_class = NULL;
+ zend_object *arg_obj;
reflection_object *intern;
zend_class_entry *ce;
if (is_object) {
ZEND_PARSE_PARAMETERS_START(1, 1)
- Z_PARAM_OBJECT(argument)
+ Z_PARAM_OBJ(arg_obj)
ZEND_PARSE_PARAMETERS_END();
} else {
ZEND_PARSE_PARAMETERS_START(1, 1)
- Z_PARAM_ZVAL(argument)
+ Z_PARAM_STR_OR_OBJ(arg_class, arg_obj)
ZEND_PARSE_PARAMETERS_END();
}
object = ZEND_THIS;
intern = Z_REFLECTION_P(object);
- if (Z_TYPE_P(argument) == IS_OBJECT) {
- ZVAL_STR_COPY(reflection_prop_name(object), Z_OBJCE_P(argument)->name);
- intern->ptr = Z_OBJCE_P(argument);
+ if (arg_obj) {
+ ZVAL_STR_COPY(reflection_prop_name(object), arg_obj->ce->name);
+ intern->ptr = arg_obj->ce;
if (is_object) {
- ZVAL_COPY(&intern->obj, argument);
+ ZVAL_OBJ_COPY(&intern->obj, arg_obj);
}
} else {
- if (!try_convert_to_string(argument)) {
- RETURN_THROWS();
- }
-
- if ((ce = zend_lookup_class(Z_STR_P(argument))) == NULL) {
+ if ((ce = zend_lookup_class(arg_class)) == NULL) {
if (!EG(exception)) {
- zend_throw_exception_ex(reflection_exception_ptr, -1, "Class \"%s\" does not exist", Z_STRVAL_P(argument));
+ zend_throw_exception_ex(reflection_exception_ptr, -1, "Class \"%s\" does not exist", ZSTR_VAL(arg_class));
}
RETURN_THROWS();
}
{
final private function __clone() {}
- /** @param object|string $objectOrClass */
- public function __construct($objectOrClass) {}
+ public function __construct(object|string $objectOrClass) {}
public function __toString(): string {}
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: beaf79270ab56d2e87a301a4a5d4444b2cc520d8 */
+ * Stub hash: 1311fc5c498d6f16afb5a18aee2d60e72048174f */
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Reflection_getModifierNames, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, modifiers, IS_LONG, 0)
#define arginfo_class_ReflectionClass___clone arginfo_class_ReflectionFunctionAbstract___clone
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ReflectionClass___construct, 0, 0, 1)
- ZEND_ARG_INFO(0, objectOrClass)
+ ZEND_ARG_TYPE_MASK(0, objectOrClass, MAY_BE_OBJECT|MAY_BE_STRING, NULL)
ZEND_END_ARG_INFO()
#define arginfo_class_ReflectionClass___toString arginfo_class_ReflectionFunction___toString
try {
var_dump(new ReflectionClass(array(1,2,3)));
-} catch (Exception $e) {
+} catch (TypeError $e) {
echo $e->getMessage() . "\n";
}
}
?>
---EXPECTF--
+--EXPECT--
ReflectionClass::__construct() expects exactly 1 parameter, 0 given
Class "" does not exist
Class "1" does not exist
Class "1" does not exist
-
-Warning: Array to string conversion in %s on line %d
-Class "Array" does not exist
+ReflectionClass::__construct(): Argument #1 ($objectOrClass) must be of type object|string, array given
ReflectionClass::__construct() expects exactly 1 parameter, 2 given
Class "X" does not exist
Method [ <internal:Reflection, ctor> public method __construct ] {
- Parameters [1] {
- Parameter #0 [ <required> $objectOrClass ]
+ Parameter #0 [ <required> object|string $objectOrClass ]
}
}
* OID parser (and type, value for SNMP_SET command)
*/
-static int php_snmp_parse_oid(zval *object, int st, struct objid_query *objid_query, zend_string *oid_str, HashTable *oid_ht, zval *type, zval *value)
-{
+static int php_snmp_parse_oid(
+ zval *object, int st, struct objid_query *objid_query, zend_string *oid_str, HashTable *oid_ht,
+ zend_string *type_str, HashTable *type_ht, zend_string *value_str, HashTable *value_ht
+) {
char *pptr;
uint32_t idx_type = 0, idx_value = 0;
zval *tmp_oid, *tmp_type, *tmp_value;
objid_query->vars = (snmpobjarg *)emalloc(sizeof(snmpobjarg));
objid_query->vars[objid_query->count].oid = ZSTR_VAL(oid_str);
if (st & SNMP_CMD_SET) {
- if (Z_TYPE_P(type) == IS_STRING && Z_TYPE_P(value) == IS_STRING) {
- if (Z_STRLEN_P(type) != 1) {
- php_error_docref(NULL, E_WARNING, "Bogus type '%s', should be single char, got %zu", Z_STRVAL_P(type), Z_STRLEN_P(type));
+ if (type_str && value_str) {
+ if (ZSTR_LEN(type_str) != 1) {
+ php_error_docref(NULL, E_WARNING, "Bogus type '%s', should be single char, got %zu", ZSTR_VAL(type_str), ZSTR_LEN(type_str));
efree(objid_query->vars);
return FALSE;
}
- pptr = Z_STRVAL_P(type);
+ pptr = ZSTR_VAL(type_str);
objid_query->vars[objid_query->count].type = *pptr;
- objid_query->vars[objid_query->count].value = Z_STRVAL_P(value);
+ objid_query->vars[objid_query->count].value = ZSTR_VAL(value_str);
} else {
php_error_docref(NULL, E_WARNING, "Single objid and multiple type or values are not supported");
efree(objid_query->vars);
convert_to_string_ex(tmp_oid);
objid_query->vars[objid_query->count].oid = Z_STRVAL_P(tmp_oid);
if (st & SNMP_CMD_SET) {
- if (Z_TYPE_P(type) == IS_STRING) {
- pptr = Z_STRVAL_P(type);
+ if (type_str) {
+ pptr = ZSTR_VAL(type_str);
objid_query->vars[objid_query->count].type = *pptr;
- } else if (Z_TYPE_P(type) == IS_ARRAY) {
- while (idx_type < Z_ARRVAL_P(type)->nNumUsed) {
- tmp_type = &Z_ARRVAL_P(type)->arData[idx_type].val;
+ } else if (type_ht) {
+ while (idx_type < type_ht->nNumUsed) {
+ tmp_type = &type_ht->arData[idx_type].val;
if (Z_TYPE_P(tmp_type) != IS_UNDEF) {
break;
}
idx_type++;
}
- if (idx_type < Z_ARRVAL_P(type)->nNumUsed) {
+ if (idx_type < type_ht->nNumUsed) {
convert_to_string_ex(tmp_type);
if (Z_STRLEN_P(tmp_type) != 1) {
php_error_docref(NULL, E_WARNING, "'%s': bogus type '%s', should be single char, got %zu", Z_STRVAL_P(tmp_oid), Z_STRVAL_P(tmp_type), Z_STRLEN_P(tmp_type));
}
}
- if (Z_TYPE_P(value) == IS_STRING) {
- objid_query->vars[objid_query->count].value = Z_STRVAL_P(value);
- } else if (Z_TYPE_P(value) == IS_ARRAY) {
- while (idx_value < Z_ARRVAL_P(value)->nNumUsed) {
- tmp_value = &Z_ARRVAL_P(value)->arData[idx_value].val;
+ if (value_str) {
+ objid_query->vars[objid_query->count].value = ZSTR_VAL(value_str);
+ } else if (value_ht) {
+ while (idx_value < value_ht->nNumUsed) {
+ tmp_value = &value_ht->arData[idx_value].val;
if (Z_TYPE_P(tmp_value) != IS_UNDEF) {
break;
}
idx_value++;
}
- if (idx_value < Z_ARRVAL_P(value)->nNumUsed) {
+ if (idx_value < value_ht->nNumUsed) {
convert_to_string_ex(tmp_value);
objid_query->vars[objid_query->count].value = Z_STRVAL_P(tmp_value);
idx_value++;
*/
static void php_snmp(INTERNAL_FUNCTION_PARAMETERS, int st, int version)
{
- zend_string *oid_str;
- HashTable *oid_ht;
- zval *value = NULL, *type = NULL;
+ zend_string *oid_str, *type_str = NULL, *value_str = NULL;
+ HashTable *oid_ht, *type_ht = NULL, *value_ht = NULL;
char *a1, *a2, *a3, *a4, *a5, *a6, *a7;
size_t a1_len, a2_len, a3_len, a4_len, a5_len, a6_len, a7_len;
zend_bool use_orignames = 0, suffix_keys = 0;
zend_long timeout = SNMP_DEFAULT_TIMEOUT;
zend_long retries = SNMP_DEFAULT_RETRIES;
- int argc = ZEND_NUM_ARGS();
struct objid_query objid_query;
php_snmp_session *session;
int session_less_mode = (getThis() == NULL);
Z_PARAM_STRING(a6, a6_len)
Z_PARAM_STRING(a7, a7_len)
Z_PARAM_STR_OR_ARRAY_HT(oid_str, oid_ht)
- Z_PARAM_ZVAL(type)
- Z_PARAM_ZVAL(value)
+ Z_PARAM_STR_OR_ARRAY_HT(type_str, type_ht)
+ Z_PARAM_STR_OR_ARRAY_HT(value_str, value_ht)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(timeout)
Z_PARAM_LONG(retries)
Z_PARAM_STRING(a1, a1_len)
Z_PARAM_STRING(a2, a2_len)
Z_PARAM_STR_OR_ARRAY_HT(oid_str, oid_ht)
- Z_PARAM_ZVAL(type)
- Z_PARAM_ZVAL(value)
+ Z_PARAM_STR_OR_ARRAY_HT(type_str, type_ht)
+ Z_PARAM_STR_OR_ARRAY_HT(value_str, value_ht)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(timeout)
Z_PARAM_LONG(retries)
if (st & SNMP_CMD_SET) {
ZEND_PARSE_PARAMETERS_START(3, 3)
Z_PARAM_STR_OR_ARRAY_HT(oid_str, oid_ht)
- Z_PARAM_ZVAL(type)
- Z_PARAM_ZVAL(value)
+ Z_PARAM_STR_OR_ARRAY_HT(type_str, type_ht)
+ Z_PARAM_STR_OR_ARRAY_HT(value_str, value_ht)
ZEND_PARSE_PARAMETERS_END();
} else if (st & SNMP_CMD_WALK) {
ZEND_PARSE_PARAMETERS_START(1, 4)
}
}
- if (!php_snmp_parse_oid(getThis(), st, &objid_query, oid_str, oid_ht, type, value)) {
+ if (!php_snmp_parse_oid(getThis(), st, &objid_query, oid_str, oid_ht, type_str, type_ht, value_str, value_ht)) {
RETURN_FALSE;
}
/** @alias snmprealwalk */
function snmpwalkoid(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {}
-/**
- * @param array|string $type
- * @param array|string $value
- */
-function snmpset(string $host, string $community, array|string $object_id, $type, $value, int $timeout = -1, int $retries = -1): array|bool {}
+function snmpset(string $host, string $community, array|string $object_id, array|string $type, array|string $value, int $timeout = -1, int $retries = -1): array|bool {}
function snmp_get_quick_print(): bool {}
function snmp2_real_walk(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {}
-/**
- * @param array|string $type
- * @param array|string $value
- */
-function snmp2_set(string $host, string $community, array|string $object_id, $type, $value, int $timeout = -1, int $retries = -1): array|bool {}
+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_real_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 {}
-/**
- * @param array|string $type
- * @param array|string $value
- */
-function snmp3_set(string $host, string $sec_name, string $sec_level, string $auth_protocol, string $auth_passphrase, string $priv_protocol, string $priv_passphrase, array|string $object_id, $type, $value, int $timeout = -1, int $retries = -1): array|bool {}
+function snmp3_set(string $host, string $sec_name, string $sec_level, string $auth_protocol, string $auth_passphrase, string $priv_protocol, string $priv_passphrase, array|string $object_id, array|string $type, array|string $value, int $timeout = -1, int $retries = -1): array|bool {}
function snmp_set_valueretrieval(int $method): bool {}
public function getnext(array|string $object_id) {}
/** @return array|bool */
- public function walk(array|string $object_id, bool $suffix_keys = false, int $max_repetitions = UNKNOWN, int $non_repeaters = UNKNOWN) {}
-
- /**
- * @param array|string $type
- * @param array|string $value
- * @return array|bool
- */
- public function set(array|string $object_id, $type, $value) {}
+ public function walk(array|string $object_id, bool $suffix_keys = false, int $max_repetitions = -1, int $non_repeaters = -1) {}
+
+ /** @return array|bool */
+ public function set(array|string $object_id, array|string $type, array|string $value) {}
/** @return int */
public function getErrno() {}
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 02b1dd87856dfdb43039f4544f3e5225a1fb1a6e */
+ * Stub hash: c9906ff8ef879e567cf8aed9a34dcff850f3e949 */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmpget, 0, 3, MAY_BE_ARRAY|MAY_BE_BOOL)
ZEND_ARG_TYPE_INFO(0, host, IS_STRING, 0)
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_INFO(0, type)
- ZEND_ARG_INFO(0, value)
+ 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_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()
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_INFO(0, type)
- ZEND_ARG_INFO(0, value)
+ 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_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()
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP_walk, 0, 0, 1)
ZEND_ARG_TYPE_MASK(0, object_id, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, suffix_keys, _IS_BOOL, 0, "false")
- ZEND_ARG_TYPE_INFO(0, max_repetitions, IS_LONG, 0)
- ZEND_ARG_TYPE_INFO(0, non_repeaters, IS_LONG, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, max_repetitions, IS_LONG, 0, "-1")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, non_repeaters, IS_LONG, 0, "-1")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP_set, 0, 0, 3)
ZEND_ARG_TYPE_MASK(0, object_id, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
- ZEND_ARG_INFO(0, type)
- ZEND_ARG_INFO(0, value)
+ 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
+++ /dev/null
---TEST--
-Test SNMP Reflection
---SKIPIF--
-<?php if (!extension_loaded('snmp')) die ("skip no snmp extension"); ?>
---FILE--
-<?php
-
-/* ALL PHP_ME user callable methods of SNMP class should appear here */
-
-echo new reflectionmethod('snmp', '__construct');
-echo new reflectionmethod('snmp', 'close');
-echo new reflectionmethod('snmp', 'setSecurity');
-echo new reflectionmethod('snmp', 'get');
-echo new reflectionmethod('snmp', 'getnext');
-echo new reflectionmethod('snmp', 'walk');
-echo new reflectionmethod('snmp', 'set');
-echo new reflectionmethod('snmp', 'getErrno');
-echo new reflectionmethod('snmp', 'getError');
-
-
-?>
---EXPECT--
-Method [ <internal:snmp, ctor> public method __construct ] {
-
- - Parameters [5] {
- Parameter #0 [ <required> int $version ]
- Parameter #1 [ <required> string $host ]
- Parameter #2 [ <required> string $community ]
- Parameter #3 [ <optional> int $timeout ]
- Parameter #4 [ <optional> int $retries ]
- }
-}
-Method [ <internal:snmp> public method close ] {
-
- - Parameters [0] {
- }
-}
-Method [ <internal:snmp> public method setSecurity ] {
-
- - Parameters [7] {
- Parameter #0 [ <required> string $sec_level ]
- Parameter #1 [ <optional> string $auth_protocol ]
- Parameter #2 [ <optional> string $auth_passphrase ]
- Parameter #3 [ <optional> string $priv_protocol ]
- Parameter #4 [ <optional> string $priv_passphrase ]
- Parameter #5 [ <optional> string $contextName ]
- Parameter #6 [ <optional> string $contextEngineID ]
- }
-}
-Method [ <internal:snmp> public method get ] {
-
- - Parameters [2] {
- Parameter #0 [ <required> $object_id ]
- Parameter #1 [ <optional> bool $use_orignames ]
- }
-}
-Method [ <internal:snmp> public method getnext ] {
-
- - Parameters [1] {
- Parameter #0 [ <required> $object_id ]
- }
-}
-Method [ <internal:snmp> public method walk ] {
-
- - Parameters [4] {
- Parameter #0 [ <required> $object_id ]
- Parameter #1 [ <optional> bool $suffix_keys ]
- Parameter #2 [ <optional> int $max_repetitions ]
- Parameter #3 [ <optional> int $non_repeaters ]
- }
-}
-Method [ <internal:snmp> public method set ] {
-
- - Parameters [3] {
- Parameter #0 [ <required> $object_id ]
- Parameter #1 [ <required> $type ]
- Parameter #2 [ <required> $value ]
- }
-}
-Method [ <internal:snmp> public method getErrno ] {
-
- - Parameters [0] {
- }
-}
-Method [ <internal:snmp> public method getError ] {
-
- - Parameters [0] {
- }
-}
/* {{{ Attach a new iterator */
PHP_METHOD(MultipleIterator, attachIterator)
{
- spl_SplObjectStorage *intern;
- zval *iterator = NULL, *info = NULL;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|z!", &iterator, zend_ce_iterator, &info) == FAILURE) {
- RETURN_THROWS();
- }
+ spl_SplObjectStorage *intern;
+ zval *iterator = NULL;
+ zval zinfo;
+ zend_string *info_str;
+ zend_long info_long;
+ zend_bool info_is_null = 1;
+
+ ZEND_PARSE_PARAMETERS_START(1, 2)
+ Z_PARAM_OBJECT_OF_CLASS(iterator, zend_ce_iterator)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_STR_OR_LONG_OR_NULL(info_str, info_long, info_is_null)
+ ZEND_PARSE_PARAMETERS_END();
intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
- if (info != NULL) {
+ if (!info_is_null) {
spl_SplObjectStorageElement *element;
- if (Z_TYPE_P(info) != IS_LONG && Z_TYPE_P(info) != IS_STRING) {
- zend_throw_exception(spl_ce_InvalidArgumentException, "Info must be NULL, integer or string", 0);
- RETURN_THROWS();
+ if (info_str) {
+ ZVAL_STR(&zinfo, info_str);
+ } else {
+ ZVAL_LONG(&zinfo, info_long);
}
zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);
while ((element = zend_hash_get_current_data_ptr_ex(&intern->storage, &intern->pos)) != NULL) {
- if (fast_is_identical_function(info, &element->inf)) {
+ if (fast_is_identical_function(&zinfo, &element->inf)) {
zend_throw_exception(spl_ce_InvalidArgumentException, "Key duplication error", 0);
RETURN_THROWS();
}
zend_hash_move_forward_ex(&intern->storage, &intern->pos);
}
- }
- spl_object_storage_attach(intern, iterator, info);
+ spl_object_storage_attach(intern, iterator, &zinfo);
+ } else {
+ spl_object_storage_attach(intern, iterator, NULL);
+ }
}
/* }}} */
/** @return void */
public function setFlags(int $flags) {}
- /**
- * @param int|string|null $info
- * @return void
- */
- public function attachIterator(Iterator $iterator, $info = null) {}
+ /** @return void */
+ public function attachIterator(Iterator $iterator, string|int|null $info = null) {}
/** @return void */
public function detachIterator(Iterator $iterator) {}
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: f795244462fc7b6aed3f38f6b2e1985b3a2ab7c1 */
+ * Stub hash: aab6134fb2223ffe4d686f3a601e66da17c99511 */
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplObserver_update, 0, 0, 1)
ZEND_ARG_OBJ_INFO(0, subject, SplSubject, 0)
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MultipleIterator_attachIterator, 0, 0, 1)
ZEND_ARG_OBJ_INFO(0, iterator, Iterator, 0)
- ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, info, "null")
+ ZEND_ARG_TYPE_MASK(0, info, MAY_BE_STRING|MAY_BE_LONG|MAY_BE_NULL, "null")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MultipleIterator_detachIterator, 0, 0, 1)
try {
$m->attachIterator($iter3, new stdClass());
-} catch(InvalidArgumentException $e) {
- echo "InvalidArgumentException thrown: " . $e->getMessage() . "\n";
+} catch(TypeError $e) {
+ echo "TypeError thrown: " . $e->getMessage() . "\n";
}
echo "-- Associate with duplicate value --\n";
int(3)
}
-- Associate with invalid value --
-InvalidArgumentException thrown: Info must be NULL, integer or string
+TypeError thrown: MultipleIterator::attachIterator(): Argument #2 ($info) must be of type string|int|null, stdClass given
-- Associate with duplicate value --
InvalidArgumentException thrown: Key duplication error
-- Count, contains, detach, count, contains, iterate --
function extract(array &$array, int $extract_type = EXTR_OVERWRITE, string $prefix = ""): int {}
/**
- * @param string|array $var_name
- * @param string|array $var_names
+ * @param array|string $var_name
+ * @param array|string $var_names
*/
function compact($var_name, ...$var_names): array {}
function array_fill_keys(array $keys, mixed $val): array {}
/**
- * @param int|float|string $low
- * @param int|float|string $high
- * @param int|float $step
+ * @param string|int|float $low
+ * @param string|int|float $high
*/
-function range($low, $high, $step = 1): array {}
+function range($low, $high, int|float $step = 1): array {}
function shuffle(array &$array): bool {}
function array_map(?callable $callback, array $array1, array ...$arrays): array {}
-/** @param int|string $key */
+/** @param string|int $key */
function array_key_exists($key, array $search): bool {}
/**
- * @param int|string $key
+ * @param string|int $key
* @alias array_key_exists
*/
function key_exists($key, array $search): bool {}
function header_remove(string $name = UNKNOWN): void {}
-/** @param int|array $expires_or_options */
+/** @param array|int $expires_or_options */
function setrawcookie(string $name, string $value = '', $expires_or_options = 0, string $path = '', string $domain = '', bool $secure = false, bool $httponly = false): bool {}
-/** @param int|array $expires_or_options */
+/** @param array|int $expires_or_options */
function setcookie(string $name, string $value = '', $expires_or_options = 0, string $path = '', string $domain = '', bool $secure = false, bool $httponly = false): bool {}
function http_response_code(int $response_code = 0): int|bool {}
* @param mixed $start
* @param mixed $length
*/
-function substr_replace(
- string|array $str, string|array $replace, $start, $length = UNKNOWN): string|array|false {}
+function substr_replace(array|string $str, string|array $replace, $start, $length = UNKNOWN): string|array|false {}
function quotemeta(string $str): string {}
function stripslashes(string $str): string {}
-/**
- * @param string|array $search
- * @param string|array $replace
- * @param int $replace_count
- */
-function str_replace(
- $search, $replace, string|array $subject, &$replace_count = UNKNOWN): string|array {}
+/** @param int $replace_count */
+function str_replace(array|string $search, array|string $replace, string|array $subject, &$replace_count = UNKNOWN): string|array {}
-/**
- * @param string|array $search
- * @param string|array $replace
- * @param int $replace_count
- */
-function str_ireplace(
- $search, $replace, string|array $subject, &$replace_count = UNKNOWN): string|array {}
+/** @param int $replace_count */
+function str_ireplace(array|string $search, array|string $replace, string|array $subject, &$replace_count = UNKNOWN): string|array {}
function hebrev(string $str, int $max_chars_per_line = 0): string {}
function password_get_info(string $hash): ?array {}
-/** @param string|int $algo */
-function password_hash(string $password, $algo, array $options = []): string {}
+function password_hash(string $password, string|int|null $algo, array $options = []): string {}
-/** @param string|int $algo */
-function password_needs_rehash(string $hash, $algo, array $options = []): bool {}
+function password_needs_rehash(string $hash, string|int $algo, array $options = []): bool {}
function password_verify(string $password, string $hash): bool {}
/** @param resource $context */
function stream_context_get_params($context): array {}
-/**
- * @param resource $context
- * @param array|string $param2
- * @param mixed $value
- */
-function stream_context_set_option($context, $param2, string $option_name = UNKNOWN, mixed $value = UNKNOWN): bool {}
+/** @param resource $context */
+function stream_context_set_option($context, array|string $wrapper_or_options, ?string $option_name = null, mixed $value = UNKNOWN): bool {}
/** @param resource $stream_or_context */
function stream_context_get_options($stream_or_context): array {}
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 8b6ef365e9635c92ef86adb40b2aba077867f3b2 */
+ * Stub hash: 010a6e0dee6d5e419e66eeefadd4dfabbbddfaca */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, seconds, IS_LONG, 0)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_range, 0, 2, IS_ARRAY, 0)
ZEND_ARG_INFO(0, low)
ZEND_ARG_INFO(0, high)
- ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, step, "1")
+ ZEND_ARG_TYPE_MASK(0, step, MAY_BE_LONG|MAY_BE_DOUBLE, "1")
ZEND_END_ARG_INFO()
#define arginfo_shuffle arginfo_natsort
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_substr_replace, 0, 3, MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_FALSE)
- ZEND_ARG_TYPE_MASK(0, str, MAY_BE_STRING|MAY_BE_ARRAY, NULL)
+ ZEND_ARG_TYPE_MASK(0, str, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
ZEND_ARG_TYPE_MASK(0, replace, MAY_BE_STRING|MAY_BE_ARRAY, NULL)
ZEND_ARG_INFO(0, start)
ZEND_ARG_INFO(0, length)
#define arginfo_stripslashes arginfo_base64_encode
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_str_replace, 0, 3, MAY_BE_STRING|MAY_BE_ARRAY)
- ZEND_ARG_INFO(0, search)
- ZEND_ARG_INFO(0, replace)
+ ZEND_ARG_TYPE_MASK(0, search, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
+ ZEND_ARG_TYPE_MASK(0, replace, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
ZEND_ARG_TYPE_MASK(0, subject, MAY_BE_STRING|MAY_BE_ARRAY, NULL)
ZEND_ARG_INFO(1, replace_count)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_password_hash, 0, 2, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, password, IS_STRING, 0)
- ZEND_ARG_INFO(0, algo)
+ ZEND_ARG_TYPE_MASK(0, algo, MAY_BE_STRING|MAY_BE_LONG|MAY_BE_NULL, NULL)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "[]")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_password_needs_rehash, 0, 2, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, hash, IS_STRING, 0)
- ZEND_ARG_INFO(0, algo)
+ ZEND_ARG_TYPE_MASK(0, algo, MAY_BE_STRING|MAY_BE_LONG, NULL)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "[]")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_stream_context_set_option, 0, 2, _IS_BOOL, 0)
ZEND_ARG_INFO(0, context)
- ZEND_ARG_INFO(0, param2)
- ZEND_ARG_TYPE_INFO(0, option_name, IS_STRING, 0)
+ ZEND_ARG_TYPE_MASK(0, wrapper_or_options, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, option_name, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0)
ZEND_END_ARG_INFO()
return Z_PTR_P(tmp);
}
-static const php_password_algo* php_password_algo_find_zval_ex(zval *arg, const php_password_algo* default_algo) {
- if (!arg || (Z_TYPE_P(arg) == IS_NULL)) {
- return default_algo;
+static const php_password_algo* php_password_algo_find_zval(zend_string *arg_str, zend_long arg_long, zend_bool arg_is_null) {
+ if (arg_is_null) {
+ return php_password_algo_default();
+ }
+
+ if (arg_str) {
+ return php_password_algo_find(arg_str);
}
- if (Z_TYPE_P(arg) == IS_LONG) {
- switch (Z_LVAL_P(arg)) {
- case 0: return default_algo;
- case 1: return &php_password_algo_bcrypt;
+ switch (arg_long) {
+ case 0: return php_password_algo_default();
+ case 1: return &php_password_algo_bcrypt;
#if HAVE_ARGON2LIB
- case 2: return &php_password_algo_argon2i;
- case 3: return &php_password_algo_argon2id;
+ case 2: return &php_password_algo_argon2i;
+ case 3: return &php_password_algo_argon2id;
#else
- case 2:
- {
- zend_string *n = zend_string_init("argon2i", sizeof("argon2i")-1, 0);
- const php_password_algo* ret = php_password_algo_find(n);
- zend_string_release(n);
- return ret;
- }
- case 3:
- {
- zend_string *n = zend_string_init("argon2id", sizeof("argon2id")-1, 0);
- const php_password_algo* ret = php_password_algo_find(n);
- zend_string_release(n);
- return ret;
- }
+ case 2:
+ {
+ zend_string *n = zend_string_init("argon2i", sizeof("argon2i")-1, 0);
+ const php_password_algo* ret = php_password_algo_find(n);
+ zend_string_release(n);
+ return ret;
+ }
+ case 3:
+ {
+ zend_string *n = zend_string_init("argon2id", sizeof("argon2id")-1, 0);
+ const php_password_algo* ret = php_password_algo_find(n);
+ zend_string_release(n);
+ return ret;
+ }
#endif
- }
- return NULL;
}
- if (Z_TYPE_P(arg) != IS_STRING) {
- return NULL;
- }
-
- return php_password_algo_find(Z_STR_P(arg));
-}
-static const php_password_algo* php_password_algo_find_zval(zval *arg) {
- return php_password_algo_find_zval_ex(arg, php_password_algo_default());
+ return NULL;
}
zend_string *php_password_algo_extract_ident(const zend_string* hash) {
{
const php_password_algo *old_algo, *new_algo;
zend_string *hash;
- zval *znew_algo;
+ zend_string *new_algo_str;
+ zend_long new_algo_long;
+ zend_bool new_algo_is_null;
zend_array *options = 0;
ZEND_PARSE_PARAMETERS_START(2, 3)
Z_PARAM_STR(hash)
- Z_PARAM_ZVAL(znew_algo)
+ Z_PARAM_STR_OR_LONG_OR_NULL(new_algo_str, new_algo_long, new_algo_is_null)
Z_PARAM_OPTIONAL
Z_PARAM_ARRAY_HT(options)
ZEND_PARSE_PARAMETERS_END();
- new_algo = php_password_algo_find_zval(znew_algo);
+ new_algo = php_password_algo_find_zval(new_algo_str, new_algo_long, new_algo_is_null);
if (!new_algo) {
/* Unknown new algorithm, never prompt to rehash. */
RETURN_FALSE;
PHP_FUNCTION(password_hash)
{
zend_string *password, *digest = NULL;
- zval *zalgo;
+ zend_string *algo_str;
+ zend_long algo_long;
+ zend_bool algo_is_null;
const php_password_algo *algo;
zend_array *options = NULL;
ZEND_PARSE_PARAMETERS_START(2, 3)
Z_PARAM_STR(password)
- Z_PARAM_ZVAL(zalgo)
+ Z_PARAM_STR_OR_LONG_OR_NULL(algo_str, algo_long, algo_is_null)
Z_PARAM_OPTIONAL
Z_PARAM_ARRAY_HT(options)
ZEND_PARSE_PARAMETERS_END();
- algo = php_password_algo_find_zval(zalgo);
+ algo = php_password_algo_find_zval(algo_str, algo_long, algo_is_null);
if (!algo) {
- zend_string *algostr = zval_get_string(zalgo);
zend_argument_value_error(2, "must be a valid password hashing algorithm");
- zend_string_release(algostr);
RETURN_THROWS();
}
}
}
-static int parse_context_options(php_stream_context *context, zval *options)
+static int parse_context_options(php_stream_context *context, HashTable *options)
{
zval *wval, *oval;
zend_string *wkey, *okey;
int ret = SUCCESS;
- ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(options), wkey, wval) {
+ ZEND_HASH_FOREACH_STR_KEY_VAL(options, wkey, wval) {
ZVAL_DEREF(wval);
if (wkey && Z_TYPE_P(wval) == IS_ARRAY) {
ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(wval), okey, oval) {
return ret;
}
-static int parse_context_params(php_stream_context *context, zval *params)
+static int parse_context_params(php_stream_context *context, HashTable *params)
{
int ret = SUCCESS;
zval *tmp;
- if (NULL != (tmp = zend_hash_str_find(Z_ARRVAL_P(params), "notification", sizeof("notification")-1))) {
+ if (NULL != (tmp = zend_hash_str_find(params, "notification", sizeof("notification")-1))) {
if (context->notifier) {
php_stream_notification_free(context->notifier);
ZVAL_COPY(&context->notifier->ptr, tmp);
context->notifier->dtor = user_space_stream_notifier_dtor;
}
- if (NULL != (tmp = zend_hash_str_find(Z_ARRVAL_P(params), "options", sizeof("options")-1))) {
+ if (NULL != (tmp = zend_hash_str_find(params, "options", sizeof("options")-1))) {
if (Z_TYPE_P(tmp) == IS_ARRAY) {
- return parse_context_options(context, tmp);
+ return parse_context_options(context, Z_ARRVAL_P(tmp));
} else {
zend_type_error("Invalid stream/context parameter");
return FAILURE;
{
zval *zcontext = NULL;
php_stream_context *context;
+ zend_string *wrappername;
+ HashTable *options;
+ char *optionname = NULL;
+ size_t optionname_len;
+ zval *zvalue = NULL;
- if (ZEND_NUM_ARGS() == 2) {
- zval *options;
+ ZEND_PARSE_PARAMETERS_START(2, 4)
+ Z_PARAM_RESOURCE(zcontext)
+ Z_PARAM_STR_OR_ARRAY_HT(wrappername, options)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_STRING_OR_NULL(optionname, optionname_len)
+ Z_PARAM_ZVAL(zvalue)
+ ZEND_PARSE_PARAMETERS_END();
+
+ /* figure out where the context is coming from exactly */
+ if (!(context = decode_context_param(zcontext))) {
+ zend_argument_type_error(1, "must be a valid stream/context");
+ RETURN_THROWS();
+ }
- ZEND_PARSE_PARAMETERS_START(2, 2)
- Z_PARAM_RESOURCE(zcontext)
- Z_PARAM_ARRAY(options)
- ZEND_PARSE_PARAMETERS_END();
+ if (options) {
+ if (optionname) {
+ zend_argument_value_error(3, "must be null when argument #2 ($wrapper_or_options) is an array");
+ RETURN_THROWS();
+ }
- /* figure out where the context is coming from exactly */
- if (!(context = decode_context_param(zcontext))) {
- zend_argument_type_error(1, "must be a valid stream/context");
+ if (zvalue) {
+ zend_argument_value_error(4, "cannot be provided when argument #2 ($wrapper_or_options) is an array");
RETURN_THROWS();
}
RETURN_BOOL(parse_context_options(context, options) == SUCCESS);
} else {
- zval *zvalue;
- char *wrappername, *optionname;
- size_t wrapperlen, optionlen;
-
- ZEND_PARSE_PARAMETERS_START(4, 4)
- Z_PARAM_RESOURCE(zcontext)
- Z_PARAM_STRING(wrappername, wrapperlen)
- Z_PARAM_STRING(optionname, optionlen)
- Z_PARAM_ZVAL(zvalue)
- ZEND_PARSE_PARAMETERS_END();
-
- /* figure out where the context is coming from exactly */
- if (!(context = decode_context_param(zcontext))) {
- zend_argument_type_error(1, "must be a valid stream/context");
+ if (!optionname) {
+ zend_argument_value_error(3, "cannot be null when argument #2 ($wrapper_or_options) is a string");
RETURN_THROWS();
}
- RETURN_BOOL(php_stream_context_set_option(context, wrappername, optionname, zvalue) == SUCCESS);
+ RETURN_BOOL(php_stream_context_set_option(context, ZSTR_VAL(wrappername), optionname, zvalue) == SUCCESS);
}
}
/* }}} */
/* {{{ Set parameters for a file context */
PHP_FUNCTION(stream_context_set_params)
{
- zval *params, *zcontext;
+ HashTable *params;
+ zval *zcontext;
php_stream_context *context;
ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_RESOURCE(zcontext)
- Z_PARAM_ARRAY(params)
+ Z_PARAM_ARRAY_HT(params)
ZEND_PARSE_PARAMETERS_END();
context = decode_context_param(zcontext);
/* {{{ Get a handle on the default file/stream context and optionally set parameters */
PHP_FUNCTION(stream_context_get_default)
{
- zval *params = NULL;
+ HashTable *params = NULL;
php_stream_context *context;
ZEND_PARSE_PARAMETERS_START(0, 1)
Z_PARAM_OPTIONAL
- Z_PARAM_ARRAY(params)
+ Z_PARAM_ARRAY_HT(params)
ZEND_PARSE_PARAMETERS_END();
if (FG(default_context) == NULL) {
/* {{{ Set default file/stream context, returns the context as a resource */
PHP_FUNCTION(stream_context_set_default)
{
- zval *options = NULL;
+ HashTable *options;
php_stream_context *context;
ZEND_PARSE_PARAMETERS_START(1, 1)
- Z_PARAM_ARRAY(options)
+ Z_PARAM_ARRAY_HT(options)
ZEND_PARSE_PARAMETERS_END();
if (FG(default_context) == NULL) {
/* {{{ Create a file context and optionally set parameters */
PHP_FUNCTION(stream_context_create)
{
- zval *options = NULL, *params = NULL;
+ HashTable *options = NULL;
+ HashTable *params = NULL;
php_stream_context *context;
ZEND_PARSE_PARAMETERS_START(0, 2)
Z_PARAM_OPTIONAL
- Z_PARAM_ARRAY_OR_NULL(options)
- Z_PARAM_ARRAY_OR_NULL(params)
+ Z_PARAM_ARRAY_HT_OR_NULL(options)
+ Z_PARAM_ARRAY_HT_OR_NULL(params)
ZEND_PARSE_PARAMETERS_END();
context = php_stream_context_alloc();
#define _isnewline(c) (((((unsigned char) c) == '\n' || ((unsigned char) c) == '\r')) ? 1 : 0)
/* {{{ php_str_replace_in_subject */
-static zend_long php_str_replace_in_subject(zval *search, zval *replace, zend_string *subject_str, zval *result, int case_sensitivity)
-{
+static zend_long php_str_replace_in_subject(
+ zend_string *search_str, HashTable *search_ht, zend_string *replace_str, HashTable *replace_ht,
+ zend_string *subject_str, zval *result, int case_sensitivity
+) {
zval *search_entry;
zend_string *tmp_result;
char *replace_value = NULL;
}
/* If search is an array */
- if (Z_TYPE_P(search) == IS_ARRAY) {
+ if (search_ht) {
/* Duplicate subject string for repeated replacement */
zend_string_addref(subject_str);
- if (Z_TYPE_P(replace) == IS_ARRAY) {
+ if (replace_ht) {
replace_idx = 0;
} else {
/* Set replacement value to the passed one */
- replace_value = Z_STRVAL_P(replace);
- replace_len = Z_STRLEN_P(replace);
+ replace_value = ZSTR_VAL(replace_str);
+ replace_len = ZSTR_LEN(replace_str);
}
/* For each entry in the search array, get the entry */
- ZEND_HASH_FOREACH_VAL_IND(Z_ARRVAL_P(search), search_entry) {
+ ZEND_HASH_FOREACH_VAL_IND(search_ht, search_entry) {
/* Make sure we're dealing with strings. */
zend_string *tmp_search_str;
zend_string *search_str = zval_get_tmp_string(search_entry, &tmp_search_str);
zend_string *replace_entry_str, *tmp_replace_entry_str = NULL;
/* If replace is an array. */
- if (Z_TYPE_P(replace) == IS_ARRAY) {
+ if (replace_ht) {
/* Get current entry */
zval *replace_entry = NULL;
- while (replace_idx < Z_ARRVAL_P(replace)->nNumUsed) {
- replace_entry = &Z_ARRVAL_P(replace)->arData[replace_idx].val;
+ while (replace_idx < replace_ht->nNumUsed) {
+ replace_entry = &replace_ht->arData[replace_idx].val;
if (Z_TYPE_P(replace_entry) != IS_UNDEF) {
break;
}
replace_idx++;
}
- if (replace_idx < Z_ARRVAL_P(replace)->nNumUsed) {
+ if (replace_idx < replace_ht->nNumUsed) {
/* Make sure we're dealing with strings. */
replace_entry_str = zval_get_tmp_string(replace_entry, &tmp_replace_entry_str);
zend_string_release_ex(lc_subject_str, 0);
}
} else {
- ZEND_ASSERT(Z_TYPE_P(search) == IS_STRING);
- if (Z_STRLEN_P(search) == 1) {
+ ZEND_ASSERT(search_str);
+ if (ZSTR_LEN(search_str) == 1) {
ZVAL_STR(result,
php_char_to_str_ex(subject_str,
- Z_STRVAL_P(search)[0],
- Z_STRVAL_P(replace),
- Z_STRLEN_P(replace),
+ ZSTR_VAL(search_str)[0],
+ ZSTR_VAL(replace_str),
+ ZSTR_LEN(replace_str),
case_sensitivity,
&replace_count));
- } else if (Z_STRLEN_P(search) > 1) {
+ } else if (ZSTR_LEN(search_str) > 1) {
if (case_sensitivity) {
ZVAL_STR(result, php_str_to_str_ex(subject_str,
- Z_STRVAL_P(search), Z_STRLEN_P(search),
- Z_STRVAL_P(replace), Z_STRLEN_P(replace), &replace_count));
+ ZSTR_VAL(search_str), ZSTR_LEN(search_str),
+ ZSTR_VAL(replace_str), ZSTR_LEN(replace_str), &replace_count));
} else {
lc_subject_str = php_string_tolower(subject_str);
ZVAL_STR(result, php_str_to_str_i_ex(subject_str, ZSTR_VAL(lc_subject_str),
- Z_STR_P(search),
- Z_STRVAL_P(replace), Z_STRLEN_P(replace), &replace_count));
+ search_str, ZSTR_VAL(replace_str), ZSTR_LEN(replace_str), &replace_count));
zend_string_release_ex(lc_subject_str, 0);
}
} else {
/* {{{ php_str_replace_common */
static void php_str_replace_common(INTERNAL_FUNCTION_PARAMETERS, int case_sensitivity)
{
+ zend_string *search_str;
+ HashTable *search_ht;
+ zend_string *replace_str;
+ HashTable *replace_ht;
zend_string *subject_str;
HashTable *subject_ht;
- zval *search, *replace, *subject_entry, *zcount = NULL;
+ zval *subject_entry, *zcount = NULL;
zval result;
zend_string *string_key;
zend_ulong num_key;
int argc = ZEND_NUM_ARGS();
ZEND_PARSE_PARAMETERS_START(3, 4)
- Z_PARAM_ZVAL(search)
- Z_PARAM_ZVAL(replace)
+ Z_PARAM_STR_OR_ARRAY_HT(search_str, search_ht)
+ Z_PARAM_STR_OR_ARRAY_HT(replace_str, replace_ht)
Z_PARAM_STR_OR_ARRAY_HT(subject_str, subject_ht)
Z_PARAM_OPTIONAL
Z_PARAM_ZVAL(zcount)
ZEND_PARSE_PARAMETERS_END();
/* Make sure we're dealing with strings and do the replacement. */
- if (Z_TYPE_P(search) != IS_ARRAY) {
- convert_to_string_ex(search);
- if (Z_TYPE_P(replace) != IS_STRING) {
- convert_to_string_ex(replace);
- }
- } else if (Z_TYPE_P(replace) != IS_ARRAY) {
- convert_to_string_ex(replace);
- }
-
- if (EG(exception)) {
+ if (search_str && replace_ht) {
+ zend_argument_type_error(2, "must be of type %s when argument #1 ($search) is %s",
+ search_str ? "string" : "array", search_str ? "a string" : "an array"
+ );
RETURN_THROWS();
}
zend_string *tmp_subject_str;
ZVAL_DEREF(subject_entry);
subject_str = zval_get_tmp_string(subject_entry, &tmp_subject_str);
- count += php_str_replace_in_subject(search, replace, subject_str, &result, case_sensitivity);
+ count += php_str_replace_in_subject(search_str, search_ht, replace_str, replace_ht, subject_str, &result, case_sensitivity);
zend_tmp_string_release(tmp_subject_str);
/* Add to return array */
}
} ZEND_HASH_FOREACH_END();
} else { /* if subject is not an array */
- count = php_str_replace_in_subject(search, replace, subject_str, return_value, case_sensitivity);
+ count = php_str_replace_in_subject(search_str, search_ht, replace_str, replace_ht, subject_str, return_value, case_sensitivity);
}
if (argc > 3) {
ZEND_TRY_ASSIGN_REF_LONG(zcount, count);
try {
password_hash("foo", array());
-} catch (ValueError $exception) {
+} catch (TypeError $exception) {
echo $exception->getMessage() . "\n";
}
}
?>
---EXPECTF--
+--EXPECT--
password_hash() expects at least 2 parameters, 1 given
-
-Warning: Array to string conversion in %s on line %d
-password_hash(): Argument #2 ($algo) must be a valid password hashing algorithm
+password_hash(): Argument #2 ($algo) must be of type string|int|null, array given
password_hash(): Argument #3 ($options) must be of type array, stdClass given
password_hash(): Argument #3 ($options) must be of type array, string given
password_hash(): Argument #1 ($password) must be of type string, array given
Test error operation of password_needs_rehash()
--FILE--
<?php
-//-=-=-=-
try {
var_dump(password_needs_rehash(''));
echo $e->getMessage(), "\n";
}
-var_dump(password_needs_rehash('', []));
+try {
+ var_dump(password_needs_rehash('', []));
+} catch (TypeError $e) {
+ echo $e->getMessage(), "\n";
+}
try {
var_dump(password_needs_rehash(array(), PASSWORD_BCRYPT));
?>
--EXPECT--
password_needs_rehash() expects at least 2 parameters, 1 given
-bool(false)
+password_needs_rehash(): Argument #2 ($algo) must be of type string|int|null, array given
password_needs_rehash(): Argument #1 ($hash) must be of type string, array given
password_needs_rehash(): Argument #3 ($options) must be of type array, string given
OK!
int(1)
string(0) ""
int(0)
-str_replace(): Argument #3 ($subject) must be of type string|array, resource given
+str_replace(): Argument #1 ($search) must be of type array|string, resource given
resource(%d) of type (stream)
);
var_dump($count);
-var_dump(str_replace("a", array("q", "q", "c"), array("aaa"), $count));
-var_dump($count);
+try {
+ str_replace("a", array("q", "q", "c"), array("aaa"), $count);
+} catch (TypeError $exception) {
+ echo $exception->getMessage() . "\n";
+}
var_dump(str_replace("a", 1, array("aaa", "bbb"), $count));
var_dump($count);
string(3) "ccc"
}
int(6)
-
-Warning: Array to string conversion in %s on line %d
-array(1) {
- [0]=>
- string(15) "ArrayArrayArray"
-}
-int(3)
+str_replace(): Argument #2 ($replace) must be of type string when argument #1 ($search) is a string
array(2) {
[0]=>
string(3) "111"
int(1)
-- Testing Resources --
-str_replace(): Argument #3 ($subject) must be of type string|array, resource given
-str_replace(): Argument #3 ($subject) must be of type string|array, resource given
+str_replace(): Argument #3 ($subject) must be of type array|string, resource given
+str_replace(): Argument #3 ($subject) must be of type array|string, resource given
-- Testing a longer and heredoc string --
string(623) "FOUNDghijklmnopqrstuvwxyz0123456789FOUNDghijklmnopqrstuvwxyz0123456789