RETURN_THROWS();
}
if (name == NULL) {
- name = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->name: NULL;
- if (name != NULL) {
- RETURN_STRING(name);
- } else {
- RETURN_FALSE;
- }
+ ZEND_ASSERT(MBSTRG(current_internal_encoding));
+ RETURN_STRING(MBSTRG(current_internal_encoding)->name);
} else {
encoding = mbfl_name2encoding(name);
if (!encoding) {
} else {
MBSTRG(current_internal_encoding) = encoding;
MBSTRG(internal_encoding_set) = 1;
+ /* TODO Return old encoding */
RETURN_TRUE;
}
}
}
}
if (!list) {
+ // TODO should return empty string?
RETURN_FALSE;
}
RETVAL_STRING(list);
retname = 0;
break;
default:
+ // TODO ValueError
result = MBSTRG(http_input_identify);
break;
}
}
+ // FIXME this bloc seems useless except for default switch case
if (retname) {
if (result) {
RETVAL_STRING(result->name);
}
if (name == NULL) {
- name = MBSTRG(current_http_output_encoding) ? MBSTRG(current_http_output_encoding)->name: NULL;
- if (name != NULL) {
- RETURN_STRING(name);
- } else {
- RETURN_FALSE;
- }
+ ZEND_ASSERT(MBSTRG(current_http_output_encoding));
+ RETURN_STRING(MBSTRG(current_http_output_encoding)->name);
} else {
encoding = mbfl_name2encoding(name);
if (!encoding) {
} else {
MBSTRG(http_output_set) = 1;
MBSTRG(current_http_output_encoding) = encoding;
+ /* TODO Return previous encoding? */
RETURN_TRUE;
}
}
if (!mbfl_is_error(n)) {
if (part) {
ret = mbfl_substr(&haystack, &result, 0, n);
- if (ret != NULL) {
- // TODO: avoid reallocation ???
- RETVAL_STRINGL((char *)ret->val, ret->len);
- efree(ret->val);
- } else {
- RETVAL_FALSE;
- }
+ ZEND_ASSERT(ret != NULL);
+ // TODO: avoid reallocation ???
+ RETVAL_STRINGL((char *)ret->val, ret->len);
+ efree(ret->val);
} else {
ret = mbfl_substr(&haystack, &result, n, MBFL_SUBSTR_UNTIL_END);
- if (ret != NULL) {
- // TODO: avoid reallocation ???
- RETVAL_STRINGL((char *)ret->val, ret->len);
- efree(ret->val);
- } else {
- RETVAL_FALSE;
- }
+ ZEND_ASSERT(ret != NULL);
+ // TODO: avoid reallocation ???
+ RETVAL_STRINGL((char *)ret->val, ret->len);
+ efree(ret->val);
}
} else {
+ // FIXME use handle_strpos_error(n)
RETVAL_FALSE;
}
}
}
ret = mbfl_substr(&string, &result, real_from, real_len);
- if (NULL == ret) {
- RETURN_FALSE;
- }
+ ZEND_ASSERT(ret != NULL);
// TODO: avoid reallocation ???
RETVAL_STRINGL((char *)ret->val, ret->len); /* the string is already strdup()'ed */
}
if (from > string.len) {
+ // TODO Out of bounds ValueError
RETURN_FALSE;
}
ret = mbfl_strcut(&string, &result, from, len);
- if (ret == NULL) {
- RETURN_FALSE;
- }
+ ZEND_ASSERT(ret != NULL);
// TODO: avoid reallocation ???
RETVAL_STRINGL((char *)ret->val, ret->len); /* the string is already strdup()'ed */
}
n = mbfl_strwidth(&string);
- if (!mbfl_is_error(n)) {
- RETVAL_LONG(n);
- } else {
- RETVAL_FALSE;
- }
+ ZEND_ASSERT(n >= 0);
+ RETVAL_LONG(n);
}
/* }}} */
}
ret = mbfl_strimwidth(&string, &marker, &result, from, width);
-
- if (ret == NULL) {
- RETURN_FALSE;
- }
+ ZEND_ASSERT(ret != NULL);
// TODO: avoid reallocation ???
RETVAL_STRINGL((char *)ret->val, ret->len); /* the string is already strdup()'ed */
efree(ret->val);
mbfl_string_init(&result);
ret = mbfl_mime_header_encode(&string, &result, charset, transenc, linefeed, indent);
- if (ret != NULL) {
- // TODO: avoid reallocation ???
- RETVAL_STRINGL((char *)ret->val, ret->len); /* the string is already strdup()'ed */
- efree(ret->val);
- } else {
- RETVAL_FALSE;
- }
+ ZEND_ASSERT(ret != NULL);
+ // TODO: avoid reallocation ???
+ RETVAL_STRINGL((char *)ret->val, ret->len); /* the string is already strdup()'ed */
+ efree(ret->val);
}
/* }}} */
mbfl_string_init(&result);
ret = mbfl_mime_header_decode(&string, &result, MBSTRG(current_internal_encoding));
- if (ret != NULL) {
- // TODO: avoid reallocation ???
- RETVAL_STRINGL((char *)ret->val, ret->len); /* the string is already strdup()'ed */
- efree(ret->val);
- } else {
- RETVAL_FALSE;
- }
+ ZEND_ASSERT(ret != NULL);
+ // TODO: avoid reallocation ???
+ RETVAL_STRINGL((char *)ret->val, ret->len); /* the string is already strdup()'ed */
+ efree(ret->val);
}
/* }}} */
}
ret = mbfl_ja_jp_hantozen(&string, &result, opt);
- if (ret != NULL) {
- // TODO: avoid reallocation ???
- RETVAL_STRINGL((char *)ret->val, ret->len); /* the string is already strdup()'ed */
- efree(ret->val);
- } else {
- RETVAL_FALSE;
- }
+ ZEND_ASSERT(ret != NULL);
+ // TODO: avoid reallocation ???
+ RETVAL_STRINGL((char *)ret->val, ret->len); /* the string is already strdup()'ed */
+ efree(ret->val);
}
/* }}} */
mapsize /= 4;
ret = mbfl_html_numeric_entity(&string, &result, convmap, mapsize, type);
- if (ret != NULL) {
- // TODO: avoid reallocation ???
- RETVAL_STRINGL((char *)ret->val, ret->len);
- efree(ret->val);
- } else {
- RETVAL_FALSE;
- }
+ ZEND_ASSERT(ret != NULL);
+ // TODO: avoid reallocation ???
+ RETVAL_STRINGL((char *)ret->val, ret->len);
+ efree(ret->val);
efree((void *)convmap);
}
/* }}} */
RETVAL_STRING("Off");
}
} else {
+ // TODO Convert to ValueError
RETURN_FALSE;
}
}
function mb_substr_count(string $haystack, string $needle, string $encoding = UNKNOWN): int {}
-function mb_substr(string $str, int $start, ?int $length = null, string $encoding = UNKNOWN): string|false {}
+function mb_substr(string $str, int $start, ?int $length = null, string $encoding = UNKNOWN): string {}
function mb_strcut(string $str, int $start, ?int $length = null, string $encoding = UNKNOWN): string|false {}
-function mb_strwidth(string $str, string $encoding = UNKNOWN): int|false {}
+function mb_strwidth(string $str, string $encoding = UNKNOWN): int {}
-function mb_strimwidth(string $str, int $start, int $width, string $trimmarker = UNKNOWN, string $encoding = UNKNOWN): string|false {}
+function mb_strimwidth(string $str, int $start, int $width, string $trim_marker = UNKNOWN, string $encoding = UNKNOWN): string {}
function mb_convert_encoding(array|string $str, string $to, array|string $from = UNKNOWN): array|string|false {}
function mb_list_encodings(): array {}
-function mb_encoding_aliases(string $encoding): array|false {}
+function mb_encoding_aliases(string $encoding): array {}
-function mb_encode_mimeheader(string $str, string $charset = UNKNOWN, string $transfer = UNKNOWN, string $linefeed = UNKNOWN, int $indent = 0): string|false {}
+function mb_encode_mimeheader(string $str, string $charset = UNKNOWN, string $transfer = UNKNOWN, string $linefeed = UNKNOWN, int $indent = 0): string {}
-function mb_decode_mimeheader(string $string): string|false {}
+function mb_decode_mimeheader(string $string): string {}
-function mb_convert_kana(string $str, string $option = UNKNOWN, string $encoding = UNKNOWN): string|false {}
+function mb_convert_kana(string $str, string $option = UNKNOWN, string $encoding = UNKNOWN): string {}
function mb_convert_variables(string $to, array|string $from, &$var, &...$vars): string|false {}
-function mb_encode_numericentity(string $string, array $convmap, string $encoding = UNKNOWN, bool $is_hex = false): string|false {}
+function mb_encode_numericentity(string $string, array $convmap, string $encoding = UNKNOWN, bool $is_hex = false): string {}
-function mb_decode_numericentity(string $string, array $convmap, string $encoding = UNKNOWN): string|false {}
+function mb_decode_numericentity(string $string, array $convmap, string $encoding = UNKNOWN): string {}
function mb_send_mail(string $to, string $subject, string $message, $additional_headers = UNKNOWN, string $additional_parameters = UNKNOWN): bool {}
ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_substr, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mb_substr, 0, 2, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, start, IS_LONG, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 1, "null")
ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0)
ZEND_END_ARG_INFO()
-#define arginfo_mb_strcut arginfo_mb_substr
-
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_strwidth, 0, 1, MAY_BE_LONG|MAY_BE_FALSE)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_strcut, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO(0, start, IS_LONG, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 1, "null")
ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_strimwidth, 0, 3, MAY_BE_STRING|MAY_BE_FALSE)
+#define arginfo_mb_strwidth arginfo_mb_strlen
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mb_strimwidth, 0, 3, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, start, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, width, IS_LONG, 0)
- ZEND_ARG_TYPE_INFO(0, trimmarker, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO(0, trim_marker, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mb_list_encodings, 0, 0, IS_ARRAY, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_encoding_aliases, 0, 1, MAY_BE_ARRAY|MAY_BE_FALSE)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mb_encoding_aliases, 0, 1, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_encode_mimeheader, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mb_encode_mimeheader, 0, 1, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, charset, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, transfer, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, indent, IS_LONG, 0, "0")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_decode_mimeheader, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mb_decode_mimeheader, 0, 1, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_convert_kana, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mb_convert_kana, 0, 1, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, option, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0)
ZEND_ARG_VARIADIC_INFO(1, vars)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_encode_numericentity, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mb_encode_numericentity, 0, 2, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, convmap, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, is_hex, _IS_BOOL, 0, "false")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_decode_numericentity, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mb_decode_numericentity, 0, 2, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, convmap, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0)
ZEND_END_ARG_INFO()
-#define arginfo_mb_ord arginfo_mb_strwidth
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_ord, 0, 1, MAY_BE_LONG|MAY_BE_FALSE)
+ ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0)
+ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_chr, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, cp, IS_LONG, 0)