summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp9
-rw-r--r--ext/intl/tests/breakiter___construct_error.phpt9
2 files changed, 17 insertions, 1 deletions
diff --git a/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp b/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp
index 476873330d..f17733da24 100644
--- a/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp
+++ b/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp
@@ -37,13 +37,20 @@ static void _php_intlrbbi_constructor_body(INTERNAL_FUNCTION_PARAMETERS)
size_t rules_len;
zend_bool compiled = 0;
UErrorCode status = U_ZERO_ERROR;
- intl_error_reset(NULL);
+ BREAKITER_METHOD_INIT_VARS;
+ object = ZEND_THIS;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b",
&rules, &rules_len, &compiled) == FAILURE) {
RETURN_THROWS();
}
+ BREAKITER_METHOD_FETCH_OBJECT_NO_CHECK;
+ if (bio->biter) {
+ zend_throw_error(NULL, "IntlRuleBasedBreakIterator object is already constructed");
+ RETURN_THROWS();
+ }
+
// instantiation of ICU object
RuleBasedBreakIterator *rbbi;
diff --git a/ext/intl/tests/breakiter___construct_error.phpt b/ext/intl/tests/breakiter___construct_error.phpt
index 57952766ec..7272d8c16b 100644
--- a/ext/intl/tests/breakiter___construct_error.phpt
+++ b/ext/intl/tests/breakiter___construct_error.phpt
@@ -35,6 +35,13 @@ try {
} catch (IntlException $e) {
print_exception($e);
}
+
+$rbbi = new IntlRuleBasedBreakIterator(".;");
+try {
+ $rbbi->__construct(".;");
+} catch (Error $e) {
+ print_exception($e);
+}
?>
--EXPECTF--
Exception: IntlRuleBasedBreakIterator::__construct(): unable to create RuleBasedBreakIterator from rules (parse error on line 1, offset 31) in %s on line %d
@@ -46,3 +53,5 @@ Exception: IntlRuleBasedBreakIterator::__construct() expects at most 2 parameter
Exception: IntlRuleBasedBreakIterator::__construct(): Argument #2 ($areCompiled) must be of type bool, array given in %s on line %d
Exception: IntlRuleBasedBreakIterator::__construct(): unable to create instance from compiled rules in %s on line %d
+
+Exception: IntlRuleBasedBreakIterator object is already constructed in %s on line %d