static void php_is_type(INTERNAL_FUNCTION_PARAMETERS, int type) { zval **arg; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &arg) == FAILURE) { RETURN_FALSE; } if (Z_TYPE_PP(arg) == type) { if (type == IS_OBJECT) { zend_class_entry *ce; if(Z_OBJ_HT_PP(arg)->get_class_entry == NULL) { /* if there's no get_class_entry it's not a PHP object, so it can't be INCOMPLETE_CLASS */ RETURN_TRUE; } ce = Z_OBJCE_PP(arg); if (!strcmp(ce->name, INCOMPLETE_CLASS)) { RETURN_FALSE; } } if (type == IS_RESOURCE) { const char *type_name = zend_rsrc_list_get_rsrc_type(Z_LVAL_PP(arg) TSRMLS_CC); if (!type_name) { RETURN_FALSE; } } RETURN_TRUE; } else { RETURN_FALSE; } }
static void php_is_type(INTERNAL_FUNCTION_PARAMETERS, int type) { zval **arg; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only one argument expected"); RETURN_FALSE; } if (Z_TYPE_PP(arg) == type) { if (type == IS_OBJECT) { zend_class_entry *ce; if(Z_OBJ_HT_PP(arg)->get_class_entry == NULL) { /* if there's no get_class_entry it's not a PHP object, so it can't be INCOMPLETE_CLASS */ RETURN_TRUE; } ce = Z_OBJCE_PP(arg); if (!strcmp(ce->name, INCOMPLETE_CLASS)) { RETURN_FALSE; } } if (type == IS_RESOURCE) { char *type_name; type_name = zend_rsrc_list_get_rsrc_type(Z_LVAL_PP(arg) TSRMLS_CC); if (!type_name) { RETURN_FALSE; } } RETURN_TRUE; } else { RETURN_FALSE; } }