UCNV_REASON_CASE(CLOSE)
UCNV_REASON_CASE(CLONE)
default:
- php_error_docref(NULL, E_WARNING, "Unknown UConverterCallbackReason: " ZEND_LONG_FMT, reason);
- RETURN_FALSE;
+ zend_argument_value_error(1, "must be a UConverter::REASON_* constant");
+ RETURN_THROWS();
}
}
/* }}} */
/** @return string|false|null */
public function getSubstChars() {}
- /** @return string|false */
+ /** @return string */
public static function reasonText(int $reason) {}
/** @return bool */
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 9eef3fe293c07ab77f4c8b6d8d53a3798f8a9865 */
+ * Stub hash: e33e2614c969c59b79c6062f7a347a8e8e486d85 */
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_UConverter___construct, 0, 0, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, destination_encoding, IS_STRING, 1, "null")
break;
default:
- php_error_docref(NULL, E_WARNING, "Unsupported format type " ZEND_LONG_FMT, type);
- RETURN_FALSE;
- break;
+ zend_argument_value_error(3, "must be a NumberFormatter::TYPE_* constant");
+ RETURN_THROWS();
}
INTL_METHOD_RETVAL_UTF8( nfo, formatted, formatted_len, ( formatted != format_buf ) );
FORMATTER_METHOD_INIT_VARS;
/* Parse parameters. */
- if( zend_parse_method_parameters( ZEND_NUM_ARGS(), getThis(), "Os|lz!",
+ if (zend_parse_method_parameters( ZEND_NUM_ARGS(), getThis(), "Os|lz!",
&object, NumberFormatter_ce_ptr, &str, &str_len, &type, &zposition ) == FAILURE )
{
RETURN_THROWS();
}
- if(zposition) {
+ if (zposition) {
position = (int32_t) zval_get_long(zposition);
position_p = &position;
}
RETVAL_DOUBLE(val_double);
break;
default:
- php_error_docref(NULL, E_WARNING, "Unsupported format type " ZEND_LONG_FMT, type);
- RETVAL_FALSE;
- break;
+ zend_argument_value_error(3, "must be a NumberFormatter::TYPE_* constant");
+ goto cleanup;
+ }
+
+ if (zposition) {
+ ZEND_TRY_ASSIGN_REF_LONG(zposition, position);
}
+
+cleanup:
+
#if ICU_LOCALE_BUG && defined(LC_NUMERIC)
setlocale(LC_NUMERIC, oldlocale);
efree(oldlocale);
#endif
- if(zposition) {
- ZEND_TRY_ASSIGN_REF_LONG(zposition, position);
- }
if (sstr) {
efree(sstr);
}
if ( OUTSIDE_STRING(loffset, haystack_len) ) {
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_strpos: Offset not contained in string", 1 );
- RETURN_FALSE;
+ zend_argument_value_error(3, "must be contained in argument #1 ($haystack)");
+ RETURN_THROWS();
}
/* we checked that it will fit: */
/* the offset is 'grapheme count offset' so it still might be invalid - we'll check it later */
if (needle_len == 0) {
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_strpos: Empty delimiter", 1 );
- RETURN_FALSE;
+ zend_argument_value_error(2, "cannot be empty");
+ RETURN_THROWS();
}
if (offset >= 0) {
} else {
RETURN_FALSE;
}
-
}
/* }}} */
}
if ( OUTSIDE_STRING(loffset, haystack_len) ) {
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_stripos: Offset not contained in string", 1 );
- RETURN_FALSE;
+ zend_argument_value_error(3, "must be contained in argument #1 ($haystack)");
+ RETURN_THROWS();
}
/* we checked that it will fit: */
/* the offset is 'grapheme count offset' so it still might be invalid - we'll check it later */
if (needle_len == 0) {
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_stripos: Empty delimiter", 1 );
- RETURN_FALSE;
+ zend_argument_value_error(2, "cannot be empty");
+ RETURN_THROWS();
}
is_ascii = ( grapheme_ascii_check((unsigned char*)haystack, haystack_len) >= 0 );
}
if ( OUTSIDE_STRING(loffset, haystack_len) ) {
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_strpos: Offset not contained in string", 1 );
- RETURN_FALSE;
+ zend_argument_value_error(3, "must be contained in argument #1 ($haystack)");
+ RETURN_THROWS();
}
/* we checked that it will fit: */
/* the offset is 'grapheme count offset' so it still might be invalid - we'll check it later */
if (needle_len == 0) {
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_strpos: Empty delimiter", 1 );
- RETURN_FALSE;
+ zend_argument_value_error(2, "cannot be empty");
+ RETURN_THROWS();
}
is_ascii = grapheme_ascii_check((unsigned char *)haystack, haystack_len) >= 0;
}
if ( OUTSIDE_STRING(loffset, haystack_len) ) {
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_strpos: Offset not contained in string", 1 );
- RETURN_FALSE;
+ zend_argument_value_error(3, "must be contained in argument #1 ($haystack)");
+ RETURN_THROWS();
}
/* we checked that it will fit: */
/* the offset is 'grapheme count offset' so it still might be invalid - we'll check it later */
if (needle_len == 0) {
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_strpos: Empty delimiter", 1 );
- RETURN_FALSE;
+ zend_argument_value_error(2, "cannot be empty");
+ RETURN_THROWS();
}
is_ascii = grapheme_ascii_check((unsigned char *)haystack, haystack_len) >= 0;
}
if ( OUTSIDE_STRING(lstart, str_len)) {
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_substr: start not contained in string", 1 );
- RETURN_FALSE;
+ zend_argument_value_error(2, "must be contained in argument #1 ($string)");
+ RETURN_THROWS();
}
/* we checked that it will fit: */
if ( UBRK_DONE == sub_str_end_pos) {
if(length < 0) {
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_substr: length not contained in string", 1 );
-
+ zend_argument_value_error(3, "must be contained in argument #1 ($string)");
efree(ustr);
- RETURN_FALSE;
+ RETURN_THROWS();
} else {
sub_str_end_pos = ustr_len;
}
}
if (needle_len == 0) {
-
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_strpos: Empty delimiter", 1 );
-
- RETURN_FALSE;
+ zend_argument_value_error(2, "cannot be empty");
+ RETURN_THROWS();
}
-
if ( !f_ignore_case ) {
/* ASCII optimization: quick check to see if the string might be there
}
if ( extract_type < GRAPHEME_EXTRACT_TYPE_MIN || extract_type > GRAPHEME_EXTRACT_TYPE_MAX ) {
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "grapheme_extract: unknown extract type param", 0 );
- RETURN_FALSE;
+ zend_argument_value_error(3, "must be either GRAPHEME_EXTR_COUNT, GRAPHEME_EXTR_MAXBYTES, or GRAPHEME_EXTR_MAXCHARS");
+ RETURN_THROWS();
}
if ( lstart > INT32_MAX || lstart < 0 || (size_t)lstart >= str_len ) {
RETURN_FALSE;
}
- if ( size > INT32_MAX || size < 0) {
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_extract: size is invalid", 0 );
- RETURN_FALSE;
+ if (size < 0) {
+ zend_argument_value_error(2, "must be greater than or equal to 0");
+ RETURN_THROWS();
}
+
+ if (size > INT32_MAX) {
+ zend_argument_value_error(2, "is too large");
+ RETURN_THROWS();
+ }
+
if (size == 0) {
RETURN_EMPTY_STRING();
}
/* Not grandfathered */
result = append_key_value(loc_name, hash_arr , LOC_LANG_TAG);
if( result == LOC_NOT_FOUND ){
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "locale_compose: parameter array does not contain 'language' tag.", 0 );
+ zend_argument_value_error(1, "must contain a \"%s\" key", LOC_LANG_TAG);
smart_str_free(loc_name);
- RETURN_FALSE;
+ RETURN_THROWS();
}
if( !handleAppendResult( result, loc_name)){
RETURN_FALSE;
/* convert the array to lowercase , also replace hyphens with the underscore and store it in cur_arr */
if(Z_TYPE_P(ele_value)!= IS_STRING) {
/* element value is not a string */
- intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "lookup_loc_range: locale array element is not a string", 0);
+ zend_argument_type_error(2, "must only contain string values");
LOOKUP_CLEAN_RETURN(NULL);
}
cur_arr[cur_arr_len*2] = estrndup(Z_STRVAL_P(ele_value), Z_STRLEN_P(ele_value));
#endif
break;
default:
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "normalizer_normalize: illegal normalization form", 0 );
- RETURN_FALSE;
+ zend_argument_value_error(2, "must be a a valid normalization form");
+ RETURN_THROWS();
}
/*
#endif
break;
default:
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "normalizer_normalize: illegal normalization form", 0 );
- RETURN_FALSE;
+ zend_argument_value_error(2, "must be a a valid normalization form");
+ RETURN_THROWS();
}
}
if (bundlename_len >= MAXPATHLEN) {
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "Bundle name too long", 0 );
- zval_ptr_dtor(return_value);
- ZVAL_NULL(return_value);
+ zend_argument_value_error(2, "is too long");
return FAILURE;
}
}
if (bundlename_len >= MAXPATHLEN) {
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "resourcebundle_locales: bundle name too long", 0 );
- RETURN_FALSE;
+ zend_argument_value_error(1, "is too long");
+ RETURN_THROWS();
}
if(bundlename_len == 0) {
?>
--FILE--
<?php
-var_dump(grapheme_stripos(1,1,2147483648));
-var_dump(grapheme_strpos(1,1,2147483648));
+try {
+ grapheme_stripos(1,1,2147483648);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
+
+try {
+ grapheme_strpos(1,1,2147483648);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
?>
--EXPECT--
-bool(false)
-bool(false)
+grapheme_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
+grapheme_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
--FILE--
<?php
$arr1 = array();
-var_dump(grapheme_extract(-1, -1, -1,-1, $arr1));
+try {
+ grapheme_extract(-1, -1, -1,-1, $arr1);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
?>
--EXPECT--
-bool(false)
+grapheme_extract(): Argument #3 ($extract_type) must be either GRAPHEME_EXTR_COUNT, GRAPHEME_EXTR_MAXBYTES, or GRAPHEME_EXTR_MAXCHARS
$arg0 = urlencode($test[0]);
$res_str .= "substring of \"$arg0\" from \"$test[1]\" - grapheme_substr";
if ( 3 == count( $test ) ) {
- $result = grapheme_substr($test[0], $test[1]);
+ try {
+ $result = grapheme_substr($test[0], $test[1]);
+ } catch (ValueError $exception) {
+ $res_str .= ": " . $exception->getMessage() . "\n";
+ }
}
else {
$res_str .= " with length $test[2]";
- $result = grapheme_substr($test[0], $test[1], $test[2]);
+ try {
+ $result = grapheme_substr($test[0], $test[1], $test[2]);
+ } catch (ValueError $exception) {
+ $res_str .= ": " . $exception->getMessage() . "\n";
+ }
}
$res_str .= " = ";
if ( $result === false ) {
$arg0 = urlencode($test[0]);
$res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_strstr";
if ( 3 == count( $test ) ) {
- $result = grapheme_strstr($test[0], $test[1]);
+ try {
+ $result = grapheme_strstr($test[0], $test[1]);
+ } catch (ValueError $exception) {
+ $res_str .= ": " . $exception->getMessage() . "\n";
+ }
}
else {
$res_str .= " before flag is " . ( $test[2] ? "TRUE" : "FALSE" );
- $result = grapheme_strstr($test[0], $test[1], $test[2]);
+ try {
+ $result = grapheme_strstr($test[0], $test[1], $test[2]);
+ } catch (ValueError $exception) {
+ $res_str .= ": " . $exception->getMessage() . "\n";
+ }
}
$res_str .= " = ";
if ( $result === false ) {
function grapheme_substr($string, $start, $length = -1) {}
-substring of "abc" from "3" - grapheme_substr = false == false
+substring of "abc" from "3" - grapheme_substr: grapheme_substr(): Argument #2 ($start) must be contained in argument #1 ($string)
+ = 3 == false **FAILED**
substring of "aa%CC%8Abco%CC%88" from "5" - grapheme_substr = false == false
substring of "aoa%CC%8Abco%CC%88O" from "2" - grapheme_substr = a%CC%8Abco%CC%88O == a%CC%8Abco%CC%88O
substring of "o%CC%88a%CC%8AaA%CC%8Abc" from "2" - grapheme_substr = aA%CC%8Abc == aA%CC%8Abc
substring of "aa%CC%8AbcO%CC%88" from "4" - grapheme_substr = O%CC%88 == O%CC%88
substring of "o%CC%88aa%CC%8Abc" from "2" - grapheme_substr = a%CC%8Abc == a%CC%8Abc
substring of "aA%CC%8Abc" from "1" - grapheme_substr = A%CC%8Abc == A%CC%8Abc
-substring of "Abc" from "-5" - grapheme_substr = false == false
+substring of "Abc" from "-5" - grapheme_substr: grapheme_substr(): Argument #2 ($start) must be contained in argument #1 ($string)
+ = A%CC%8Abc == false **FAILED**
substring of "a%CC%8Abc" from "3" - grapheme_substr = false == false
-substring of "abc" from "4" - grapheme_substr = false == false
+substring of "abc" from "4" - grapheme_substr: grapheme_substr(): Argument #2 ($start) must be contained in argument #1 ($string)
+ = false == false
substring of "abC" from "2" - grapheme_substr = C == C
substring of "abc" from "1" - grapheme_substr = bc == bc
substring of "Abc" from "1" - grapheme_substr with length 1 = b == b
substring of "abc" from "0" - grapheme_substr with length 2 = ab == ab
-substring of "Abc" from "-4" - grapheme_substr with length 1 = false == false
+substring of "Abc" from "-4" - grapheme_substr with length 1: grapheme_substr(): Argument #2 ($start) must be contained in argument #1 ($string)
+ = ab == false **FAILED**
substring of "ababc" from "1" - grapheme_substr with length 2 = ba == ba
substring of "ababc" from "0" - grapheme_substr with length 10 = ababc == ababc
substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length 10 = aa%CC%8Abco%CC%88Opq == aa%CC%8Abco%CC%88Opq
substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length -6 = aa%CC%8A == aa%CC%8A
substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length -7 = a == a
substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length -8 = ==
-substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length -9 = false == false
+substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length -9: grapheme_substr(): Argument #3 ($length) must be contained in argument #1 ($string)
+ = == false **FAILED**
substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr = aa%CC%8Abco%CC%88Opq == aa%CC%8Abco%CC%88Opq
substring of "aa%CC%8Abco%CC%88Opq" from "-7" - grapheme_substr = a%CC%8Abco%CC%88Opq == a%CC%8Abco%CC%88Opq
substring of "aa%CC%8Abco%CC%88Opq" from "-6" - grapheme_substr = bco%CC%88Opq == bco%CC%88Opq
substring of "aa%CC%8Abco%CC%88Opq" from "-3" - grapheme_substr = Opq == Opq
substring of "aa%CC%8Abco%CC%88Opq" from "-2" - grapheme_substr = pq == pq
substring of "aa%CC%8Abco%CC%88Opq" from "-1" - grapheme_substr = q == q
-substring of "aa%CC%8Abco%CC%88Opq" from "-999" - grapheme_substr = false == false
+substring of "aa%CC%8Abco%CC%88Opq" from "-999" - grapheme_substr: grapheme_substr(): Argument #2 ($start) must be contained in argument #1 ($string)
+ = q == false **FAILED**
substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length 8 = aa%CC%8Abco%CC%88Opq == aa%CC%8Abco%CC%88Opq
substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length 7 = aa%CC%8Abco%CC%88Op == aa%CC%8Abco%CC%88Op
substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length 6 = aa%CC%8Abco%CC%88O == aa%CC%8Abco%CC%88O
substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length 2 = aa%CC%8A == aa%CC%8A
substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length 1 = a == a
substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length 0 = ==
-substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -999 = false == false
+substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -999: grapheme_substr(): Argument #3 ($length) must be contained in argument #1 ($string)
+ = == false **FAILED**
substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -1 = aa%CC%8Abco%CC%88Op == aa%CC%8Abco%CC%88Op
substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -2 = aa%CC%8Abco%CC%88O == aa%CC%8Abco%CC%88O
substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -3 = aa%CC%8Abco%CC%88 == aa%CC%8Abco%CC%88
substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -6 = aa%CC%8A == aa%CC%8A
substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -7 = a == a
substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -8 = ==
-substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -9 = false == false
+substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -9: grapheme_substr(): Argument #3 ($length) must be contained in argument #1 ($string)
+ = == false **FAILED**
function grapheme_strstr($haystack, $needle, $before_needle = FALSE) {}
);
foreach( $tests as $test ) {
- $arg0 = urlencode($test[0]);
- $res_str .= "substring of \"$arg0\" from \"$test[1]\" - grapheme_substr";
- if ( 3 == count( $test ) ) {
- $result = grapheme_substr($test[0], $test[1]);
- }
- else {
- $res_str .= " with length $test[2]";
- $result = grapheme_substr($test[0], $test[1], $test[2]);
- }
- $res_str .= " = ";
- if ( $result === false ) {
- $res_str .= 'false';
- }
- else {
- $res_str .= urlencode($result);
+ try {
+ $arg0 = urlencode($test[0]);
+ $res_str .= "substring of \"$arg0\" from \"$test[1]\" - grapheme_substr";
+ if ( 3 == count( $test ) ) {
+ $result = grapheme_substr($test[0], $test[1]);
+ }
+ else {
+ $res_str .= " with length $test[2]";
+ $result = grapheme_substr($test[0], $test[1], $test[2]);
+ }
+ $res_str .= " = ";
+ if ( $result === false ) {
+ $res_str .= 'false';
+ }
+ else {
+ $res_str .= urlencode($result);
+ }
+ $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n";
+ } catch (ValueError $exception) {
+ $res_str .= ": " . $exception->getMessage() . "\n";
}
- $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n";
}
function grapheme_substr($string, $start, $length = -1) {}
-substring of "abc" from "3" - grapheme_substr = false == false
+substring of "abc" from "3" - grapheme_substr: grapheme_substr(): Argument #2 ($start) must be contained in argument #1 ($string)
substring of "aa%CC%8Abco%CC%88" from "5" - grapheme_substr = false == false
substring of "aoa%CC%8Abco%CC%88O" from "2" - grapheme_substr = a%CC%8Abco%CC%88O == a%CC%8Abco%CC%88O
substring of "o%CC%88a%CC%8AaA%CC%8Abc" from "2" - grapheme_substr = aA%CC%8Abc == aA%CC%8Abc
substring of "aa%CC%8AbcO%CC%88" from "4" - grapheme_substr = O%CC%88 == O%CC%88
substring of "o%CC%88aa%CC%8Abc" from "2" - grapheme_substr = a%CC%8Abc == a%CC%8Abc
substring of "aA%CC%8Abc" from "1" - grapheme_substr = A%CC%8Abc == A%CC%8Abc
-substring of "Abc" from "-5" - grapheme_substr = false == false
+substring of "Abc" from "-5" - grapheme_substr: grapheme_substr(): Argument #2 ($start) must be contained in argument #1 ($string)
substring of "a%CC%8Abc" from "3" - grapheme_substr = false == false
-substring of "abc" from "4" - grapheme_substr = false == false
+substring of "abc" from "4" - grapheme_substr: grapheme_substr(): Argument #2 ($start) must be contained in argument #1 ($string)
substring of "abC" from "2" - grapheme_substr = C == C
substring of "abc" from "1" - grapheme_substr = bc == bc
substring of "Abc" from "1" - grapheme_substr with length 1 = b == b
substring of "abc" from "0" - grapheme_substr with length 2 = ab == ab
-substring of "Abc" from "-4" - grapheme_substr with length 1 = false == false
+substring of "Abc" from "-4" - grapheme_substr with length 1: grapheme_substr(): Argument #2 ($start) must be contained in argument #1 ($string)
substring of "ababc" from "1" - grapheme_substr with length 2 = ba == ba
substring of "ababc" from "0" - grapheme_substr with length 10 = ababc == ababc
substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length 10 = aa%CC%8Abco%CC%88Opq == aa%CC%8Abco%CC%88Opq
substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length -6 = aa%CC%8A == aa%CC%8A
substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length -7 = a == a
substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length -8 = ==
-substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length -9 = false == false
+substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length -9: grapheme_substr(): Argument #3 ($length) must be contained in argument #1 ($string)
substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr = aa%CC%8Abco%CC%88Opq == aa%CC%8Abco%CC%88Opq
substring of "aa%CC%8Abco%CC%88Opq" from "-7" - grapheme_substr = a%CC%8Abco%CC%88Opq == a%CC%8Abco%CC%88Opq
substring of "aa%CC%8Abco%CC%88Opq" from "-6" - grapheme_substr = bco%CC%88Opq == bco%CC%88Opq
substring of "aa%CC%8Abco%CC%88Opq" from "-3" - grapheme_substr = Opq == Opq
substring of "aa%CC%8Abco%CC%88Opq" from "-2" - grapheme_substr = pq == pq
substring of "aa%CC%8Abco%CC%88Opq" from "-1" - grapheme_substr = q == q
-substring of "aa%CC%8Abco%CC%88Opq" from "-999" - grapheme_substr = false == false
+substring of "aa%CC%8Abco%CC%88Opq" from "-999" - grapheme_substr: grapheme_substr(): Argument #2 ($start) must be contained in argument #1 ($string)
substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length 8 = aa%CC%8Abco%CC%88Opq == aa%CC%8Abco%CC%88Opq
substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length 7 = aa%CC%8Abco%CC%88Op == aa%CC%8Abco%CC%88Op
substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length 6 = aa%CC%8Abco%CC%88O == aa%CC%8Abco%CC%88O
substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length 2 = aa%CC%8A == aa%CC%8A
substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length 1 = a == a
substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length 0 = ==
-substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -999 = false == false
+substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -999: grapheme_substr(): Argument #3 ($length) must be contained in argument #1 ($string)
substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -1 = aa%CC%8Abco%CC%88Op == aa%CC%8Abco%CC%88Op
substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -2 = aa%CC%8Abco%CC%88O == aa%CC%8Abco%CC%88O
substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -3 = aa%CC%8Abco%CC%88 == aa%CC%8Abco%CC%88
substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -6 = aa%CC%8A == aa%CC%8A
substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -7 = a == a
substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -8 = ==
-substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -9 = false == false
+substring of "aa%CC%8Abco%CC%88Opq" from "-8" - grapheme_substr with length -9: grapheme_substr(): Argument #3 ($length) must be contained in argument #1 ($string)
function grapheme_strstr($haystack, $needle, $before_needle = FALSE) {}
--- /dev/null
+--TEST--
+Test grapheme_strpos-alike functions with empty needle
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+ini_set("intl.error_level", E_WARNING);
+
+try {
+ var_dump(grapheme_strpos("abc", "", -1));
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
+
+try {
+ var_dump(grapheme_strpos("abc", ""));
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
+
+try {
+ var_dump(grapheme_strpos("abc", "", -1));
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
+
+try {
+ var_dump(grapheme_stripos("abc", ""));
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
+
+try {
+ var_dump(grapheme_stripos("abc", "", -1));
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
+
+try {
+ var_dump(grapheme_strrpos("abc", ""));
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
+
+try {
+ var_dump(grapheme_strrpos("abc", "", -1));
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
+
+try {
+ var_dump(grapheme_strripos("abc", ""));
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
+
+try {
+ var_dump(grapheme_strripos("abc", "", 1));
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
+
+try {
+ var_dump(grapheme_strstr("abc", ""));
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
+
+try {
+ var_dump(grapheme_stristr("abc", ""));
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
+
+?>
+--EXPECT--
+grapheme_strpos(): Argument #2 ($needle) cannot be empty
+grapheme_strpos(): Argument #2 ($needle) cannot be empty
+grapheme_strpos(): Argument #2 ($needle) cannot be empty
+grapheme_stripos(): Argument #2 ($needle) cannot be empty
+grapheme_stripos(): Argument #2 ($needle) cannot be empty
+grapheme_strrpos(): Argument #2 ($needle) cannot be empty
+grapheme_strrpos(): Argument #2 ($needle) cannot be empty
+grapheme_strripos(): Argument #2 ($needle) cannot be empty
+grapheme_strripos(): Argument #2 ($needle) cannot be empty
+grapheme_strstr(): Argument #2 ($needle) cannot be empty
+grapheme_stristr(): Argument #2 ($needle) cannot be empty
$res_str .= $valKey ."->".$valValue." " ;
}
*/
-
- $locale = ut_loc_locale_compose( $value);
- $res_str .= "\n\nComposed Locale: ";
- if( $locale){
- $res_str .= "$locale";
- }else{
- $res_str .= "No values found from Locale compose due to the following error:\n";
- $res_str .= intl_get_error_message() ;
+ try {
+ $locale = ut_loc_locale_compose( $value);
+ $res_str .= "\n\nComposed Locale: ";
+ if( $locale){
+ $res_str .= "$locale";
+ }else{
+ $res_str .= "No values found from Locale compose due to the following error:\n";
+ $res_str .= intl_get_error_message() ;
+ }
+ } catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
}
}
?>
--EXPECT--
+Locale::composeLocale(): Argument #1 ($subtags) must contain a "language" key
+locale_compose(): Argument #1 ($subtags) must contain a "language" key
+
------------
Input Array name is : loc1
Composed Locale: en_lng_ing_Hans_CN_nedis_rozaj_x_prv1_prv2
------------
Input Array name is : loc9
-
-Composed Locale: No values found from Locale compose due to the following error:
-locale_compose: parameter array does not contain 'language' tag.: U_ILLEGAL_ARGUMENT_ERROR
------------
Input Array name is : loc10
//Arguments
var_dump(transliterator_transliterate($tr,"str",7));
-var_dump(transliterator_transliterate($tr,"str",7,6));
+
+try {
+ transliterator_transliterate($tr,"str",7,6);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
//bad UTF-8
transliterator_transliterate($tr, "\x80\x03");
--EXPECTF--
Warning: transliterator_transliterate(): transliterator_transliterate: Neither "start" nor the "end" arguments can exceed the number of UTF-16 code units (in this case, 3) in %s on line %d
bool(false)
-
-Warning: transliterator_transliterate(): transliterator_transliterate: "start" argument should be non-negative and not bigger than "end" (if defined) in %s on line %d
-bool(false)
+transliterator_transliterate(): Argument #2 ($subject) must be less than or equal to argument #3 ($end)
Warning: transliterator_transliterate(): String conversion of string to UTF-16 failed in %s on line %d
Done.
else
{
/* We shouldn't have unconstructed objects in the first place */
- php_error_docref( NULL, E_WARNING,
- "Cloning unconstructed transliterator." );
+ zend_throw_error(NULL, "Unconstructed Transliterator object cannot be cloned");
}
return ret_val;
( zend_binary_strcmp( "id", sizeof( "id" ) - 1,
ZSTR_VAL( name ), ZSTR_LEN( name ) ) == 0 ) )
{
- php_error_docref(NULL, E_WARNING, "The property \"id\" is read-only" );
+ zend_throw_error(NULL, "Transliterator::$id is read-only");
retval = &EG( uninitialized_zval );
}
else
( zend_binary_strcmp( "id", sizeof( "id" ) - 1,
ZSTR_VAL( name ), ZSTR_LEN( name ) ) == 0 ) )
{
- php_error_docref(NULL, E_WARNING, "The property \"id\" is read-only" );
+ zend_throw_error(NULL, "Transliterator::$id is read-only");
}
else
{
if( ( direction != TRANSLITERATOR_FORWARD ) && (direction != TRANSLITERATOR_REVERSE ) )
{
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "transliterator_create: invalid direction", 0 );
+ zend_argument_value_error(2, "must be either Transliterator::FORWARD or Transliterator::REVERSE");
return FAILURE;
}
if( ( direction != TRANSLITERATOR_FORWARD ) && (direction != TRANSLITERATOR_REVERSE ) )
{
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "transliterator_create_from_rules: invalid direction", 0 );
- RETURN_NULL();
+ zend_argument_value_error(2, "must be either Transliterator::FORWARD or Transliterator::REVERSE");
+ RETURN_THROWS();
}
object = return_value;
res = create_transliterator(ZSTR_VAL(arg1_str), ZSTR_LEN(arg1_str), TRANSLITERATOR_FORWARD, object);
if( res == FAILURE )
{
- zend_string *message = intl_error_get_message( NULL );
- php_error_docref(NULL, E_WARNING, "Could not create "
- "transliterator with ID \"%s\" (%s)", ZSTR_VAL(arg1_str), ZSTR_VAL(message) );
- zend_string_free( message );
+ if (!EG(exception)) {
+ zend_string *message = intl_error_get_message( NULL );
+ php_error_docref(NULL, E_WARNING, "Could not create transliterator with ID \"%s\" (%s)", ZSTR_VAL(arg1_str), ZSTR_VAL(message) );
+ zend_string_free( message );
+ }
ZVAL_UNDEF(&tmp_object);
/* don't set U_ILLEGAL_ARGUMENT_ERROR to allow fetching of inner error */
goto cleanup;
RETURN_THROWS();
}
- if( limit < -1 )
- {
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "transliterator_transliterate: \"end\" argument should be "
- "either non-negative or -1", 0 );
- RETVAL_FALSE;
+ if (limit < -1) {
+ zend_argument_value_error(object ? 3 : 4, "must be greater than or equal to -1");
goto cleanup_object;
}
- if( start < 0 || ((limit != -1 ) && (start > limit )) )
- {
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "transliterator_transliterate: \"start\" argument should be "
- "non-negative and not bigger than \"end\" (if defined)", 0 );
- RETVAL_FALSE;
+ if (start < 0) {
+ zend_argument_value_error(object ? 2 : 3, "must be greater than or equal to 0");
+ goto cleanup_object;
+ }
+
+ if (limit != -1 && start > limit) {
+ zend_argument_value_error(object ? 2 : 3, "must be less than or equal to argument #%d ($end)", object ? 3 : 4);
goto cleanup_object;
}
msg, 1 );
efree( msg );
}
- RETVAL_FALSE;
goto cleanup;
}