summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2015-03-30 18:53:38 +0300
committerDmitry Stogov <dmitry@zend.com>2015-03-30 18:53:38 +0300
commit1018f462d8bb0a12b238d9d11c141038beaf2a6c (patch)
tree6466aa51c3924c5ed56741e02fa323fcb3e2ece4
parent9155a267adeeb6f442f97892de441e4b6666ce73 (diff)
downloadphp-git-1018f462d8bb0a12b238d9d11c141038beaf2a6c.tar.gz
Patch improvement:
Removed the corresponding core code. Fixed ext/com_dotnet and ext/date. Refactored ext/intl changes. Improved ext/fileinfo and ext/pdo changes. Fixed tests.
-rw-r--r--Zend/zend_API.c9
-rw-r--r--Zend/zend_API.h6
-rw-r--r--Zend/zend_vm_def.h7
-rw-r--r--Zend/zend_vm_execute.h38
-rw-r--r--ext/com_dotnet/com_com.c2
-rw-r--r--ext/com_dotnet/com_dotnet.c3
-rw-r--r--ext/date/php_date.c10
-rw-r--r--ext/fileinfo/fileinfo.c55
-rw-r--r--ext/fileinfo/tests/bug61173.phpt7
-rw-r--r--ext/fileinfo/tests/finfo_open_error.phpt8
-rw-r--r--ext/intl/breakiterator/breakiterator_methods.cpp4
-rw-r--r--ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp11
-rw-r--r--ext/intl/calendar/gregoriancalendar_methods.cpp51
-rw-r--r--ext/intl/collator/collator_create.c22
-rw-r--r--ext/intl/converter/converter.c6
-rw-r--r--ext/intl/dateformat/dateformat_create.cpp31
-rw-r--r--ext/intl/formatter/formatter_main.c24
-rw-r--r--ext/intl/intl_data.h4
-rw-r--r--ext/intl/intl_error.c55
-rw-r--r--ext/intl/intl_error.h6
-rw-r--r--ext/intl/msgformat/msgformat.c26
-rw-r--r--ext/intl/msgformat/msgformat_class.c4
-rw-r--r--ext/intl/resourcebundle/resourcebundle_class.c25
-rw-r--r--ext/intl/spoofchecker/spoofchecker_create.c7
-rw-r--r--ext/intl/tests/breakiter___construct_error.phpt56
-rw-r--r--ext/intl/tests/bug62017.phpt12
-rw-r--r--ext/intl/tests/bug62081.phpt7
-rw-r--r--ext/intl/tests/dateformat___construct_bad_tz_cal.phpt35
-rw-r--r--ext/intl/tests/dateformat_calendars_variant2.phpt7
-rw-r--r--ext/intl/tests/formatter_fail.phpt71
-rw-r--r--ext/intl/tests/formatter_format.phpt9
-rw-r--r--ext/intl/tests/gregoriancalendar___construct_error.phpt26
-rw-r--r--ext/intl/tests/msgfmt_fail.phpt78
-rw-r--r--ext/intl/tests/msgfmt_fail2.phpt43
-rw-r--r--ext/intl/tests/msgfmt_parse.phpt14
-rw-r--r--ext/intl/tests/resourcebundle_create.phpt29
-rw-r--r--ext/intl/tests/ut_common.inc20
-rw-r--r--ext/intl/transliterator/transliterator_methods.c8
-rw-r--r--ext/pdo/pdo_dbh.c34
-rw-r--r--ext/pdo/pdo_stmt.c6
-rw-r--r--ext/pdo/tests/pdo_036.phpt37
-rw-r--r--ext/pdo/tests/pdorow.phpt22
-rw-r--r--ext/pdo_mysql/tests/pdo_mysql___construct.phpt7
-rw-r--r--ext/pdo_mysql/tests/pdo_mysql___construct_options.phpt7
-rw-r--r--ext/pdo_mysql/tests/pdo_mysql___construct_uri.phpt3
-rw-r--r--ext/phar/phar_object.c2
-rw-r--r--ext/phar/tests/badparameters.phpt31
-rw-r--r--ext/phar/tests/bug60261.phpt8
-rw-r--r--ext/phar/tests/pharfileinfo_construct.phpt10
-rw-r--r--ext/reflection/php_reflection.c2
50 files changed, 504 insertions, 501 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index e6f94798d0..4295159c7b 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -4128,15 +4128,6 @@ ZEND_API zend_string *zend_resolve_method_name(zend_class_entry *ce, zend_functi
}
/* }}} */
-ZEND_API void zend_ctor_make_null(zend_execute_data *execute_data) /* {{{ */
-{
- if (EX(return_value)) {
- Z_OBJ_P(EX(return_value)) = NULL;
- ZVAL_NULL(EX(return_value));
- }
-}
-/* }}} */
-
ZEND_API const char *zend_get_object_type(const zend_class_entry *ce) /* {{{ */
{
if(ce->ce_flags & ZEND_ACC_TRAIT) {
diff --git a/Zend/zend_API.h b/Zend/zend_API.h
index 694c818f60..b70dd26ef8 100644
--- a/Zend/zend_API.h
+++ b/Zend/zend_API.h
@@ -538,8 +538,6 @@ ZEND_API int zend_set_local_var_str(const char *name, size_t len, zval *value, i
ZEND_API zend_string *zend_find_alias_name(zend_class_entry *ce, zend_string *name);
ZEND_API zend_string *zend_resolve_method_name(zend_class_entry *ce, zend_function *f);
-ZEND_API void zend_ctor_make_null(zend_execute_data *execute_data);
-
ZEND_API const char *zend_get_object_type(const zend_class_entry *ce);
#define add_method(arg, key, method) add_assoc_function((arg), (key), (method))
@@ -651,10 +649,6 @@ END_EXTERN_C()
} \
} while (0)
-/* May be used in internal constructors to make them return NULL */
-#define ZEND_CTOR_MAKE_NULL() \
- zend_ctor_make_null(execute_data)
-
#define RETURN_ZVAL_FAST(z) { RETVAL_ZVAL_FAST(z); return; }
#define HASH_OF(p) (Z_TYPE_P(p)==IS_ARRAY ? Z_ARRVAL_P(p) : ((Z_TYPE_P(p)==IS_OBJECT ? Z_OBJ_HT_P(p)->get_properties((p)) : NULL)))
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index 8c1f1b4a8f..7dcad6c379 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -2950,10 +2950,6 @@ ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_METHOD_CALL, CONST|VAR, CONST|TMPVAR|UNUSE
EX(call) = zend_vm_stack_push_call_frame(ZEND_CALL_NESTED_FUNCTION,
fbc, opline->extended_value, ce, object, EX(call));
- if (OP2_TYPE == IS_UNUSED) {
- EX(call)->return_value = NULL;
- }
-
CHECK_EXCEPTION();
ZEND_VM_NEXT_OPCODE();
}
@@ -4704,9 +4700,6 @@ ZEND_VM_HANDLER(68, ZEND_NEW, CONST|VAR, ANY)
if (EXPECTED(RETURN_VALUE_USED(opline))) {
ZVAL_COPY(EX_VAR(opline->result.var), &object_zval);
- EX(call)->return_value = EX_VAR(opline->result.var);
- } else {
- EX(call)->return_value = NULL;
}
CHECK_EXCEPTION();
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index 31ee053ef4..c628928cd4 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -3100,9 +3100,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_NEW_SPEC_CONST_HANDLER(ZEND_OP
if (EXPECTED(RETURN_VALUE_USED(opline))) {
ZVAL_COPY(EX_VAR(opline->result.var), &object_zval);
- EX(call)->return_value = EX_VAR(opline->result.var);
- } else {
- EX(call)->return_value = NULL;
}
CHECK_EXCEPTION();
@@ -5082,10 +5079,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_C
EX(call) = zend_vm_stack_push_call_frame(ZEND_CALL_NESTED_FUNCTION,
fbc, opline->extended_value, ce, object, EX(call));
- if (IS_CONST == IS_UNUSED) {
- EX(call)->return_value = NULL;
- }
-
CHECK_EXCEPTION();
ZEND_VM_NEXT_OPCODE();
}
@@ -6984,10 +6977,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_C
EX(call) = zend_vm_stack_push_call_frame(ZEND_CALL_NESTED_FUNCTION,
fbc, opline->extended_value, ce, object, EX(call));
- if (IS_UNUSED == IS_UNUSED) {
- EX(call)->return_value = NULL;
- }
-
CHECK_EXCEPTION();
ZEND_VM_NEXT_OPCODE();
}
@@ -8466,10 +8455,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_C
EX(call) = zend_vm_stack_push_call_frame(ZEND_CALL_NESTED_FUNCTION,
fbc, opline->extended_value, ce, object, EX(call));
- if (IS_CV == IS_UNUSED) {
- EX(call)->return_value = NULL;
- }
-
CHECK_EXCEPTION();
ZEND_VM_NEXT_OPCODE();
}
@@ -10015,10 +10000,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_C
EX(call) = zend_vm_stack_push_call_frame(ZEND_CALL_NESTED_FUNCTION,
fbc, opline->extended_value, ce, object, EX(call));
- if ((IS_TMP_VAR|IS_VAR) == IS_UNUSED) {
- EX(call)->return_value = NULL;
- }
-
CHECK_EXCEPTION();
ZEND_VM_NEXT_OPCODE();
}
@@ -13795,9 +13776,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_NEW_SPEC_VAR_HANDLER(ZEND_OPCO
if (EXPECTED(RETURN_VALUE_USED(opline))) {
ZVAL_COPY(EX_VAR(opline->result.var), &object_zval);
- EX(call)->return_value = EX_VAR(opline->result.var);
- } else {
- EX(call)->return_value = NULL;
}
CHECK_EXCEPTION();
@@ -15880,10 +15858,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_V
EX(call) = zend_vm_stack_push_call_frame(ZEND_CALL_NESTED_FUNCTION,
fbc, opline->extended_value, ce, object, EX(call));
- if (IS_CONST == IS_UNUSED) {
- EX(call)->return_value = NULL;
- }
-
CHECK_EXCEPTION();
ZEND_VM_NEXT_OPCODE();
}
@@ -17455,10 +17429,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_V
EX(call) = zend_vm_stack_push_call_frame(ZEND_CALL_NESTED_FUNCTION,
fbc, opline->extended_value, ce, object, EX(call));
- if (IS_UNUSED == IS_UNUSED) {
- EX(call)->return_value = NULL;
- }
-
CHECK_EXCEPTION();
ZEND_VM_NEXT_OPCODE();
}
@@ -19072,10 +19042,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_V
EX(call) = zend_vm_stack_push_call_frame(ZEND_CALL_NESTED_FUNCTION,
fbc, opline->extended_value, ce, object, EX(call));
- if (IS_CV == IS_UNUSED) {
- EX(call)->return_value = NULL;
- }
-
CHECK_EXCEPTION();
ZEND_VM_NEXT_OPCODE();
}
@@ -20631,10 +20597,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_V
EX(call) = zend_vm_stack_push_call_frame(ZEND_CALL_NESTED_FUNCTION,
fbc, opline->extended_value, ce, object, EX(call));
- if ((IS_TMP_VAR|IS_VAR) == IS_UNUSED) {
- EX(call)->return_value = NULL;
- }
-
CHECK_EXCEPTION();
ZEND_VM_NEXT_OPCODE();
}
diff --git a/ext/com_dotnet/com_com.c b/ext/com_dotnet/com_com.c
index d61d933e7a..80ef70e7e0 100644
--- a/ext/com_dotnet/com_com.c
+++ b/ext/com_dotnet/com_com.c
@@ -66,7 +66,6 @@ PHP_FUNCTION(com_create_instance)
&typelib_name, &typelib_name_len)) {
php_com_throw_exception(E_INVALIDARG, "Could not create COM object - invalid arguments!");
- ZEND_CTOR_MAKE_NULL();
return;
}
@@ -230,7 +229,6 @@ PHP_FUNCTION(com_create_instance)
php_com_throw_exception(res, msg);
efree(msg);
- ZEND_CTOR_MAKE_NULL();
return;
}
diff --git a/ext/com_dotnet/com_dotnet.c b/ext/com_dotnet/com_dotnet.c
index 974876a853..7e0124b062 100644
--- a/ext/com_dotnet/com_dotnet.c
+++ b/ext/com_dotnet/com_dotnet.c
@@ -208,7 +208,6 @@ PHP_FUNCTION(com_dotnet_create_instance)
if (err)
LocalFree(err);
php_com_throw_exception(hr, buf);
- ZEND_CTOR_MAKE_NULL();
return;
}
stuff = (struct dotnet_runtime_stuff*)COMG(dotnet_runtime_stuff);
@@ -248,7 +247,6 @@ PHP_FUNCTION(com_dotnet_create_instance)
&datatype_name, &datatype_name_len,
&obj->code_page)) {
php_com_throw_exception(E_INVALIDARG, "Could not create .Net object - invalid arguments!");
- ZEND_CTOR_MAKE_NULL();
return;
}
@@ -314,7 +312,6 @@ PHP_FUNCTION(com_dotnet_create_instance)
LocalFree(err);
}
php_com_throw_exception(hr, buf);
- ZEND_CTOR_MAKE_NULL();
return;
}
}
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 94d3a19bcd..0021483de1 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -2670,9 +2670,7 @@ PHP_METHOD(DateTime, __construct)
zend_replace_error_handling(EH_THROW, NULL, &error_handling);
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|sO!", &time_str, &time_str_len, &timezone_object, date_ce_timezone)) {
- if (!php_date_initialize(Z_PHPDATE_P(getThis()), time_str, time_str_len, NULL, timezone_object, 1)) {
- ZEND_CTOR_MAKE_NULL();
- }
+ php_date_initialize(Z_PHPDATE_P(getThis()), time_str, time_str_len, NULL, timezone_object, 1);
}
zend_restore_error_handling(&error_handling);
}
@@ -3679,9 +3677,7 @@ PHP_METHOD(DateTimeZone, __construct)
zend_replace_error_handling(EH_THROW, NULL, &error_handling);
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "s", &tz, &tz_len)) {
tzobj = Z_PHPTIMEZONE_P(getThis());
- if (FAILURE == timezone_initialize(tzobj, tz)) {
- ZEND_CTOR_MAKE_NULL();
- }
+ timezone_initialize(tzobj, tz);
}
zend_restore_error_handling(&error_handling);
}
@@ -4113,8 +4109,6 @@ PHP_METHOD(DateInterval, __construct)
diobj = Z_PHPINTERVAL_P(getThis());
diobj->diff = reltime;
diobj->initialized = 1;
- } else {
- ZEND_CTOR_MAKE_NULL();
}
}
zend_restore_error_handling(&error_handling);
diff --git a/ext/fileinfo/fileinfo.c b/ext/fileinfo/fileinfo.c
index 33c67d1ec1..075397105b 100644
--- a/ext/fileinfo/fileinfo.c
+++ b/ext/fileinfo/fileinfo.c
@@ -282,15 +282,6 @@ PHP_MINFO_FUNCTION(fileinfo)
}
/* }}} */
-#define FILEINFO_DESTROY_OBJECT(object) \
- do { \
- if (object) { \
- zend_object_store_ctor_failed(Z_OBJ_P(object)); \
- Z_OBJ_P(object) = NULL; \
- ZEND_CTOR_MAKE_NULL(); \
- } \
- } while (0)
-
/* {{{ proto resource finfo_open([int options [, string arg]])
Create a new fileinfo resource. */
PHP_FUNCTION(finfo_open)
@@ -302,18 +293,17 @@ PHP_FUNCTION(finfo_open)
FILEINFO_DECLARE_INIT_OBJECT(object)
char resolved_path[MAXPATHLEN];
zend_error_handling zeh;
- int rv;
if (object) {
- zend_replace_error_handling(EH_THROW, NULL, &zeh TSRMLS_CC);
- rv = zend_parse_parameters(ZEND_NUM_ARGS(), "|lp", &options, &file, &file_len);
- zend_restore_error_handling(&zeh TSRMLS_CC);
- } else {
- rv = zend_parse_parameters(ZEND_NUM_ARGS(), "|lp", &options, &file, &file_len);
+ zend_replace_error_handling(EH_THROW, NULL, &zeh);
}
-
- if (rv == FAILURE) {
- FILEINFO_DESTROY_OBJECT(object);
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|lp", &options, &file, &file_len) == FAILURE) {
+ if (object) {
+ zend_restore_error_handling(&zeh);
+ if (!EG(exception)) {
+ zend_throw_exception(NULL, "Constructor failed", 0);
+ }
+ }
RETURN_FALSE;
}
@@ -332,11 +322,21 @@ PHP_FUNCTION(finfo_open)
} else if (file && *file) { /* user specified file, perform open_basedir checks */
if (php_check_open_basedir(file)) {
- FILEINFO_DESTROY_OBJECT(object);
+ if (object) {
+ zend_restore_error_handling(&zeh);
+ if (!EG(exception)) {
+ zend_throw_exception(NULL, "Constructor failed", 0);
+ }
+ }
RETURN_FALSE;
}
if (!expand_filepath_with_mode(file, resolved_path, NULL, 0, CWD_EXPAND)) {
- FILEINFO_DESTROY_OBJECT(object);
+ if (object) {
+ zend_restore_error_handling(&zeh);
+ if (!EG(exception)) {
+ zend_throw_exception(NULL, "Constructor failed", 0);
+ }
+ }
RETURN_FALSE;
}
file = resolved_path;
@@ -350,7 +350,12 @@ PHP_FUNCTION(finfo_open)
if (finfo->magic == NULL) {
efree(finfo);
php_error_docref(NULL, E_WARNING, "Invalid mode '%pd'.", options);
- FILEINFO_DESTROY_OBJECT(object);
+ if (object) {
+ zend_restore_error_handling(&zeh);
+ if (!EG(exception)) {
+ zend_throw_exception(NULL, "Constructor failed", 0);
+ }
+ }
RETURN_FALSE;
}
@@ -358,11 +363,17 @@ PHP_FUNCTION(finfo_open)
php_error_docref(NULL, E_WARNING, "Failed to load magic database at '%s'.", file);
magic_close(finfo->magic);
efree(finfo);
- FILEINFO_DESTROY_OBJECT(object);
+ if (object) {
+ zend_restore_error_handling(&zeh);
+ if (!EG(exception)) {
+ zend_throw_exception(NULL, "Constructor failed", 0);
+ }
+ }
RETURN_FALSE;
}
if (object) {
+ zend_restore_error_handling(&zeh);
FILEINFO_REGISTER_OBJECT(object, finfo);
} else {
RETURN_RES(zend_register_resource(finfo, le_fileinfo));
diff --git a/ext/fileinfo/tests/bug61173.phpt b/ext/fileinfo/tests/bug61173.phpt
index 521176fe76..838faf5b7d 100644
--- a/ext/fileinfo/tests/bug61173.phpt
+++ b/ext/fileinfo/tests/bug61173.phpt
@@ -10,5 +10,8 @@ if (!class_exists('finfo'))
$finfo = new finfo(1, '', false);
var_dump($finfo);
--EXPECTF--
-Warning: finfo::finfo() expects at most 2 parameters, 3 given in %s on line %d
-NULL
+Fatal error: Uncaught exception 'Exception' with message 'finfo::finfo() expects at most 2 parameters, 3 given' in %sbug61173.php:3
+Stack trace:
+#0 %sbug61173.php(3): finfo->finfo(1, '', false)
+#1 {main}
+ thrown in %sbug61173.php on line 3
diff --git a/ext/fileinfo/tests/finfo_open_error.phpt b/ext/fileinfo/tests/finfo_open_error.phpt
index ed43a8b453..d02be60e31 100644
--- a/ext/fileinfo/tests/finfo_open_error.phpt
+++ b/ext/fileinfo/tests/finfo_open_error.phpt
@@ -46,6 +46,8 @@ resource(6) of type (file_info)
Warning: finfo_open() expects parameter 1 to be integer, string given in %sfinfo_open_error.php on line 16
bool(false)
-Warning: finfo::finfo() expects parameter 1 to be integer, string given in %sfinfo_open_error.php on line 18
-NULL
-===DONE===
+Fatal error: Uncaught exception 'Exception' with message 'finfo::finfo() expects parameter 1 to be integer, string given' in %sfinfo_open_error.php:18
+Stack trace:
+#0 %sfinfo_open_error.php(18): finfo->finfo('foobar')
+#1 {main}
+ thrown in %sfinfo_open_error.php on line 18
diff --git a/ext/intl/breakiterator/breakiterator_methods.cpp b/ext/intl/breakiterator/breakiterator_methods.cpp
index 02d228653a..baab5a682d 100644
--- a/ext/intl/breakiterator/breakiterator_methods.cpp
+++ b/ext/intl/breakiterator/breakiterator_methods.cpp
@@ -162,12 +162,12 @@ U_CFUNC PHP_FUNCTION(breakiter_set_text)
BREAKITER_METHOD_FETCH_OBJECT;
ut = utext_openUTF8(ut, text->val, text->len, BREAKITER_ERROR_CODE_P(bio));
- INTL_CTOR_CHECK_STATUS(bio, "breakiter_set_text: error opening UText", 0);
+ INTL_CTOR_CHECK_STATUS(bio, "breakiter_set_text: error opening UText");
bio->biter->setText(ut, BREAKITER_ERROR_CODE(bio));
utext_close(ut); /* ICU shallow clones the UText */
INTL_CTOR_CHECK_STATUS(bio, "breakiter_set_text: error calling "
- "BreakIterator::setText()", 0);
+ "BreakIterator::setText()");
/* When ICU clones the UText, it does not copy the buffer, so we have to
* keep the string buffer around by holding a reference to its zval. This
diff --git a/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp b/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp
index c112134124..b43f8212d0 100644
--- a/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp
+++ b/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp
@@ -24,6 +24,7 @@ extern "C" {
}
#include "../intl_convertcpp.h"
+#include "../intl_common.h"
static inline RuleBasedBreakIterator *fetch_rbbi(BreakIterator_object *bio) {
return (RuleBasedBreakIterator*)bio->biter;
@@ -97,15 +98,17 @@ static void _php_intlrbbi_constructor_body(INTERNAL_FUNCTION_PARAMETERS)
U_CFUNC PHP_METHOD(IntlRuleBasedBreakIterator, __construct)
{
- zval orig_this = *getThis();
+ zend_error_handling error_handling;
+ zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, &error_handling);
return_value = getThis();
_php_intlrbbi_constructor_body(INTERNAL_FUNCTION_PARAM_PASSTHRU);
-
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
- zend_object_store_ctor_failed(Z_OBJ(orig_this));
- ZEND_CTOR_MAKE_NULL();
+ if (!EG(exception)) {
+ zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0);
+ }
}
+ zend_restore_error_handling(&error_handling);
}
U_CFUNC PHP_FUNCTION(rbbi_get_rules)
diff --git a/ext/intl/calendar/gregoriancalendar_methods.cpp b/ext/intl/calendar/gregoriancalendar_methods.cpp
index 69bae08e06..d9572a0668 100644
--- a/ext/intl/calendar/gregoriancalendar_methods.cpp
+++ b/ext/intl/calendar/gregoriancalendar_methods.cpp
@@ -25,18 +25,20 @@
#include <unicode/gregocal.h>
extern "C" {
#include "../php_intl.h"
+#include "../intl_common.h"
#define USE_TIMEZONE_POINTER 1
#include "../timezone/timezone_class.h"
#define USE_CALENDAR_POINTER 1
#include "calendar_class.h"
#include <ext/date/php_date.h>
+#include "zend_exceptions.h"
}
static inline GregorianCalendar *fetch_greg(Calendar_object *co) {
return (GregorianCalendar*)co->ucal;
}
-static void _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
+static void _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAMETERS)
{
zval *tz_object = NULL;
zval args_a[6] = {0},
@@ -51,8 +53,8 @@ static void _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAMETERS, zend
// parameter number validation / variant determination
if (ZEND_NUM_ARGS() > 6 ||
zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) {
- intl_error_set_ex(NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "intlgregcal_create_instance: too many arguments", 0, is_constructor);
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlgregcal_create_instance: too many arguments", 0);
Z_OBJ_P(return_value) = NULL;
return;
}
@@ -60,9 +62,9 @@ static void _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAMETERS, zend
variant > 0 && Z_TYPE(args[variant - 1]) == IS_NULL;
variant--) {}
if (variant == 4) {
- intl_error_set_ex(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"intlgregcal_create_instance: no variant with 4 arguments "
- "(excluding trailing NULLs)", 0, is_constructor);
+ "(excluding trailing NULLs)", 0);
Z_OBJ_P(return_value) = NULL;
return;
}
@@ -71,8 +73,8 @@ static void _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAMETERS, zend
if (variant <= 2) {
if (zend_parse_parameters(MIN(ZEND_NUM_ARGS(), 2),
"|z!s!", &tz_object, &locale, &locale_len) == FAILURE) {
- intl_error_set_ex(NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "intlgregcal_create_instance: bad arguments", 0, is_constructor);
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlgregcal_create_instance: bad arguments", 0);
Z_OBJ_P(return_value) = NULL;
return;
}
@@ -80,8 +82,8 @@ static void _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAMETERS, zend
if (variant > 2 && zend_parse_parameters(ZEND_NUM_ARGS(),
"lll|lll", &largs[0], &largs[1], &largs[2], &largs[3], &largs[4],
&largs[5]) == FAILURE) {
- intl_error_set_ex(NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "intlgregcal_create_instance: bad arguments", 0, is_constructor);
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlgregcal_create_instance: bad arguments", 0);
Z_OBJ_P(return_value) = NULL;
return;
}
@@ -104,8 +106,8 @@ static void _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAMETERS, zend
gcal = new GregorianCalendar(tz, Locale::createFromName(locale),
status);
if (U_FAILURE(status)) {
- intl_error_set_ex(NULL, status, "intlgregcal_create_instance: error "
- "creating ICU GregorianCalendar from time zone and locale", 0, is_constructor);
+ intl_error_set(NULL, status, "intlgregcal_create_instance: error "
+ "creating ICU GregorianCalendar from time zone and locale", 0);
if (gcal) {
delete gcal;
}
@@ -117,9 +119,9 @@ static void _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAMETERS, zend
// From date/time (3, 5 or 6 arguments)
for (int i = 0; i < variant; i++) {
if (largs[i] < INT32_MIN || largs[i] > INT32_MAX) {
- intl_error_set_ex(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"intlgregcal_create_instance: at least one of the arguments"
- " has an absolute value that is too large", 0, is_constructor);
+ " has an absolute value that is too large", 0);
Z_OBJ_P(return_value) = NULL;
return;
}
@@ -137,8 +139,8 @@ static void _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAMETERS, zend
status);
}
if (U_FAILURE(status)) {
- intl_error_set_ex(NULL, status, "intlgregcal_create_instance: error "
- "creating ICU GregorianCalendar from date", 0, is_constructor);
+ intl_error_set(NULL, status, "intlgregcal_create_instance: error "
+ "creating ICU GregorianCalendar from date", 0);
if (gcal) {
delete gcal;
}
@@ -154,10 +156,10 @@ static void _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAMETERS, zend
strlen(tzinfo->name), US_INV);
#endif
if (tzstr.isBogus()) {
- intl_error_set_ex(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"intlgregcal_create_instance: could not create UTF-8 string "
"from PHP's default timezone name (see date_default_timezone_get())",
- 0, is_constructor);
+ 0);
delete gcal;
Z_OBJ_P(return_value) = NULL;
return;
@@ -179,7 +181,7 @@ U_CFUNC PHP_FUNCTION(intlgregcal_create_instance)
object_init_ex(return_value, GregorianCalendar_ce_ptr);
ZVAL_COPY_VALUE(&orig, return_value);
- _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
+ _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAM_PASSTHRU);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
zval_dtor(&orig);
@@ -189,17 +191,18 @@ U_CFUNC PHP_FUNCTION(intlgregcal_create_instance)
U_CFUNC PHP_METHOD(IntlGregorianCalendar, __construct)
{
- zval orig_this = *getThis();
- intl_error_reset(NULL);
+ zend_error_handling error_handling;
+ zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, &error_handling);
return_value = getThis();
//changes this to IS_NULL (without first destroying) if there's an error
- _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-
+ _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAM_PASSTHRU);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
- zend_object_store_ctor_failed(Z_OBJ(orig_this));
- ZEND_CTOR_MAKE_NULL();
+ if (!EG(exception)) {
+ zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0);
+ }
}
+ zend_restore_error_handling(&error_handling);
}
U_CFUNC PHP_FUNCTION(intlgregcal_set_gregorian_change)
diff --git a/ext/intl/collator/collator_create.c b/ext/intl/collator/collator_create.c
index 7631d76ff4..c6bc3fd209 100644
--- a/ext/intl/collator/collator_create.c
+++ b/ext/intl/collator/collator_create.c
@@ -25,7 +25,7 @@
#include "intl_data.h"
/* {{{ */
-static void collator_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
+static void collator_ctor(INTERNAL_FUNCTION_PARAMETERS)
{
const char* locale;
size_t locale_len = 0;
@@ -38,8 +38,8 @@ static void collator_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor
if( zend_parse_parameters( ZEND_NUM_ARGS(), "s",
&locale, &locale_len ) == FAILURE )
{
- intl_error_set_ex( NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "collator_create: unable to parse input params", 0, is_constructor );
+ intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "collator_create: unable to parse input params", 0 );
zval_dtor(return_value);
RETURN_NULL();
}
@@ -53,7 +53,7 @@ static void collator_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor
/* Open ICU collator. */
co->ucoll = ucol_open( locale, COLLATOR_ERROR_CODE_P( co ) );
- INTL_CTOR_CHECK_STATUS(co, "collator_create: unable to open ICU collator", is_constructor);
+ INTL_CTOR_CHECK_STATUS(co, "collator_create: unable to open ICU collator");
}
/* }}} */
@@ -63,7 +63,7 @@ static void collator_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor
PHP_FUNCTION( collator_create )
{
object_init_ex( return_value, Collator_ce_ptr );
- collator_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
+ collator_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
/* }}} */
@@ -72,15 +72,17 @@ PHP_FUNCTION( collator_create )
*/
PHP_METHOD( Collator, __construct )
{
- zval orig_this = *getThis();
+ zend_error_handling error_handling;
+ zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, &error_handling);
return_value = getThis();
- collator_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-
+ collator_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
- zend_object_store_ctor_failed(Z_OBJ(orig_this));
- ZEND_CTOR_MAKE_NULL();
+ if (!EG(exception)) {
+ zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0);
+ }
}
+ zend_restore_error_handling(&error_handling);
}
/* }}} */
diff --git a/ext/intl/converter/converter.c b/ext/intl/converter/converter.c
index 760d763b83..fd3aced34d 100644
--- a/ext/intl/converter/converter.c
+++ b/ext/intl/converter/converter.c
@@ -562,10 +562,10 @@ static PHP_METHOD(UConverter, __construct) {
intl_error_reset(NULL);
- zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, &zeh TSRMLS_CC);
+ zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, &zeh);
rv = zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s!",
- &dest, &dest_len, &src, &src_len);
- zend_restore_error_handling(&zeh TSRMLS_CC);
+ &dest, &dest_len, &src, &src_len);
+ zend_restore_error_handling(&zeh);
if (rv == FAILURE) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
diff --git a/ext/intl/dateformat/dateformat_create.cpp b/ext/intl/dateformat/dateformat_create.cpp
index 31fcaeb7fc..b7ad7b5126 100644
--- a/ext/intl/dateformat/dateformat_create.cpp
+++ b/ext/intl/dateformat/dateformat_create.cpp
@@ -34,9 +34,10 @@ extern "C" {
}
#include "dateformat_helpers.h"
+#include "zend_exceptions.h"
/* {{{ */
-static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
+static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
{
zval *object;
@@ -64,8 +65,8 @@ static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sll|zzs",
&locale_str, &locale_len, &date_type, &time_type, &timezone_zv,
&calendar_zv, &pattern_str, &pattern_str_len) == FAILURE) {
- intl_error_set_ex( NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: "
- "unable to parse input parameters", 0, is_constructor);
+ intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: "
+ "unable to parse input parameters", 0);
Z_OBJ_P(return_value) = NULL;
return;
}
@@ -79,8 +80,6 @@ static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
DATE_FORMAT_METHOD_FETCH_OBJECT_NO_CHECK;
if (DATE_FORMAT_OBJECT(dfo) != NULL) {
- /* This is __construct being called on an instance - it is not
- a constructor. */
intl_errors_set(INTL_DATA_ERROR_P(dfo), U_ILLEGAL_ARGUMENT_ERROR,
"datefmt_create: cannot call constructor twice", 0);
return;
@@ -112,8 +111,8 @@ static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
pattern_str, pattern_str_len, &INTL_DATA_ERROR_CODE(dfo));
if (U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) {
/* object construction -> only set global error */
- intl_error_set_ex(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: "
- "error converting pattern to UTF-16", 0, is_constructor);
+ intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: "
+ "error converting pattern to UTF-16", 0);
goto error;
}
}
@@ -141,8 +140,8 @@ static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
df->adoptTimeZone(timezone);
}
} else {
- intl_error_set_ex(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: date "
- "formatter creation failed", 0, is_constructor);
+ intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: date "
+ "formatter creation failed", 0);
goto error;
}
@@ -177,7 +176,7 @@ error:
U_CFUNC PHP_FUNCTION( datefmt_create )
{
object_init_ex( return_value, IntlDateFormatter_ce_ptr );
- datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
+ datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
RETURN_NULL();
}
@@ -189,16 +188,18 @@ U_CFUNC PHP_FUNCTION( datefmt_create )
*/
U_CFUNC PHP_METHOD( IntlDateFormatter, __construct )
{
- zval orig_this = *getThis();
+ zend_error_handling error_handling;
+ zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, &error_handling);
/* return_value param is being changed, therefore we will always return
* NULL here */
return_value = getThis();
- datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-
+ datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
- zend_object_store_ctor_failed(Z_OBJ(orig_this));
- ZEND_CTOR_MAKE_NULL();
+ if (!EG(exception)) {
+ zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0);
+ }
}
+ zend_restore_error_handling(&error_handling);
}
/* }}} */
diff --git a/ext/intl/formatter/formatter_main.c b/ext/intl/formatter/formatter_main.c
index c8ca65da27..5d5a139688 100644
--- a/ext/intl/formatter/formatter_main.c
+++ b/ext/intl/formatter/formatter_main.c
@@ -25,7 +25,7 @@
#include "intl_convert.h"
/* {{{ */
-static void numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
+static void numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
{
const char* locale;
char* pattern = NULL;
@@ -39,8 +39,8 @@ static void numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
if( zend_parse_parameters( ZEND_NUM_ARGS(), "sl|s",
&locale, &locale_len, &style, &pattern, &pattern_len ) == FAILURE )
{
- intl_error_set_ex( NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "numfmt_create: unable to parse input parameters", 0, is_constructor );
+ intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "numfmt_create: unable to parse input parameters", 0 );
Z_OBJ_P(return_value) = NULL;
return;
}
@@ -52,7 +52,7 @@ static void numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
/* Convert pattern (if specified) to UTF-16. */
if(pattern && pattern_len) {
intl_convert_utf8_to_utf16(&spattern, &spattern_len, pattern, pattern_len, &INTL_DATA_ERROR_CODE(nfo));
- INTL_CTOR_CHECK_STATUS(nfo, "numfmt_create: error converting pattern to UTF-16", is_constructor);
+ INTL_CTOR_CHECK_STATUS(nfo, "numfmt_create: error converting pattern to UTF-16");
}
if(locale_len == 0) {
@@ -66,7 +66,7 @@ static void numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
efree(spattern);
}
- INTL_CTOR_CHECK_STATUS(nfo, "numfmt_create: number formatter creation failed", is_constructor);
+ INTL_CTOR_CHECK_STATUS(nfo, "numfmt_create: number formatter creation failed");
}
/* }}} */
@@ -78,7 +78,7 @@ static void numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
PHP_FUNCTION( numfmt_create )
{
object_init_ex( return_value, NumberFormatter_ce_ptr );
- numfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
+ numfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
RETURN_NULL();
}
@@ -90,15 +90,17 @@ PHP_FUNCTION( numfmt_create )
*/
PHP_METHOD( NumberFormatter, __construct )
{
- zval orig_this = *getThis();
+ zend_error_handling error_handling;
+ zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, &error_handling);
return_value = getThis();
- numfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-
+ numfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
- zend_object_store_ctor_failed(Z_OBJ(orig_this));
- ZEND_CTOR_MAKE_NULL();
+ if (!EG(exception)) {
+ zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0);
+ }
}
+ zend_restore_error_handling(&error_handling);
}
/* }}} */
diff --git a/ext/intl/intl_data.h b/ext/intl/intl_data.h
index c49214ffcd..6001aa1285 100644
--- a/ext/intl/intl_data.h
+++ b/ext/intl/intl_data.h
@@ -64,11 +64,11 @@ typedef struct _intl_data {
}
/* Check status, if error - destroy value and exit */
-#define INTL_CTOR_CHECK_STATUS(obj, msg, forceException) \
+#define INTL_CTOR_CHECK_STATUS(obj, msg) \
intl_error_set_code( NULL, INTL_DATA_ERROR_CODE((obj)) ); \
if( U_FAILURE( INTL_DATA_ERROR_CODE((obj)) ) ) \
{ \
- intl_errors_set_custom_msg_ex( INTL_DATA_ERROR_P((obj)), msg, 0, forceException ); \
+ intl_errors_set_custom_msg( INTL_DATA_ERROR_P((obj)), msg, 0 ); \
/* yes, this is ugly, but it alreay is */ \
if (return_value != getThis()) { \
zval_dtor(return_value); \
diff --git a/ext/intl/intl_error.c b/ext/intl/intl_error.c
index 8ea5e7b4cf..a946705a76 100644
--- a/ext/intl/intl_error.c
+++ b/ext/intl/intl_error.c
@@ -103,25 +103,14 @@ void intl_error_reset( intl_error* err )
*/
void intl_error_set_custom_msg( intl_error* err, char* msg, int copyMsg )
{
- intl_error_set_custom_msg_ex( err, msg, copyMsg, 0 );
-}
-/* }}} */
-
-
-/* {{{ void intl_error_set_custom_msg( intl_error* err, char* msg, int copyMsg )
- * Set last error message to msg copying it if needed.
- */
-void intl_error_set_custom_msg_ex( intl_error* err, char* msg, int copyMsg, int forceException )
-{
if( !msg )
return;
if( !err ) {
- if ( forceException || INTL_G( use_exceptions ) ) {
- zend_throw_exception_ex( IntlException_ce_ptr, 0, "%s", msg );
- } else if( INTL_G( error_level ) ) {
+ if( INTL_G( error_level ) )
php_error_docref( NULL, INTL_G( error_level ), "%s", msg );
- }
+ if( INTL_G( use_exceptions ) )
+ zend_throw_exception_ex( IntlException_ce_ptr, 0, "%s", msg );
}
if( !err && !( err = intl_g_error_get( ) ) )
return;
@@ -193,38 +182,18 @@ UErrorCode intl_error_get_code( intl_error* err )
*/
void intl_error_set( intl_error* err, UErrorCode code, char* msg, int copyMsg )
{
- intl_error_set_ex( err, code, msg, copyMsg, 0 );
-}
-/* }}} */
-
-
-/* {{{ void intl_error_set( intl_error* err, UErrorCode code, char* msg, int copyMsg )
- * Set error code and message.
- */
-void intl_error_set_ex( intl_error* err, UErrorCode code, char* msg, int copyMsg, int forceException )
-{
intl_error_set_code( err, code );
- intl_error_set_custom_msg_ex( err, msg, copyMsg, forceException );
+ intl_error_set_custom_msg( err, msg, copyMsg );
}
/* }}} */
-
/* {{{ void intl_errors_set( intl_error* err, UErrorCode code, char* msg, int copyMsg )
* Set error code and message.
*/
void intl_errors_set( intl_error* err, UErrorCode code, char* msg, int copyMsg )
{
- intl_errors_set_ex( err, code, msg, copyMsg, 0 );
-}
-/* }}} */
-
-/* {{{ void intl_errors_set_ex( intl_error* err, UErrorCode code, char* msg, int copyMsg )
- * Set error code and message.
- */
-void intl_errors_set_ex( intl_error* err, UErrorCode code, char* msg, int copyMsg, int forceException )
-{
intl_errors_set_code( err, code );
- intl_errors_set_custom_msg_ex( err, msg, copyMsg, forceException );
+ intl_errors_set_custom_msg( err, msg, copyMsg );
}
/* }}} */
@@ -243,23 +212,13 @@ void intl_errors_reset( intl_error* err )
*/
void intl_errors_set_custom_msg( intl_error* err, char* msg, int copyMsg )
{
- intl_errors_set_custom_msg_ex( err, msg, copyMsg, 0 );
-}
-/* }}} */
-
-
-/* {{{ void intl_errors_set_custom_msg( intl_error* err, char* msg, int copyMsg )
- */
-void intl_errors_set_custom_msg_ex( intl_error* err, char* msg, int copyMsg, int forceException )
-{
if(err) {
- intl_error_set_custom_msg_ex( err, msg, copyMsg, forceException );
+ intl_error_set_custom_msg( err, msg, copyMsg );
}
- intl_error_set_custom_msg_ex( NULL, msg, copyMsg, forceException );
+ intl_error_set_custom_msg( NULL, msg, copyMsg );
}
/* }}} */
-
/* {{{ intl_errors_set_code( intl_error* err, UErrorCode err_code )
*/
void intl_errors_set_code( intl_error* err, UErrorCode err_code )
diff --git a/ext/intl/intl_error.h b/ext/intl/intl_error.h
index 4c9349b281..02d62f0299 100644
--- a/ext/intl/intl_error.h
+++ b/ext/intl/intl_error.h
@@ -36,21 +36,15 @@ void intl_error_init( intl_error* err );
void intl_error_reset( intl_error* err );
void intl_error_set_code( intl_error* err, UErrorCode err_code );
void intl_error_set_custom_msg( intl_error* err, char* msg, int copyMsg );
-void intl_error_set_custom_msg_ex( intl_error* err, char* msg, int copyMsg, int forceException );
void intl_error_set( intl_error* err, UErrorCode code, char* msg, int copyMsg );
-void intl_error_set_ex( intl_error* err, UErrorCode code, char* msg, int copyMsg, int forceException );
-
-
UErrorCode intl_error_get_code( intl_error* err );
zend_string* intl_error_get_message( intl_error* err );
// Wrappers to synchonize object's and global error structures.
void intl_errors_reset( intl_error* err );
void intl_errors_set_custom_msg( intl_error* err, char* msg, int copyMsg );
-void intl_errors_set_custom_msg_ex( intl_error* err, char* msg, int copyMsg, int forceException );
void intl_errors_set_code( intl_error* err, UErrorCode err_code );
void intl_errors_set( intl_error* err, UErrorCode code, char* msg, int copyMsg );
-void intl_errors_set_ex( intl_error* err, UErrorCode code, char* msg, int copyMsg, int forceException );
// Other error helpers
smart_str intl_parse_error_to_string( UParseError* pe );
diff --git a/ext/intl/msgformat/msgformat.c b/ext/intl/msgformat/msgformat.c
index 34923f92a5..15d6ef8321 100644
--- a/ext/intl/msgformat/msgformat.c
+++ b/ext/intl/msgformat/msgformat.c
@@ -26,7 +26,7 @@
#include "intl_convert.h"
/* {{{ */
-static void msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
+static void msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
{
const char* locale;
char* pattern;
@@ -42,8 +42,8 @@ static void msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
if( zend_parse_parameters( ZEND_NUM_ARGS(), "ss",
&locale, &locale_len, &pattern, &pattern_len ) == FAILURE )
{
- intl_error_set_ex( NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "msgfmt_create: unable to parse input parameters", 0, is_constructor );
+ intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "msgfmt_create: unable to parse input parameters", 0 );
Z_OBJ_P(return_value) = NULL;
return;
}
@@ -54,7 +54,7 @@ static void msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
/* Convert pattern (if specified) to UTF-16. */
if(pattern && pattern_len) {
intl_convert_utf8_to_utf16(&spattern, &spattern_len, pattern, pattern_len, &INTL_DATA_ERROR_CODE(mfo));
- INTL_CTOR_CHECK_STATUS(mfo, "msgfmt_create: error converting pattern to UTF-16", is_constructor);
+ INTL_CTOR_CHECK_STATUS(mfo, "msgfmt_create: error converting pattern to UTF-16");
} else {
spattern_len = 0;
spattern = NULL;
@@ -66,7 +66,7 @@ static void msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
#ifdef MSG_FORMAT_QUOTE_APOS
if(msgformat_fix_quotes(&spattern, &spattern_len, &INTL_DATA_ERROR_CODE(mfo)) != SUCCESS) {
- INTL_CTOR_CHECK_STATUS(mfo, "msgfmt_create: error converting pattern to quote-friendly format", is_constructor);
+ INTL_CTOR_CHECK_STATUS(mfo, "msgfmt_create: error converting pattern to quote-friendly format");
}
#endif
@@ -84,7 +84,7 @@ static void msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
efree(spattern);
}
- INTL_CTOR_CHECK_STATUS(mfo, "msgfmt_create: message formatter creation failed", is_constructor);
+ INTL_CTOR_CHECK_STATUS(mfo, "msgfmt_create: message formatter creation failed");
}
/* }}} */
@@ -96,7 +96,7 @@ static void msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
PHP_FUNCTION( msgfmt_create )
{
object_init_ex( return_value, MessageFormatter_ce_ptr );
- msgfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
+ msgfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
RETURN_NULL();
}
@@ -108,15 +108,17 @@ PHP_FUNCTION( msgfmt_create )
*/
PHP_METHOD( MessageFormatter, __construct )
{
- zval orig_this = *getThis();
+ zend_error_handling error_handling;
+ zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, &error_handling);
return_value = getThis();
- msgfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-
+ msgfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
- zend_object_store_ctor_failed(Z_OBJ(orig_this));
- ZEND_CTOR_MAKE_NULL();
+ if (!EG(exception)) {
+ zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0);
+ }
}
+ zend_restore_error_handling(&error_handling);
}
/* }}} */
diff --git a/ext/intl/msgformat/msgformat_class.c b/ext/intl/msgformat/msgformat_class.c
index 1296d087e1..8d464c6ca4 100644
--- a/ext/intl/msgformat/msgformat_class.c
+++ b/ext/intl/msgformat/msgformat_class.c
@@ -87,10 +87,10 @@ zend_object *MessageFormatter_object_clone(zval *object)
if (U_FAILURE(INTL_DATA_ERROR_CODE(mfo))) {
intl_errors_set(INTL_DATA_ERROR_P(mfo), INTL_DATA_ERROR_CODE(mfo),
"Failed to clone MessageFormatter object", 0);
- zend_throw_exception_ex(IntlException_ce_ptr, 0, "Failed to clone MessageFormatter object");
+ zend_throw_exception_ex(NULL, 0, "Failed to clone MessageFormatter object");
}
} else {
- zend_throw_exception_ex(IntlException_ce_ptr, 0, "Cannot clone unconstructed MessageFormatter");
+ zend_throw_exception_ex(NULL, 0, "Cannot clone unconstructed MessageFormatter");
}
return new_obj;
}
diff --git a/ext/intl/resourcebundle/resourcebundle_class.c b/ext/intl/resourcebundle/resourcebundle_class.c
index 60800fe1a9..d8d1aa0d9c 100644
--- a/ext/intl/resourcebundle/resourcebundle_class.c
+++ b/ext/intl/resourcebundle/resourcebundle_class.c
@@ -25,6 +25,7 @@
#include "php_intl.h"
#include "intl_data.h"
+#include "intl_common.h"
#include "resourcebundle/resourcebundle.h"
#include "resourcebundle/resourcebundle_iterator.h"
@@ -74,7 +75,7 @@ static zend_object *ResourceBundle_object_create( zend_class_entry *ce )
/* }}} */
/* {{{ ResourceBundle_ctor */
-static void resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
+static void resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS)
{
const char *bundlename;
size_t bundlename_len = 0;
@@ -90,8 +91,8 @@ static void resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_const
if( zend_parse_parameters( ZEND_NUM_ARGS(), "s!s!|b",
&locale, &locale_len, &bundlename, &bundlename_len, &fallback ) == FAILURE )
{
- intl_error_set_ex( NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "resourcebundle_ctor: unable to parse input parameters", 0, is_constructor );
+ intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "resourcebundle_ctor: unable to parse input parameters", 0 );
Z_OBJ_P(return_value) = NULL;
return;
}
@@ -108,7 +109,7 @@ static void resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_const
rb->me = ures_openDirect(bundlename, locale, &INTL_DATA_ERROR_CODE(rb));
}
- INTL_CTOR_CHECK_STATUS(rb, "resourcebundle_ctor: Cannot load libICU resource bundle", is_constructor);
+ INTL_CTOR_CHECK_STATUS(rb, "resourcebundle_ctor: Cannot load libICU resource bundle");
if (!fallback && (INTL_DATA_ERROR_CODE(rb) == U_USING_FALLBACK_WARNING ||
INTL_DATA_ERROR_CODE(rb) == U_USING_DEFAULT_WARNING)) {
@@ -119,7 +120,7 @@ static void resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_const
bundlename ? bundlename : "(default data)", locale,
ures_getLocaleByType(
rb->me, ULOC_ACTUAL_LOCALE, &INTL_DATA_ERROR_CODE(rb)));
- intl_errors_set_custom_msg_ex(INTL_DATA_ERROR_P(rb), pbuf, 1, is_constructor);
+ intl_errors_set_custom_msg(INTL_DATA_ERROR_P(rb), pbuf, 1);
efree(pbuf);
Z_OBJ_P(return_value) = NULL;
}
@@ -139,15 +140,17 @@ ZEND_END_ARG_INFO()
*/
PHP_METHOD( ResourceBundle, __construct )
{
- zval orig_this = *getThis();
+ zend_error_handling error_handling;
+ zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, &error_handling);
return_value = getThis();
- resourcebundle_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-
+ resourcebundle_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
- zend_object_store_ctor_failed(Z_OBJ(orig_this));
- ZEND_CTOR_MAKE_NULL();
+ if (!EG(exception)) {
+ zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0);
+ }
}
+ zend_restore_error_handling(&error_handling);
}
/* }}} */
@@ -157,7 +160,7 @@ proto ResourceBundle resourcebundle_create( string $locale [, string $bundlename
PHP_FUNCTION( resourcebundle_create )
{
object_init_ex( return_value, ResourceBundle_ce_ptr );
- resourcebundle_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
+ resourcebundle_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
RETURN_NULL();
}
diff --git a/ext/intl/spoofchecker/spoofchecker_create.c b/ext/intl/spoofchecker/spoofchecker_create.c
index b56c840961..abe1d8e9cc 100644
--- a/ext/intl/spoofchecker/spoofchecker_create.c
+++ b/ext/intl/spoofchecker/spoofchecker_create.c
@@ -30,15 +30,19 @@ PHP_METHOD(Spoofchecker, __construct)
{
int checks;
SPOOFCHECKER_METHOD_INIT_VARS;
+ zend_error_handling error_handling;
+
+ zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, &error_handling);
if (zend_parse_parameters_none() == FAILURE) {
+ zend_restore_error_handling(&error_handling);
return;
}
SPOOFCHECKER_METHOD_FETCH_OBJECT_NO_CHECK;
co->uspoof = uspoof_open(SPOOFCHECKER_ERROR_CODE_P(co));
- INTL_CTOR_CHECK_STATUS(co, "spoofchecker: unable to open ICU Spoof Checker", 1);
+ INTL_CTOR_CHECK_STATUS(co, "spoofchecker: unable to open ICU Spoof Checker");
/* Single-script enforcement is on by default. This fails for languages
like Japanese that legally use multiple scripts within a single word,
@@ -46,6 +50,7 @@ PHP_METHOD(Spoofchecker, __construct)
*/
checks = uspoof_getChecks(co->uspoof, SPOOFCHECKER_ERROR_CODE_P(co));
uspoof_setChecks(co->uspoof, checks & ~USPOOF_SINGLE_SCRIPT, SPOOFCHECKER_ERROR_CODE_P(co));
+ zend_restore_error_handling(&error_handling);
}
/* }}} */
diff --git a/ext/intl/tests/breakiter___construct_error.phpt b/ext/intl/tests/breakiter___construct_error.phpt
index 770f1403c7..bea65667fa 100644
--- a/ext/intl/tests/breakiter___construct_error.phpt
+++ b/ext/intl/tests/breakiter___construct_error.phpt
@@ -7,32 +7,44 @@ IntlRuleBasedBreakIterator::__construct(): arg errors
<?php
ini_set("intl.error_level", E_WARNING);
-//missing ; at the end:
-var_dump(new IntlRuleBasedBreakIterator('[\p{Letter}\uFFFD]+;[:number:]+'));
-var_dump(new IntlRuleBasedBreakIterator());
-var_dump(new IntlRuleBasedBreakIterator(1,2,3));
-var_dump(new IntlRuleBasedBreakIterator('[\p{Letter}\uFFFD]+;[:number:]+;', array()));
-var_dump(new IntlRuleBasedBreakIterator('[\p{Letter}\uFFFD]+;[:number:]+;', true));
+function print_exception($e) {
+ echo "\nException: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n";
+}
+//missing ; at the end:
+try {
+ var_dump(new IntlRuleBasedBreakIterator('[\p{Letter}\uFFFD]+;[:number:]+'));
+} catch (IntlException $e) {
+ print_exception($e);
+}
+try {
+ var_dump(new IntlRuleBasedBreakIterator());
+} catch (IntlException $e) {
+ print_exception($e);
+}
+try {
+ var_dump(new IntlRuleBasedBreakIterator(1,2,3));
+} catch (IntlException $e) {
+ print_exception($e);
+}
+try {
+ var_dump(new IntlRuleBasedBreakIterator('[\p{Letter}\uFFFD]+;[:number:]+;', array()));
+} catch (IntlException $e) {
+ print_exception($e);
+}
+try {
+ var_dump(new IntlRuleBasedBreakIterator('[\p{Letter}\uFFFD]+;[:number:]+;', true));
+} catch (IntlException $e) {
+ print_exception($e);
+}
--EXPECTF--
-Warning: IntlRuleBasedBreakIterator::__construct(): rbbi_create_instance: unable to create RuleBasedBreakIterator from rules (parse error on line 1, offset 31) in %s on line %d
-NULL
-
-Warning: IntlRuleBasedBreakIterator::__construct() expects at least 1 parameter, 0 given in %s on line %d
-
-Warning: IntlRuleBasedBreakIterator::__construct(): rbbi_create_instance: bad arguments in %s on line %d
-NULL
-
-Warning: IntlRuleBasedBreakIterator::__construct() expects at most 2 parameters, 3 given in %s on line %d
+Exception: IntlRuleBasedBreakIterator::__construct(): rbbi_create_instance: unable to create RuleBasedBreakIterator from rules (parse error on line 1, offset 31) in %s on line %d
-Warning: IntlRuleBasedBreakIterator::__construct(): rbbi_create_instance: bad arguments in %s on line %d
-NULL
+Exception: IntlRuleBasedBreakIterator::__construct() expects at least 1 parameter, 0 given in %s on line %d
-Warning: IntlRuleBasedBreakIterator::__construct() expects parameter 2 to be boolean, array given in %s on line %d
+Exception: IntlRuleBasedBreakIterator::__construct() expects at most 2 parameters, 3 given in %s on line %d
-Warning: IntlRuleBasedBreakIterator::__construct(): rbbi_create_instance: bad arguments in %s on line %d
-NULL
+Exception: IntlRuleBasedBreakIterator::__construct() expects parameter 2 to be boolean, array given in %s on line %d
-Warning: IntlRuleBasedBreakIterator::__construct(): rbbi_create_instance: unable to create instance from compiled rules in %s on line %d
-NULL
+Exception: IntlRuleBasedBreakIterator::__construct(): rbbi_create_instance: unable to create instance from compiled rules in %s on line %d
diff --git a/ext/intl/tests/bug62017.phpt b/ext/intl/tests/bug62017.phpt
index e5c216c1e2..2f3c816f99 100644
--- a/ext/intl/tests/bug62017.phpt
+++ b/ext/intl/tests/bug62017.phpt
@@ -11,14 +11,14 @@ var_dump(
datefmt_create('', IntlDateFormatter::NONE, IntlDateFormatter::NONE, "\xFF",
IntlDateFormatter::GREGORIAN, 'a'));
try {
- new IntlDateFormatter('', IntlDateFormatter::NONE, IntlDateFormatter::NONE, "Europe/Lisbon",
- IntlDateFormatter::GREGORIAN, "\x80");
-}
-catch(IntlException $ie) {
- echo $ie->getMessage().PHP_EOL;
+ var_dump(
+ new IntlDateFormatter('', IntlDateFormatter::NONE, IntlDateFormatter::NONE, "Europe/Lisbon",
+ IntlDateFormatter::GREGORIAN, "\x80"));
+} catch (IntlException $e) {
+ echo PHP_EOL."Exception: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . PHP_EOL;
}
--EXPECTF--
Warning: datefmt_create(): datefmt_create: Time zone identifier given is not a valid UTF-8 string in %s on line %d
NULL
-datefmt_create: error converting pattern to UTF-16
+Exception: IntlDateFormatter::__construct(): datefmt_create: error converting pattern to UTF-16 in %sbug62017.php on line %d
diff --git a/ext/intl/tests/bug62081.phpt b/ext/intl/tests/bug62081.phpt
index 44ad4beec7..263023ffac 100644
--- a/ext/intl/tests/bug62081.phpt
+++ b/ext/intl/tests/bug62081.phpt
@@ -12,5 +12,8 @@ ini_set('intl.error_level', E_WARNING);
$x = new IntlDateFormatter('en', 1, 1);
var_dump($x->__construct('en', 1, 1));
--EXPECTF--
-Warning: IntlDateFormatter::__construct(): datefmt_create: cannot call constructor twice in %s on line %d
-NULL
+Fatal error: Uncaught exception 'IntlException' with message 'IntlDateFormatter::__construct(): datefmt_create: cannot call constructor twice' in %sbug62081.php:4
+Stack trace:
+#0 %sbug62081.php(4): IntlDateFormatter->__construct('en', 1, 1)
+#1 {main}
+ thrown in %sbug62081.php on line 4
diff --git a/ext/intl/tests/dateformat___construct_bad_tz_cal.phpt b/ext/intl/tests/dateformat___construct_bad_tz_cal.phpt
index cfd9338717..d10ad42623 100644
--- a/ext/intl/tests/dateformat___construct_bad_tz_cal.phpt
+++ b/ext/intl/tests/dateformat___construct_bad_tz_cal.phpt
@@ -10,23 +10,32 @@ ini_set("intl.error_level", E_WARNING);
ini_set("intl.default_locale", "pt_PT");
ini_set("date.timezone", 'Atlantic/Azores');
-var_dump(new IntlDateFormatter(NULL, 0, 0, 'bad timezone'));
-
-var_dump(new IntlDateFormatter(NULL, 0, 0, NULL, 3));
-
-var_dump(new IntlDateFormatter(NULL, 0, 0, NULL, new stdclass));
-
-
+function print_exception($e) {
+ echo "\nException: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n";
+}
+
+try {
+ var_dump(new IntlDateFormatter(NULL, 0, 0, 'bad timezone'));
+} catch (IntlException $e) {
+ print_exception($e);
+}
+try {
+ var_dump(new IntlDateFormatter(NULL, 0, 0, NULL, 3));
+} catch (IntlException $e) {
+ print_exception($e);
+}
+try {
+ var_dump(new IntlDateFormatter(NULL, 0, 0, NULL, new stdclass));
+} catch (IntlException $e) {
+ print_exception($e);
+}
?>
==DONE==
--EXPECTF--
-Warning: IntlDateFormatter::__construct(): datefmt_create: no such time zone: 'bad timezone' in %s on line %d
-NULL
+Exception: IntlDateFormatter::__construct(): datefmt_create: no such time zone: 'bad timezone' in %s on line %d
-Warning: IntlDateFormatter::__construct(): datefmt_create: invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object in %s on line %d
-NULL
+Exception: IntlDateFormatter::__construct(): datefmt_create: invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object in %s on line %d
-Warning: IntlDateFormatter::__construct(): datefmt_create: Invalid calendar argument; should be an integer or an IntlCalendar instance in %s on line %d
-NULL
+Exception: IntlDateFormatter::__construct(): datefmt_create: Invalid calendar argument; should be an integer or an IntlCalendar instance in %s on line %d
==DONE==
diff --git a/ext/intl/tests/dateformat_calendars_variant2.phpt b/ext/intl/tests/dateformat_calendars_variant2.phpt
index b3b1701c55..11a5026da0 100644
--- a/ext/intl/tests/dateformat_calendars_variant2.phpt
+++ b/ext/intl/tests/dateformat_calendars_variant2.phpt
@@ -42,5 +42,8 @@ string(47) "Sunday, January 1, 2012 at 5:12:00 AM GMT+05:12"
string(47) "Sunday, January 1, 2012 at 5:12:00 AM GMT+05:12"
string(48) "Sunday, Tevet 6, 5772 AM at 5:12:00 AM GMT+05:12"
-Warning: IntlDateFormatter::__construct(): datefmt_create: invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object in %sdateformat_calendars_variant2.php on line %d
-==DONE==
+Fatal error: Uncaught exception 'IntlException' with message 'IntlDateFormatter::__construct(): datefmt_create: invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object' in %sdateformat_calendars_variant2.php:27
+Stack trace:
+#0 %sdateformat_calendars_variant2.php(27): IntlDateFormatter->__construct('en_US@calendar=...', 0, 0, 'GMT+05:12', -1)
+#1 {main}
+ thrown in %sdateformat_calendars_variant2.php on line 27
diff --git a/ext/intl/tests/formatter_fail.phpt b/ext/intl/tests/formatter_fail.phpt
index c45b113bdb..f61cb14878 100644
--- a/ext/intl/tests/formatter_fail.phpt
+++ b/ext/intl/tests/formatter_fail.phpt
@@ -11,24 +11,26 @@ function err($fmt) {
}
}
+function print_exception($e) {
+ echo "\nException: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n";
+}
+
function crt($t, $l, $s) {
- try {
- $fmt = null;
- switch(true) {
- case $t == "O":
- $fmt = new NumberFormatter($l, $s);
- break;
- case $t == "C":
- $fmt = NumberFormatter::create($l, $s);
- break;
- case $t == "P":
- $fmt = numfmt_create($l, $s);
- break;
- }
- err($fmt);
- }
- catch(IntlException $ie) {
- echo "IE: ".$ie->getMessage().PHP_EOL;
+ switch(true) {
+ case $t == "O":
+ try {
+ return new NumberFormatter($l, $s);
+ } catch (IntlException $e) {
+ print_exception($e);
+ return null;
+ }
+ break;
+ case $t == "C":
+ return NumberFormatter::create($l, $s);
+ break;
+ case $t == "P":
+ return numfmt_create($l, $s);
+ break;
}
}
@@ -42,11 +44,11 @@ $args = array(
try {
$fmt = new NumberFormatter();
+} catch (IntlException $e) {
+ print_exception($e);
+ $fmt = null;
}
-catch(IntlException $ie) {
- echo $ie->getMessage().PHP_EOL;
-}
-
+err($fmt);
$fmt = numfmt_create();
err($fmt);
$fmt = NumberFormatter::create();
@@ -54,13 +56,16 @@ err($fmt);
foreach($args as $arg) {
$fmt = crt("O", $arg[0], $arg[1]);
+ err($fmt);
$fmt = crt("C", $arg[0], $arg[1]);
+ err($fmt);
$fmt = crt("P", $arg[0], $arg[1]);
+ err($fmt);
}
?>
--EXPECTF--
-Warning: NumberFormatter::__construct() expects at least 2 parameters, 0 given in %s on line %d
+Exception: NumberFormatter::__construct() expects at least 2 parameters, 0 given in %s on line %d
'numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
Warning: numfmt_create() expects at least 2 parameters, 0 given in %s on line %d
@@ -68,21 +73,27 @@ Warning: numfmt_create() expects at least 2 parameters, 0 given in %s on line %d
Warning: NumberFormatter::create() expects at least 2 parameters, 0 given in %s on line %d
'numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+
+Exception: Constructor failed in %sformatter_fail.php on line %d
'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'
'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'
'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'
-Warning: NumberFormatter::__construct() expects parameter 1 to be string, array given in %s on line %d
+Exception: NumberFormatter::__construct() expects parameter 1 to be string, array given in %s on line %d
'numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
Warning: NumberFormatter::create() expects parameter 1 to be string, array given in %s on line %d
'numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
Warning: numfmt_create() expects parameter 1 to be string, array given in %s on line %d
-IE: numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR
-IE: numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR
-IE: numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR
-IE: numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR
-IE: numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR
-IE: numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR
-IE: numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR
+'numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+
+Exception: Constructor failed in %sformatter_fail.php on line %d
+'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'
+'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'
+'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'
+
+Exception: Constructor failed in %sformatter_fail.php on line %d
+'numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR'
+'numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR'
+'numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR'
diff --git a/ext/intl/tests/formatter_format.phpt b/ext/intl/tests/formatter_format.phpt
index 0fa88681d9..334ef49567 100644
--- a/ext/intl/tests/formatter_format.phpt
+++ b/ext/intl/tests/formatter_format.phpt
@@ -50,14 +50,7 @@ function ut_main()
$str_res .= "\nLocale is: $locale\n";
foreach( $styles as $style => $pattern )
{
- try {
- $fmt = ut_nfmt_create( $locale, $style, $pattern );
- }
- catch (IntlException $ie) {
- //$str_res .= "IE:".$ie->getMessage()."\n";
- $str_res .= "Bad formatter!\n";
- continue;
- }
+ $fmt = ut_nfmt_create( $locale, $style, $pattern );
if(!$fmt) {
$str_res .= "Bad formatter!\n";
diff --git a/ext/intl/tests/gregoriancalendar___construct_error.phpt b/ext/intl/tests/gregoriancalendar___construct_error.phpt
index a28fa715e4..d81809793e 100644
--- a/ext/intl/tests/gregoriancalendar___construct_error.phpt
+++ b/ext/intl/tests/gregoriancalendar___construct_error.phpt
@@ -8,23 +8,23 @@ if (!extension_loaded('intl'))
<?php
ini_set("intl.error_level", E_WARNING);
+function print_exception($e) {
+ echo "\nException: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n";
+}
+
var_dump(intlgregcal_create_instance(1,2,3,4,5,6,7));
var_dump(intlgregcal_create_instance(1,2,3,4,5,6,7,8));
var_dump(intlgregcal_create_instance(1,2,3,4));
try {
- new IntlGregorianCalendar(1,2,NULL,4);
-}
-catch (IntlException $ie) {
- echo "IE: ".$ie->getMessage().PHP_EOL;
+ var_dump(new IntlGregorianCalendar(1,2,NULL,4));
+} catch (IntlException $e) {
+ print_exception($e);
}
try {
- new IntlGregorianCalendar(1,2,3,4,NULL,array());
-}
-catch (IntlException $ie) {
- echo "IE: ".$ie->getMessage().PHP_EOL;
+ var_dump(new IntlGregorianCalendar(1,2,3,4,NULL,array()));
+} catch (IntlException $e) {
+ print_exception($e);
}
-
-
--EXPECTF--
Warning: intlgregcal_create_instance(): intlgregcal_create_instance: too many arguments in %s on line %d
@@ -36,6 +36,6 @@ NULL
Warning: intlgregcal_create_instance(): intlgregcal_create_instance: no variant with 4 arguments (excluding trailing NULLs) in %s on line %d
NULL
-IE: IntlGregorianCalendar::__construct(): intlgregcal_create_instance: no variant with 4 arguments (excluding trailing NULLs)
-Warning: IntlGregorianCalendar::__construct() expects parameter 6 to be integer, array given in %s on line %d
-IE: IntlGregorianCalendar::__construct(): intlgregcal_create_instance: bad arguments
+Exception: IntlGregorianCalendar::__construct(): intlgregcal_create_instance: no variant with 4 arguments (excluding trailing NULLs) in %s on line %d
+
+Exception: IntlGregorianCalendar::__construct() expects parameter 6 to be integer, array given in %s on line %d
diff --git a/ext/intl/tests/msgfmt_fail.phpt b/ext/intl/tests/msgfmt_fail.phpt
index 4b60b35abc..7c76598c0d 100644
--- a/ext/intl/tests/msgfmt_fail.phpt
+++ b/ext/intl/tests/msgfmt_fail.phpt
@@ -12,25 +12,26 @@ function err($fmt) {
}
}
-function crt($t, $l, $s) {
+function print_exception($e) {
+ echo "\nException: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n";
+}
- try {
- $fmt = null;
- switch(true) {
- case $t == "O":
- $fmt = new MessageFormatter($l, $s);
- break;
- case $t == "C":
- $fmt = MessageFormatter::create($l, $s);
- break;
- case $t == "P":
- $fmt = msgfmt_create($l, $s);
- break;
- }
- err($fmt);
- }
- catch (IntlException $ie) {
- echo "IE: ".$ie->getMessage().PHP_EOL;
+function crt($t, $l, $s) {
+ switch(true) {
+ case $t == "O":
+ try {
+ return new MessageFormatter($l, $s);
+ } catch (IntlException $e) {
+ print_exception($e);
+ return null;
+ }
+ break;
+ case $t == "C":
+ return MessageFormatter::create($l, $s);
+ break;
+ case $t == "P":
+ return msgfmt_create($l, $s);
+ break;
}
}
@@ -45,34 +46,40 @@ $args = array(
try {
$fmt = new MessageFormatter();
+} catch (IntlException $e) {
+ print_exception($e);
+ $fmt = null;
}
-catch(IntlException $ie) {
- echo "IE: ".$ie->getMessage().PHP_EOL;
-}
+err($fmt);
$fmt = msgfmt_create();
err($fmt);
$fmt = MessageFormatter::create();
err($fmt);
try {
$fmt = new MessageFormatter('en');
+} catch (IntlException $e) {
+ print_exception($e);
+ $fmt = null;
}
-catch(IntlException $ie) {
- echo "IE: ".$ie->getMessage().PHP_EOL;
-}
+err($fmt);
$fmt = msgfmt_create('en');
err($fmt);
$fmt = MessageFormatter::create('en');
err($fmt);
foreach($args as $arg) {
- crt("O", $arg[0], $arg[1]);
- crt("C", $arg[0], $arg[1]);
- crt("P", $arg[0], $arg[1]);
+ $fmt = crt("O", $arg[0], $arg[1]);
+ err($fmt);
+ $fmt = crt("C", $arg[0], $arg[1]);
+ err($fmt);
+ $fmt = crt("P", $arg[0], $arg[1]);
+ err($fmt);
}
?>
--EXPECTF--
-IE: msgfmt_create: unable to parse input parameters
+Exception: MessageFormatter::__construct() expects exactly 2 parameters, 0 given in %s on line %d
+'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
Warning: msgfmt_create() expects exactly 2 parameters, 0 given in %s on line %d
'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
@@ -80,21 +87,26 @@ Warning: msgfmt_create() expects exactly 2 parameters, 0 given in %s on line %d
Warning: MessageFormatter::create() expects exactly 2 parameters, 0 given in %s on line %d
'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
-IE: msgfmt_create: unable to parse input parameters
+Exception: MessageFormatter::__construct() expects exactly 2 parameters, 1 given in %s on line %d
+'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
Warning: msgfmt_create() expects exactly 2 parameters, 1 given in %s on line %d
'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
Warning: MessageFormatter::create() expects exactly 2 parameters, 1 given in %s on line %d
'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+
+Exception: Constructor failed in %smsgfmt_fail2.php on line %d
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
+
+Exception: Constructor failed in %smsgfmt_fail2.php on line %d
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
-Warning: MessageFormatter::__construct() expects parameter 1 to be string, array given in %s on line %d
+Exception: MessageFormatter::__construct() expects parameter 1 to be string, array given in %s on line %d
'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
Warning: MessageFormatter::create() expects parameter 1 to be string, array given in %s on line %d
@@ -102,12 +114,18 @@ Warning: MessageFormatter::create() expects parameter 1 to be string, array give
Warning: msgfmt_create() expects parameter 1 to be string, array given in %s on line %d
'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+
+Exception: Constructor failed in %smsgfmt_fail2.php on line %d
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
+
+Exception: Constructor failed in %smsgfmt_fail2.php on line %d
'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES'
'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES'
'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES'
+
+Exception: Constructor failed in %smsgfmt_fail2.php on line %d
'msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND'
'msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND'
'msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND'
diff --git a/ext/intl/tests/msgfmt_fail2.phpt b/ext/intl/tests/msgfmt_fail2.phpt
index eee2424a50..0ab99cf633 100644
--- a/ext/intl/tests/msgfmt_fail2.phpt
+++ b/ext/intl/tests/msgfmt_fail2.phpt
@@ -12,10 +12,19 @@ function err($fmt) {
}
}
+function print_exception($e) {
+ echo "\nException: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n";
+}
+
function crt($t, $l, $s) {
switch(true) {
case $t == "O":
- return new MessageFormatter($l, $s);
+ try {
+ return new MessageFormatter($l, $s);
+ } catch (IntlException $e) {
+ print_exception($e);
+ return null;
+ }
break;
case $t == "C":
return MessageFormatter::create($l, $s);
@@ -35,13 +44,23 @@ $args = array(
array("en_US", "\xD0"),
);
-$fmt = new MessageFormatter();
+try {
+ $fmt = new MessageFormatter();
+} catch (IntlException $e) {
+ print_exception($e);
+ $fmt = null;
+}
err($fmt);
$fmt = msgfmt_create();
err($fmt);
$fmt = MessageFormatter::create();
-err($fmt);
-$fmt = new MessageFormatter('en');
+err($fmt);
+try {
+ $fmt = new MessageFormatter('en');
+} catch (IntlException $e) {
+ print_exception($e);
+ $fmt = null;
+}
err($fmt);
$fmt = msgfmt_create('en');
err($fmt);
@@ -59,7 +78,7 @@ foreach($args as $arg) {
?>
--EXPECTF--
-Warning: MessageFormatter::__construct() expects exactly 2 parameters, 0 given in %s on line %d
+Exception: MessageFormatter::__construct() expects exactly 2 parameters, 0 given in %s on line %d
'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
Warning: msgfmt_create() expects exactly 2 parameters, 0 given in %s on line %d
@@ -68,7 +87,7 @@ Warning: msgfmt_create() expects exactly 2 parameters, 0 given in %s on line %d
Warning: MessageFormatter::create() expects exactly 2 parameters, 0 given in %s on line %d
'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
-Warning: MessageFormatter::__construct() expects exactly 2 parameters, 1 given in %s on line %d
+Exception: MessageFormatter::__construct() expects exactly 2 parameters, 1 given in %s on line %d
'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
Warning: msgfmt_create() expects exactly 2 parameters, 1 given in %s on line %d
@@ -76,14 +95,18 @@ Warning: msgfmt_create() expects exactly 2 parameters, 1 given in %s on line %d
Warning: MessageFormatter::create() expects exactly 2 parameters, 1 given in %s on line %d
'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+
+Exception: Constructor failed in %smsgfmt_fail2.php on line %d
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
+
+Exception: Constructor failed in %smsgfmt_fail2.php on line %d
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
-Warning: MessageFormatter::__construct() expects parameter 1 to be string, array given in %s on line %d
+Exception: MessageFormatter::__construct() expects parameter 1 to be string, array given in %s on line %d
'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
Warning: MessageFormatter::create() expects parameter 1 to be string, array given in %s on line %d
@@ -91,12 +114,18 @@ Warning: MessageFormatter::create() expects parameter 1 to be string, array give
Warning: msgfmt_create() expects parameter 1 to be string, array given in %s on line %d
'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+
+Exception: Constructor failed in %smsgfmt_fail2.php on line %d
'msgfmt_create: message formatter creation failed: U_PATTERN_SYNTAX_ERROR'
'msgfmt_create: message formatter creation failed: U_PATTERN_SYNTAX_ERROR'
'msgfmt_create: message formatter creation failed: U_PATTERN_SYNTAX_ERROR'
+
+Exception: Constructor failed in %smsgfmt_fail2.php on line %d
'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES'
'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES'
'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES'
+
+Exception: Constructor failed in %smsgfmt_fail2.php on line %d
'msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND'
'msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND'
'msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND'
diff --git a/ext/intl/tests/msgfmt_parse.phpt b/ext/intl/tests/msgfmt_parse.phpt
index 2eaf630010..b9ec36374b 100644
--- a/ext/intl/tests/msgfmt_parse.phpt
+++ b/ext/intl/tests/msgfmt_parse.phpt
@@ -36,15 +36,9 @@ function ut_main()
foreach( $locales as $locale => $pattern )
{
$str_res .= "\nLocale is: $locale\n";
- try {
- $fmt = ut_msgfmt_create( $locale, $pattern );
- if(!$fmt) {
- $str_res .= dump(intl_get_error_message())."\n";
- continue;
- }
- }
- catch (\IntlException $ie) {
- $str_res .= "IE: ".$ie->getMessage().PHP_EOL;
+ $fmt = ut_msgfmt_create( $locale, $pattern );
+ if(!$fmt) {
+ $str_res .= dump(intl_get_error_message())."\n";
continue;
}
$str_res .= dump( ut_msgfmt_parse( $fmt, $results[$locale] ) ) . "\n";
@@ -109,7 +103,7 @@ array (
)
Locale is: root
-IE: msgfmt_create: message formatter creation failed
+'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
Locale is: fr
array (
diff --git a/ext/intl/tests/resourcebundle_create.phpt b/ext/intl/tests/resourcebundle_create.phpt
index 99492a698b..2bf4f556a8 100644
--- a/ext/intl/tests/resourcebundle_create.phpt
+++ b/ext/intl/tests/resourcebundle_create.phpt
@@ -14,7 +14,6 @@ function ut_main() {
$str_res .= debug( $r1 );
$str_res .= print_r( $r1['teststring'], true)."\n";
-
// non-root one
$r1 = ut_resourcebundle_create( 'es', BUNDLE );
$str_res .= debug( $r1 );
@@ -25,22 +24,14 @@ function ut_main() {
$str_res .= debug( $r1 );
$str_res .= print_r( $r1['testsring'], true);
- try {
- // fall out
- $r2 = ut_resourcebundle_create( 'en_US', BUNDLE, false );
- }
- catch (\IntlException $ie) {
- $str_res .= "ie: ".$ie->getMessage().PHP_EOL;
- }
-
- try {
- // missing
- $r3 = ut_resourcebundle_create( 'en_US', 'nonexisting' );
- }
- catch (\IntlException $ie) {
- $str_res .= "ie: ".$ie->getMessage().PHP_EOL;
- }
+ // fall out
+ $r2 = ut_resourcebundle_create( 'en_US', BUNDLE, false );
+ $str_res .= debug( $r2 );
+ // missing
+ $r3 = ut_resourcebundle_create( 'en_US', 'nonexisting' );
+ $str_res .= debug( $r3 );
+
return $str_res;
}
@@ -65,5 +56,7 @@ ResourceBundle Object
)
-127: U_USING_DEFAULT_WARNING
-ie: resourcebundle_ctor: Cannot load libICU resource bundle
-ie: resourcebundle_ctor: Cannot load libICU resource bundle
+NULL
+ 2: resourcebundle_ctor: Cannot load libICU resource bundle: U_MISSING_RESOURCE_ERROR
+NULL
+ 2: resourcebundle_ctor: Cannot load libICU resource bundle: U_MISSING_RESOURCE_ERROR
diff --git a/ext/intl/tests/ut_common.inc b/ext/intl/tests/ut_common.inc
index 09be22bf5a..9f72bacae4 100644
--- a/ext/intl/tests/ut_common.inc
+++ b/ext/intl/tests/ut_common.inc
@@ -132,7 +132,15 @@ function ut_coll_set_default( $coll )
function ut_nfmt_create( $locale, $style, $pattern = null )
{
- return $GLOBALS['oo-mode'] ? new NumberFormatter( $locale, $style, $pattern ) : numfmt_create( $locale, $style, $pattern );
+ if ($GLOBALS['oo-mode']) {
+ try {
+ return new NumberFormatter( $locale, $style, $pattern );
+ } catch (Exception $e) {
+ return NULL;
+ }
+ } else {
+ return numfmt_create( $locale, $style, $pattern );
+ }
}
function ut_nfmt_format( $fmt, $number, $type = null )
{
@@ -392,7 +400,15 @@ function ut_datefmt_localtime( $fmt , $value , &$parse_pos=0 )
function ut_resourcebundle_create( $locale, $bundle, $fallback=true )
{
- return $GLOBALS['oo-mode'] ? new ResourceBundle($locale, $bundle, $fallback): resourcebundle_create($locale, $bundle, $fallback);
+ if ($GLOBALS['oo-mode']) {
+ try {
+ return new ResourceBundle($locale, $bundle, $fallback);
+ } catch (Exception $e) {
+ return NULL;
+ }
+ } else {
+ return resourcebundle_create($locale, $bundle, $fallback);
+ }
}
function ut_resourcebundle_count($bundle )
{
diff --git a/ext/intl/transliterator/transliterator_methods.c b/ext/intl/transliterator/transliterator_methods.c
index 7be1412b13..d8b030a6d1 100644
--- a/ext/intl/transliterator/transliterator_methods.c
+++ b/ext/intl/transliterator/transliterator_methods.c
@@ -169,7 +169,7 @@ PHP_FUNCTION( transliterator_create_from_rules )
str_rules, str_rules_len, TRANSLITERATOR_ERROR_CODE_P( to ) );
/* (I'm not a big fan of non-obvious flow control macros ).
* This one checks the error value, destroys object and returns false */
- INTL_CTOR_CHECK_STATUS( to, "String conversion of rules to UTF-16 failed", 0 );
+ INTL_CTOR_CHECK_STATUS( to, "String conversion of rules to UTF-16 failed" );
/* Open ICU Transliterator. */
utrans = utrans_openU( id, ( sizeof( id ) - 1 ) / ( sizeof( *id ) ), (UTransDirection ) direction,
@@ -197,7 +197,7 @@ PHP_FUNCTION( transliterator_create_from_rules )
}
transliterator_object_construct( object, utrans, TRANSLITERATOR_ERROR_CODE_P( to ) );
/* no need to close the transliterator manually on construction error */
- INTL_CTOR_CHECK_STATUS( to, "transliterator_create_from_rules: internal constructor call failed", 0 );
+ INTL_CTOR_CHECK_STATUS( to, "transliterator_create_from_rules: internal constructor call failed" );
}
/* }}} */
@@ -228,10 +228,10 @@ PHP_FUNCTION( transliterator_create_inverse )
utrans = utrans_openInverse( to_orig->utrans, TRANSLITERATOR_ERROR_CODE_P( to ) );
INTL_CTOR_CHECK_STATUS( to, "transliterator_create_inverse: could not create "
- "inverse ICU transliterator", 0 );
+ "inverse ICU transliterator" );
transliterator_object_construct( object, utrans, TRANSLITERATOR_ERROR_CODE_P( to ) );
/* no need to close the transliterator manually on construction error */
- INTL_CTOR_CHECK_STATUS( to, "transliterator_create: internal constructor call failed", 0 );
+ INTL_CTOR_CHECK_STATUS( to, "transliterator_create: internal constructor call failed" );
}
/* }}} */
diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c
index 1796435c5f..ed541543f9 100644
--- a/ext/pdo/pdo_dbh.c
+++ b/ext/pdo/pdo_dbh.c
@@ -209,15 +209,11 @@ static PHP_METHOD(PDO, dbh_constructor)
char alt_dsn[512];
int call_factory = 1;
zend_error_handling zeh;
- int rv;
- zend_replace_error_handling(EH_THROW, pdo_exception_ce, &zeh TSRMLS_CC);
- rv = zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!s!a!", &data_source, &data_source_len,
- &username, &usernamelen, &password, &passwordlen, &options);
- zend_restore_error_handling(&zeh TSRMLS_CC);
-
- if (FAILURE == rv) {
- ZEND_CTOR_MAKE_NULL();
+ zend_replace_error_handling(EH_THROW, pdo_exception_ce, &zeh);
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!s!a!", &data_source, &data_source_len,
+ &username, &usernamelen, &password, &passwordlen, &options)) {
+ zend_restore_error_handling(&zeh);
return;
}
@@ -230,8 +226,8 @@ static PHP_METHOD(PDO, dbh_constructor)
snprintf(alt_dsn, sizeof(alt_dsn), "pdo.dsn.%s", data_source);
if (FAILURE == cfg_get_string(alt_dsn, &ini_dsn)) {
+ zend_restore_error_handling(&zeh);
zend_throw_exception_ex(php_pdo_get_exception(), 0, "invalid data source name");
- ZEND_CTOR_MAKE_NULL();
return;
}
@@ -239,8 +235,8 @@ static PHP_METHOD(PDO, dbh_constructor)
colon = strchr(data_source, ':');
if (!colon) {
+ zend_restore_error_handling(&zeh);
zend_throw_exception_ex(php_pdo_get_exception(), 0, "invalid data source name (via INI: %s)", alt_dsn);
- ZEND_CTOR_MAKE_NULL();
return;
}
}
@@ -249,14 +245,14 @@ static PHP_METHOD(PDO, dbh_constructor)
/* the specified URI holds connection details */
data_source = dsn_from_uri(data_source + sizeof("uri:")-1, alt_dsn, sizeof(alt_dsn));
if (!data_source) {
+ zend_restore_error_handling(&zeh);
zend_throw_exception_ex(php_pdo_get_exception(), 0, "invalid data source URI");
- ZEND_CTOR_MAKE_NULL();
return;
}
colon = strchr(data_source, ':');
if (!colon) {
+ zend_restore_error_handling(&zeh);
zend_throw_exception_ex(php_pdo_get_exception(), 0, "invalid data source name (via URI)");
- ZEND_CTOR_MAKE_NULL();
return;
}
}
@@ -266,8 +262,8 @@ static PHP_METHOD(PDO, dbh_constructor)
if (!driver) {
/* NB: don't want to include the data_source in the error message as
* it might contain a password */
+ zend_restore_error_handling(&zeh);
zend_throw_exception_ex(php_pdo_get_exception(), 0, "could not find driver");
- ZEND_CTOR_MAKE_NULL();
return;
}
@@ -402,12 +398,16 @@ options:
} ZEND_HASH_FOREACH_END();
}
+ zend_restore_error_handling(&zeh);
return;
}
/* the connection failed; things will tidy up in free_storage */
/* XXX raise exception */
- ZEND_CTOR_MAKE_NULL();
+ zend_restore_error_handling(&zeh);
+ if (!EG(exception)) {
+ zend_throw_exception(pdo_exception_ce, "Constructor failed", 0);
+ }
}
/* }}} */
@@ -465,11 +465,7 @@ static void pdo_stmt_construct(zend_execute_data *execute_data, pdo_stmt_t *stmt
fcc.called_scope = Z_OBJCE_P(object);
fcc.object = Z_OBJ_P(object);
- if (zend_call_function(&fci, &fcc) == FAILURE) {
- Z_OBJ_P(object) = NULL;
- ZEND_CTOR_MAKE_NULL();
- object = NULL; /* marks failure */
- } else if (!Z_ISUNDEF(retval)) {
+ if (zend_call_function(&fci, &fcc) != FAILURE) {
zval_ptr_dtor(&retval);
}
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c
index ace865899e..d221c9ed22 100644
--- a/ext/pdo/pdo_stmt.c
+++ b/ext/pdo/pdo_stmt.c
@@ -113,8 +113,7 @@ ZEND_END_ARG_INFO()
RETURN_FALSE; \
} \
-//The class is called PDORow in userland, it is called PDOStatement in the manual.
-static PHP_FUNCTION(dbstmt_constructor) /* {{{ */
+static PHP_FUNCTION(dbrow_constructor) /* {{{ */
{
zend_throw_exception_ex(php_pdo_get_exception(), 0, "You may not create a PDORow manually");
}
@@ -2641,8 +2640,7 @@ static union _zend_function *row_get_ctor(zend_object *object)
ctor.type = ZEND_INTERNAL_FUNCTION;
ctor.function_name = zend_string_init("__construct", sizeof("__construct") - 1, 0);
ctor.scope = pdo_row_ce;
- //The class is called PDORow in userland, it is called PDOStatement in the manual.
- ctor.handler = ZEND_FN(dbstmt_constructor);
+ ctor.handler = ZEND_FN(dbrow_constructor);
ctor.fn_flags = ZEND_ACC_PUBLIC;
return (union _zend_function*)&ctor;
diff --git a/ext/pdo/tests/pdo_036.phpt b/ext/pdo/tests/pdo_036.phpt
index 16a1597f36..a9fdc9315d 100644
--- a/ext/pdo/tests/pdo_036.phpt
+++ b/ext/pdo/tests/pdo_036.phpt
@@ -7,29 +7,22 @@ Testing PDORow and PDOStatement instances with Reflection
$instance = new reflectionclass('pdostatement');
$x = $instance->newInstance();
+var_dump($x);
-if ($x instanceof pdostatement) {
- echo "Ok".PHP_EOL;
-}
-else {
- echo "Failed to create instance of pdostatment";
-}
-
-try {
- $instance = new reflectionclass('pdorow');
- $x = $instance->newInstance();
- echo "Failed to throw exception: ".var_export($x, true);
-}
-catch(PDOException $pe) {
- if ($pe->getMessage() != "You may not create a PDORow manually") {
- echo "PDOException has wrong message.";
- }
- else {
- echo "Ok".PHP_EOL;
- }
-}
+$instance = new reflectionclass('pdorow');
+$x = $instance->newInstance();
+var_dump($x);
?>
--EXPECTF--
-Ok
-Ok
+object(PDOStatement)#%d (1) {
+ [%u|b%"queryString"]=>
+ NULL
+}
+
+Fatal error: Uncaught exception 'PDOException' with message 'You may not create a PDORow manually' in %spdo_036.php:8
+Stack trace:
+#0 [internal function]: PDORow->__construct()
+#1 %spdo_036.php(8): ReflectionClass->newInstance()
+#2 {main}
+ thrown in %spdo_036.php on line 8
diff --git a/ext/pdo/tests/pdorow.phpt b/ext/pdo/tests/pdorow.phpt
index fca40a1ee1..727f60f2c7 100644
--- a/ext/pdo/tests/pdorow.phpt
+++ b/ext/pdo/tests/pdorow.phpt
@@ -5,22 +5,12 @@ Trying instantiate a PDORow object manually
--FILE--
<?php
-try {
- $instance = new PDORow;
- echo "Failed to throw exception.".var_export($instance, true);
-}
-catch(PDOException $pe) {
- if ($pe->getMessage() != "You may not create a PDORow manually") {
- echo "PDOException has wrong message.";
- }
- else {
- echo "Ok".PHP_EOL;
- }
-}
-catch(\Exception $e) {
- echo "Exception throw was not of type PDOException instead was ".get_class($e).PHP_EOL;
-}
+new PDORow;
?>
--EXPECTF--
-Ok
+Fatal error: Uncaught exception 'PDOException' with message 'You may not create a PDORow manually' in %spdorow.php:3
+Stack trace:
+#0 %spdorow.php(3): PDORow->__construct()
+#1 {main}
+ thrown in %spdorow.php on line 3
diff --git a/ext/pdo_mysql/tests/pdo_mysql___construct.phpt b/ext/pdo_mysql/tests/pdo_mysql___construct.phpt
index 0cabfe6aa3..2a890c963d 100644
--- a/ext/pdo_mysql/tests/pdo_mysql___construct.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql___construct.phpt
@@ -28,8 +28,11 @@ MySQLPDOTest::skip();
try {
- if (NULL !== ($db = @new PDO()))
- printf("[001] Too few parameters\n");
+ try {
+ if (NULL !== ($db = @new PDO()))
+ printf("[001] Too few parameters\n");
+ } catch (Exception $ex) {
+ }
print tryandcatch(2, '$db = new PDO(chr(0));');
print tryandcatch(3, '$db = new PDO("a" . chr(0) . "b");');
diff --git a/ext/pdo_mysql/tests/pdo_mysql___construct_options.phpt b/ext/pdo_mysql/tests/pdo_mysql___construct_options.phpt
index 8cd028fc53..5166958d24 100644
--- a/ext/pdo_mysql/tests/pdo_mysql___construct_options.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql___construct_options.phpt
@@ -67,8 +67,11 @@ MySQLPDOTest::skip();
PDO::MYSQL_ATTR_INIT_COMMAND => '',
);
- if (NULL !== ($db = @new PDO($dsn, $user, $pass, 'wrong type')))
- printf("[001] Expecting NULL got %s/%s\n", gettype($db), $db);
+ try {
+ if (NULL !== ($db = @new PDO($dsn, $user, $pass, 'wrong type')))
+ printf("[001] Expecting NULL got %s/%s\n", gettype($db), $db);
+ } catch (Exception $e) {
+ }
if (!is_object($db = new PDO($dsn, $user, $pass, array())))
printf("[002] Expecting object got %s/%s¸\n", gettype($db), $db);
diff --git a/ext/pdo_mysql/tests/pdo_mysql___construct_uri.phpt b/ext/pdo_mysql/tests/pdo_mysql___construct_uri.phpt
index 7e92ff2e9a..87a69125bb 100644
--- a/ext/pdo_mysql/tests/pdo_mysql___construct_uri.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql___construct_uri.phpt
@@ -68,9 +68,6 @@ MySQLPDOTest::skip();
print "done!";
?>
--EXPECTF--
-Warning: PDO::__construct(%s
[002] URI=uri:file:%spdomuri.tst, DSN=mysql%sdbname=%s, File=%spdomuri.tst (%d bytes, 'mysql%sdbname=%s'), invalid data source URI
-
-Warning: PDO::__construct(%s
[003] URI=uri:file:%spdomuri.tst, DSN=mysql%sdbname=%s, File=%spdomuri.tst (%d bytes, 'mysql%sdbname=letshopeinvalid%s'), chr(0) test, invalid data source URI
done!
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c
index 982a67ba8a..d2a63a538a 100644
--- a/ext/phar/phar_object.c
+++ b/ext/phar/phar_object.c
@@ -1149,7 +1149,7 @@ PHP_METHOD(Phar, __construct)
rv = zend_parse_parameters(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len);
zend_restore_error_handling(&zeh TSRMLS_CC);
if (rv == FAILURE) {
- //Exception was thrown already
+ /* Exception was thrown already */
return;
}
}
diff --git a/ext/phar/tests/badparameters.phpt b/ext/phar/tests/badparameters.phpt
index 781c8a3f4b..7d5525b887 100644
--- a/ext/phar/tests/badparameters.phpt
+++ b/ext/phar/tests/badparameters.phpt
@@ -7,16 +7,37 @@ phar.readonly=0
--FILE--
<?php
ini_set('phar.readonly', 1);
+
+function print_exception($e) {
+ echo "\nException: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n";
+}
+
Phar::mungServer('hi');
Phar::createDefaultStub(array());
Phar::loadPhar(array());
Phar::canCompress('hi');
-$a = new Phar(array());
-$a = new Phar(dirname(__FILE__) . '/files/frontcontroller10.phar');
+try {
+ $a = new Phar(array());
+} catch (PharException $e) {
+ print_exception($e);
+}
+try {
+ $a = new Phar(dirname(__FILE__) . '/files/frontcontroller10.phar');
+} catch (PharException $e) {
+ print_exception($e);
+}
$a->convertToExecutable(array());
$a->convertToData(array());
-$b = new PharData(dirname(__FILE__) . '/whatever.tar');
-$c = new PharData(dirname(__FILE__) . '/whatever.zip');
+try {
+ $b = new PharData(dirname(__FILE__) . '/whatever.tar');
+} catch (PharException $e) {
+ print_exception($e);
+}
+try {
+ $c = new PharData(dirname(__FILE__) . '/whatever.zip');
+} catch (PharException $e) {
+ print_exception($e);
+}
$b->delete(array());
try {
$a->delete('oops');
@@ -132,7 +153,7 @@ Warning: Phar::loadPhar() expects parameter 1 to be %string, array given in %sba
Warning: Phar::canCompress() expects parameter 1 to be integer, %string given in %sbadparameters.php on line %d
-Warning: Phar::__construct() expects parameter 1 to be %string, array given in %sbadparameters.php on line %d
+Exception: Phar::__construct() expects parameter 1 to be %string, array given in %sbadparameters.php on line %d
Warning: Phar::convertToExecutable() expects parameter 1 to be integer, array given in %sbadparameters.php on line %d
diff --git a/ext/phar/tests/bug60261.phpt b/ext/phar/tests/bug60261.phpt
index 1b6cd7a7cd..c27ff5b554 100644
--- a/ext/phar/tests/bug60261.phpt
+++ b/ext/phar/tests/bug60261.phpt
@@ -14,6 +14,8 @@ try {
?>
--EXPECTF--
-
-Warning: Phar::__construct() expects at least 1 parameter, 0 given in %s on line %d
-SplFileInfo::getLinkTarget(): Empty filename
+Fatal error: Uncaught exception 'PharException' with message 'Phar::__construct() expects at least 1 parameter, 0 given' in %sbug60261.php:3
+Stack trace:
+#0 %sbug60261.php(3): Phar->__construct()
+#1 {main}
+ thrown in %sbug60261.php on line 3
diff --git a/ext/phar/tests/pharfileinfo_construct.phpt b/ext/phar/tests/pharfileinfo_construct.phpt
index 2610095e6e..df00161d55 100644
--- a/ext/phar/tests/pharfileinfo_construct.phpt
+++ b/ext/phar/tests/pharfileinfo_construct.phpt
@@ -47,8 +47,8 @@ echo $e->getMessage() . "\n";
--EXPECTF--
Cannot open phar file 'phar://%spharfileinfo_construct.phar/oops': internal corruption of phar "%spharfileinfo_construct.phar" (truncated entry)
-Warning: PharFileInfo::__construct() expects parameter 1 to be %string, array given in %spharfileinfo_construct.php on line %d
-Cannot access phar file entry '/oops/I/do/not/exist' in archive '%spharfileinfo_construct.phar'
-Cannot call constructor twice
-'%spharfileinfo_construct.php' is not a valid phar archive URL (must have at least phar://filename.phar)
-===DONE=== \ No newline at end of file
+Fatal error: Uncaught exception 'PharException' with message 'PharFileInfo::__construct() expects parameter 1 to be string, array given' in %spharfileinfo_construct.php:13
+Stack trace:
+#0 %spharfileinfo_construct.php(13): PharFileInfo->__construct(Array)
+#1 {main}
+ thrown in %spharfileinfo_construct.php on line 13
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index e7aed4da8e..4dc0ed6868 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -1612,7 +1612,7 @@ ZEND_METHOD(reflection_function, __construct)
}
efree(lcname);
} else {
- //Exception has been thrown.
+ /* Exception has been thrown. */
return;
}
}