mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Add number or str ZPP macros
This commit is contained in:
parent
53829b7daf
commit
80e90ad7ba
6 changed files with 194 additions and 1 deletions
|
@ -674,6 +674,36 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_number_slow(zval *arg, zval **dest, u
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
ZEND_API bool ZEND_FASTCALL zend_parse_arg_number_or_str_slow(zval *arg, zval **dest, uint32_t arg_num) /* {{{ */
|
||||
{
|
||||
if (UNEXPECTED(ZEND_ARG_USES_STRICT_TYPES())) {
|
||||
return false;
|
||||
}
|
||||
if (Z_TYPE_P(arg) < IS_TRUE) {
|
||||
if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("string|int|float", arg_num)) {
|
||||
return false;
|
||||
}
|
||||
ZVAL_LONG(arg, 0);
|
||||
} else if (Z_TYPE_P(arg) == IS_TRUE) {
|
||||
ZVAL_LONG(arg, 1);
|
||||
} else if (UNEXPECTED(Z_TYPE_P(arg) == IS_OBJECT)) {
|
||||
zend_object *zobj = Z_OBJ_P(arg);
|
||||
zval obj;
|
||||
if (zobj->handlers->cast_object(zobj, &obj, IS_STRING) == SUCCESS) {
|
||||
OBJ_RELEASE(zobj);
|
||||
ZVAL_COPY_VALUE(arg, &obj);
|
||||
*dest = arg;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
*dest = arg;
|
||||
return true;
|
||||
}
|
||||
|
||||
ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, zend_string **dest, uint32_t arg_num) /* {{{ */
|
||||
{
|
||||
if (EXPECTED(Z_TYPE_P(arg) < IS_STRING)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue