va_end(va);
} /* }}} */
-ZEND_API void zend_internal_type_error(zend_bool strict, const char *format, ...) /* {{{ */
+ZEND_API void zend_internal_type_error(zend_bool throw_exception, const char *format, ...) /* {{{ */
{
va_list va;
char *message = NULL;
va_start(va, format);
zend_vspprintf(&message, 0, format, va);
- if (strict) {
+ if (throw_exception) {
zend_throw_exception(zend_get_type_exception(), message, E_ERROR);
} else {
zend_error(E_WARNING, message);
ZEND_API void zend_error(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
ZEND_API void zend_type_error(const char *format, ...);
-ZEND_API void zend_internal_type_error(zend_bool strict, const char *format, ...);
+ZEND_API void zend_internal_type_error(zend_bool throw_exception, const char *format, ...);
void zenderror(const char *error);
if (!(flags & ZEND_PARSE_PARAMS_QUIET) && (*expected_type || error)) {
const char *space;
const char *class_name = get_active_class_name(&space);
+ zend_bool throw_exception =
+ ZEND_ARG_USES_STRICT_TYPES() || (flags & ZEND_PARSE_PARAMS_THROW);
if (error) {
- zend_internal_type_error(ZEND_ARG_USES_STRICT_TYPES(), "%s%s%s() expects parameter %d %s",
- class_name, space, get_active_function_name(), arg_num, error);
+ zend_internal_type_error(throw_exception, "%s%s%s() expects parameter %d %s",
+ class_name, space, get_active_function_name(), arg_num, error);
efree(error);
} else {
- zend_internal_type_error(ZEND_ARG_USES_STRICT_TYPES(), "%s%s%s() expects parameter %d to be %s, %s given",
+ zend_internal_type_error(throw_exception,
+ "%s%s%s() expects parameter %d to be %s, %s given",
class_name, space, get_active_function_name(), arg_num, expected_type,
zend_zval_type_name(arg));
}
if (!(flags & ZEND_PARSE_PARAMS_QUIET)) {
zend_function *active_function = EG(current_execute_data)->func;
const char *class_name = active_function->common.scope ? active_function->common.scope->name->val : "";
- zend_internal_type_error(ZEND_ARG_USES_STRICT_TYPES(), "%s%s%s() expects %s %d parameter%s, %d given",
+ zend_bool throw_exception =
+ ZEND_ARG_USES_STRICT_TYPES() || (flags & ZEND_PARSE_PARAMS_THROW);
+ zend_internal_type_error(throw_exception, "%s%s%s() expects %s %d parameter%s, %d given",
class_name,
class_name[0] ? "::" : "",
active_function->common.function_name->val,
}
/* }}} */
-#define RETURN_IF_ZERO_ARGS(num_args, type_spec, flags) { \
+#define RETURN_IF_ZERO_ARGS(num_args, type_spec, flags) do { \
int __num_args = (num_args); \
- \
if (0 == (type_spec)[0] && 0 != __num_args && !(flags & ZEND_PARSE_PARAMS_QUIET)) { \
const char *__space; \
const char * __class_name = get_active_class_name(&__space); \
- zend_internal_type_error(ZEND_ARG_USES_STRICT_TYPES(), "%s%s%s() expects exactly 0 parameters, %d given", \
- __class_name, __space, \
- get_active_function_name(), __num_args); \
+ zend_bool throw_exception = \
+ ZEND_ARG_USES_STRICT_TYPES() || (flags & ZEND_PARSE_PARAMS_THROW); \
+ zend_internal_type_error(throw_exception, \
+ "%s%s%s() expects exactly 0 parameters, %d given", \
+ __class_name, __space, get_active_function_name(), __num_args); \
return FAILURE; \
- }\
-}
+ } \
+} while(0)
ZEND_API int zend_parse_parameters_ex(int flags, int num_args, const char *type_spec, ...) /* {{{ */
{
}
/* }}} */
+ZEND_API int zend_parse_parameters_throw(int num_args, const char *type_spec, ...) /* {{{ */
+{
+ va_list va;
+ int retval;
+ int flags = ZEND_PARSE_PARAMS_THROW;
+
+ RETURN_IF_ZERO_ARGS(num_args, type_spec, flags);
+
+ va_start(va, type_spec);
+ retval = zend_parse_va_args(num_args, type_spec, &va, flags);
+ va_end(va);
+
+ return retval;
+}
+/* }}} */
+
ZEND_API int zend_parse_method_parameters(int num_args, zval *this_ptr, const char *type_spec, ...) /* {{{ */
{
va_list va;
/* Parameter parsing API -- andrei */
#define ZEND_PARSE_PARAMS_QUIET (1<<1)
+#define ZEND_PARSE_PARAMS_THROW (1<<2)
ZEND_API int zend_parse_parameters(int num_args, const char *type_spec, ...);
ZEND_API int zend_parse_parameters_ex(int flags, int num_args, const char *type_spec, ...);
+ZEND_API int zend_parse_parameters_throw(int num_args, const char *type_spec, ...);
ZEND_API char *zend_zval_type_name(const zval *arg);
ZEND_API int zend_parse_method_parameters(int num_args, zval *this_ptr, const char *type_spec, ...);
size_t time_str_len = 0;
zend_error_handling error_handling;
- 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)) {
- php_date_initialize(Z_PHPDATE_P(getThis()), time_str, time_str_len, NULL, timezone_object, 1);
+ if (FAILURE == zend_parse_parameters_throw(ZEND_NUM_ARGS(), "|sO!", &time_str, &time_str_len, &timezone_object, date_ce_timezone)) {
+ return;
}
+
+ zend_replace_error_handling(EH_THROW, NULL, &error_handling);
+ php_date_initialize(Z_PHPDATE_P(getThis()), time_str, time_str_len, NULL, timezone_object, 1);
zend_restore_error_handling(&error_handling);
}
/* }}} */
size_t time_str_len = 0;
zend_error_handling error_handling;
- 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)) {
- php_date_initialize(Z_PHPDATE_P(getThis()), time_str, time_str_len, NULL, timezone_object, 1);
+ if (FAILURE == zend_parse_parameters_throw(ZEND_NUM_ARGS(), "|sO!", &time_str, &time_str_len, &timezone_object, date_ce_timezone)) {
+ return;
}
+
+ zend_replace_error_handling(EH_THROW, NULL, &error_handling);
+ php_date_initialize(Z_PHPDATE_P(getThis()), time_str, time_str_len, NULL, timezone_object, 1);
zend_restore_error_handling(&error_handling);
}
/* }}} */
php_timezone_obj *tzobj;
zend_error_handling error_handling;
- 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());
- timezone_initialize(tzobj, tz);
+ if (FAILURE == zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &tz, &tz_len)) {
+ return;
}
+
+ zend_replace_error_handling(EH_THROW, NULL, &error_handling);
+ tzobj = Z_PHPTIMEZONE_P(getThis());
+ timezone_initialize(tzobj, tz);
zend_restore_error_handling(&error_handling);
}
/* }}} */
timelib_rel_time *reltime;
zend_error_handling error_handling;
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &interval_string, &interval_string_length) == FAILURE) {
+ return;
+ }
+
zend_replace_error_handling(EH_THROW, NULL, &error_handling);
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &interval_string, &interval_string_length) == SUCCESS) {
- if (date_interval_initialize(&reltime, interval_string, interval_string_length) == SUCCESS) {
- diobj = Z_PHPINTERVAL_P(getThis());
- diobj->diff = reltime;
- diobj->initialized = 1;
- }
+ if (date_interval_initialize(&reltime, interval_string, interval_string_length) == SUCCESS) {
+ diobj = Z_PHPINTERVAL_P(getThis());
+ diobj->diff = reltime;
+ diobj->initialized = 1;
}
zend_restore_error_handling(&error_handling);
}
echo "\n-- Testing new DateTimeZone() with more than expected no. of arguments --\n";
$timezone = "GMT";
$extra_arg = 99;
-var_dump( new DateTimeZone($timezone, $extra_arg) );
+try {
+ new DateTimeZone($timezone, $extra_arg);
+} catch (TypeException $e) {
+ echo $e->getMessage(), "\n";
+}
?>
===DONE===
*** Testing DateTimeZone() : error conditions ***
-- Testing new DateTimeZone() with more than expected no. of arguments --
-
-Fatal error: Uncaught exception 'Exception' with message 'DateTimeZone::__construct() expects exactly 1 parameter, 2 given' in %s:%d
-Stack trace:
-#0 %s(%d): DateTimeZone->__construct('GMT', 99)
-#1 {main}
- thrown in %s on line %d
-
\ No newline at end of file
+DateTimeZone::__construct() expects exactly 1 parameter, 2 given
+===DONE===
echo "\n-- $variation --\n";
try {
var_dump( new DateTimezone($timezone) );
- } catch(Exception $e) {
+ } catch (BaseException $e) {
$msg = $e->getMessage();
echo "FAILED: " . $msg . "\n";
}
$time = "GMT";
$timezone = timezone_open("GMT");
$extra_arg = 99;
-var_dump( new DateTime($time, $timezone, $extra_arg) );
+try {
+ var_dump( new DateTime($time, $timezone, $extra_arg) );
+} catch (TypeException $e) {
+ echo $e->getMessage(), "\n";
+}
?>
===DONE===
*** Testing date_create() : error conditions ***
-- Testing new DateTime() with more than expected no. of arguments --
-
-Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct() expects at most 2 parameters, 3 given' in %s:%d
-Stack trace:
-#0 %s(%d): DateTime->__construct('GMT', Object(DateTimeZone), 99)
-#1 {main}
- thrown in %s on line %d
\ No newline at end of file
+DateTime::__construct() expects at most 2 parameters, 3 given
+===DONE===
try {
var_dump( new DateTime($time) );
- } catch(Exception $e) {
+ } catch (BaseException $e) {
$msg = $e->getMessage();
echo "FAILED: " . $msg . "\n";
}
try {
var_dump( new DateTime($time, $timezone) );
- } catch(Exception$e) {
+ } catch (BaseException$e) {
$msg = $e->getMessage();
echo "FAILED: " . $msg . "\n";
}
try {
var_dump( new DateTime($time, $timezone) );
- } catch(Exception $e) {
+ } catch (BaseException $e) {
$msg = $e->getMessage();
echo "FAILED: " . $msg . "\n";
}
/* {{{ proto void DOMAttr::__construct(string name, [string value]); */
PHP_METHOD(domattr, __construct)
{
- zval *id;
+ zval *id = getThis();
xmlAttrPtr nodep = NULL;
xmlNodePtr oldnode = NULL;
dom_object *intern;
char *name, *value = NULL;
size_t name_len, value_len, name_valid;
- zend_error_handling error_handling;
- zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling);
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os|s", &id, dom_attr_class_entry, &name, &name_len, &value, &value_len) == FAILURE) {
- zend_restore_error_handling(&error_handling);
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|s", &name, &name_len, &value, &value_len) == FAILURE) {
return;
}
- zend_restore_error_handling(&error_handling);
intern = Z_DOMOBJ_P(id);
name_valid = xmlValidateName((xmlChar *) name, 0);
PHP_METHOD(domcdatasection, __construct)
{
- zval *id;
+ zval *id = getThis();
xmlNodePtr nodep = NULL, oldnode = NULL;
dom_object *intern;
char *value = NULL;
size_t value_len;
- zend_error_handling error_handling;
- zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling);
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &id, dom_cdatasection_class_entry, &value, &value_len) == FAILURE) {
- zend_restore_error_handling(&error_handling);
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &value, &value_len) == FAILURE) {
return;
}
- zend_restore_error_handling(&error_handling);
nodep = xmlNewCDataBlock(NULL, (xmlChar *) value, value_len);
if (!nodep) {
PHP_METHOD(domcomment, __construct)
{
- zval *id;
+ zval *id = getThis();
xmlNodePtr nodep = NULL, oldnode = NULL;
dom_object *intern;
char *value = NULL;
size_t value_len;
- zend_error_handling error_handling;
- zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling);
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|s", &id, dom_comment_class_entry, &value, &value_len) == FAILURE) {
- zend_restore_error_handling(&error_handling);
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "|s", &value, &value_len) == FAILURE) {
return;
}
- zend_restore_error_handling(&error_handling);
nodep = xmlNewComment((xmlChar *) value);
if (!nodep) {
PHP_METHOD(domdocument, __construct)
{
- zval *id;
+ zval *id = getThis();
xmlDoc *docp = NULL, *olddoc;
dom_object *intern;
char *encoding, *version = NULL;
size_t encoding_len = 0, version_len = 0;
int refcount;
- zend_error_handling error_handling;
- zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling);
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|ss", &id, dom_document_class_entry, &version, &version_len, &encoding, &encoding_len) == FAILURE) {
- zend_restore_error_handling(&error_handling);
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "|ss", &version, &version_len, &encoding, &encoding_len) == FAILURE) {
return;
}
- zend_restore_error_handling(&error_handling);
docp = xmlNewDoc((xmlChar *) version);
if (!docp) {
PHP_METHOD(domdocumentfragment, __construct)
{
- zval *id;
+ zval *id = getThis();
xmlNodePtr nodep = NULL, oldnode = NULL;
dom_object *intern;
- zend_error_handling error_handling;
- zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling);
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &id, dom_documentfragment_class_entry) == FAILURE) {
- zend_restore_error_handling(&error_handling);
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "") == FAILURE) {
return;
}
- zend_restore_error_handling(&error_handling);
nodep = xmlNewDocFragment(NULL);
if (!nodep) {
PHP_METHOD(domelement, __construct)
{
- zval *id;
+ zval *id = getThis();
xmlNodePtr nodep = NULL, oldnode = NULL;
dom_object *intern;
char *name, *value = NULL, *uri = NULL;
size_t name_len, value_len = 0, uri_len = 0;
int name_valid;
xmlNsPtr nsptr = NULL;
- zend_error_handling error_handling;
- zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling);
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os|s!s", &id, dom_element_class_entry, &name, &name_len, &value, &value_len, &uri, &uri_len) == FAILURE) {
- zend_restore_error_handling(&error_handling);
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|s!s", &name, &name_len, &value, &value_len, &uri, &uri_len) == FAILURE) {
return;
}
- zend_restore_error_handling(&error_handling);
name_valid = xmlValidateName((xmlChar *) name, 0);
if (name_valid != 0) {
/* {{{ proto void DOMEntityReference::__construct(string name); */
PHP_METHOD(domentityreference, __construct)
{
- zval *id;
+ zval *id = getThis();
xmlNode *node;
xmlNodePtr oldnode = NULL;
dom_object *intern;
char *name;
size_t name_len, name_valid;
- zend_error_handling error_handling;
- zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling);
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &id, dom_entityreference_class_entry, &name, &name_len) == FAILURE) {
- zend_restore_error_handling(&error_handling);
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &name, &name_len) == FAILURE) {
return;
}
- zend_restore_error_handling(&error_handling);
-
name_valid = xmlValidateName((xmlChar *) name, 0);
if (name_valid != 0) {
php_dom_throw_error(INVALID_CHARACTER_ERR, 1);
/* {{{ proto void DOMProcessingInstruction::__construct(string name, [string value]); */
PHP_METHOD(domprocessinginstruction, __construct)
{
- zval *id;
+ zval *id = getThis();
xmlNodePtr nodep = NULL, oldnode = NULL;
dom_object *intern;
char *name, *value = NULL;
size_t name_len, value_len;
int name_valid;
- zend_error_handling error_handling;
- zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling);
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os|s", &id, dom_processinginstruction_class_entry, &name, &name_len, &value, &value_len) == FAILURE) {
- zend_restore_error_handling(&error_handling);
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|s", &name, &name_len, &value, &value_len) == FAILURE) {
return;
}
- zend_restore_error_handling(&error_handling);
-
name_valid = xmlValidateName((xmlChar *) name, 0);
if (name_valid != 0) {
php_dom_throw_error(INVALID_CHARACTER_ERR, 1);
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
-$attr = new DOMAttr();
+try {
+ $attr = new DOMAttr();
+} catch (TypeException $e) {
+ echo $e->getMessage(), "\n";
+}
?>
--EXPECTF--
-Fatal error: Uncaught exception 'DOMException' with message 'DOMAttr::__construct() expects at least 1 parameter, 0 given' in %s:%d
-Stack trace:
-#0 %s(%d): DOMAttr->__construct()
-#1 {main}
- thrown in %s on line %d
+DOMAttr::__construct() expects at least 1 parameter, 0 given
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
- try
- {
+ try {
$section = new DOMCDataSection();
-
- }
- catch (Exception $e)
- {
+ } catch (TypeException $e) {
echo $e->getMessage();
}
?>
--EXPECT--
-DOMCdataSection::__construct() expects exactly 1 parameter, 0 given
\ No newline at end of file
+DOMCdataSection::__construct() expects exactly 1 parameter, 0 given
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
-$comment = new DOMComment("comment1", "comment2");
+try {
+ $comment = new DOMComment("comment1", "comment2");
+} catch (TypeException $e) {
+ echo $e->getMessage(), "\n";
+}
?>
--EXPECTF--
-Fatal error: Uncaught exception 'DOMException' with message 'DOMComment::__construct() expects at most 1 parameter, 2 given' in %s:%d
-Stack trace:
-#0 %s(%d): DOMComment->__construct('comment1', 'comment2')
-#1 {main}
- thrown in %s on line %d
\ No newline at end of file
+DOMComment::__construct() expects at most 1 parameter, 2 given
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
-$fragment = new DOMDocumentFragment("root");
+try {
+ $fragment = new DOMDocumentFragment("root");
+} catch (TypeException $e) {
+ echo $e->getMessage(), "\n";
+}
?>
--EXPECTF--
-Fatal error: Uncaught exception 'DOMException' with message 'DOMDocumentFragment::__construct() expects exactly 0 parameters, 1 given' in %s:%d
-Stack trace:
-#0 %s(%d): DOMDocumentFragment->__construct('root')
-#1 {main}
- thrown in %s on line %d
\ No newline at end of file
+DOMDocumentFragment::__construct() expects exactly 0 parameters, 1 given
PHP_METHOD(domtext, __construct)
{
- zval *id;
+ zval *id = getThis();
xmlNodePtr nodep = NULL, oldnode = NULL;
dom_object *intern;
char *value = NULL;
size_t value_len;
- zend_error_handling error_handling;
- zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling);
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|s", &id, dom_text_class_entry, &value, &value_len) == FAILURE) {
- zend_restore_error_handling(&error_handling);
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "|s", &value, &value_len) == FAILURE) {
return;
}
- zend_restore_error_handling(&error_handling);
nodep = xmlNewText((xmlChar *) value);
if (!nodep) {
/* {{{ proto void DOMXPath::__construct(DOMDocument doc) U */
PHP_METHOD(domxpath, __construct)
{
- zval *id, *doc;
+ zval *id = getThis(), *doc;
xmlDocPtr docp = NULL;
dom_object *docobj;
dom_xpath_object *intern;
xmlXPathContextPtr ctx, oldctx;
- zend_error_handling error_handling;
- zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling);
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &id, dom_xpath_class_entry, &doc, dom_document_class_entry) == FAILURE) {
- zend_restore_error_handling(&error_handling);
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "O", &doc, dom_document_class_entry) == FAILURE) {
return;
}
- zend_restore_error_handling(&error_handling);
DOM_GET_OBJ(docp, doc, xmlDocPtr, docobj);
ctx = xmlXPathNewContext(docp);
FILEINFO_DECLARE_INIT_OBJECT(object)
char resolved_path[MAXPATHLEN];
zend_error_handling zeh;
+ int flags = object ? ZEND_PARSE_PARAMS_THROW : 0;
- if (object) {
- zend_replace_error_handling(EH_THROW, NULL, &zeh);
- }
- 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);
- }
- }
+ if (zend_parse_parameters_ex(flags, ZEND_NUM_ARGS(), "|lp", &options, &file, &file_len) == FAILURE) {
RETURN_FALSE;
}
if (object) {
finfo_object *finfo_obj = Z_FINFO_P(object);
+ zend_replace_error_handling(EH_THROW, NULL, &zeh);
+
if (finfo_obj->ptr) {
magic_close(finfo_obj->ptr->magic);
efree(finfo_obj->ptr);
--FILE--
<?php
-$finfo = new finfo(1, '', false);
-var_dump($finfo);
+try {
+ $finfo = new finfo(1, '', false);
+ var_dump($finfo);
+} catch (TypeException $e) {
+ echo $e->getMessage(), "\n";
+}
--EXPECTF--
-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
+finfo::finfo() expects at most 2 parameters, 3 given
var_dump( finfo_open( PHP_INT_MAX - 1, $magicFile ) );
var_dump( finfo_open( 'foobar' ) );
-var_dump( new finfo('foobar') );
+try {
+ var_dump( new finfo('foobar') );
+} catch (TypeException $e) {
+ echo $e->getMessage(), "\n";
+}
?>
===DONE===
Warning: finfo_open() expects parameter 1 to be integer, string given in %sfinfo_open_error.php on line 16
bool(false)
-
-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
+finfo::finfo() expects parameter 1 to be integer, string given
+===DONE===
static void _php_intlrbbi_constructor_body(INTERNAL_FUNCTION_PARAMETERS)
{
- zval *object = getThis();
char *rules;
size_t rules_len;
zend_bool compiled = 0;
UErrorCode status = U_ZERO_ERROR;
intl_error_reset(NULL);
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b",
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|b",
&rules, &rules_len, &compiled) == FAILURE) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"rbbi_create_instance: bad arguments", 0);
return (GregorianCalendar*)co->ucal;
}
-static void _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAMETERS)
+static void _php_intlgregcal_constructor_body(
+ INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
{
zval *tz_object = NULL;
zval args_a[6] = {0},
zend_long largs[6];
UErrorCode status = U_ZERO_ERROR;
int variant;
+ int zpp_flags = is_constructor ? ZEND_PARSE_PARAMS_THROW : 0;
intl_error_reset(NULL);
// parameter number validation / variant determination
// argument parsing
if (variant <= 2) {
- if (zend_parse_parameters(MIN(ZEND_NUM_ARGS(), 2),
+ if (zend_parse_parameters_ex(zpp_flags, MIN(ZEND_NUM_ARGS(), 2),
"|z!s!", &tz_object, &locale, &locale_len) == FAILURE) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"intlgregcal_create_instance: bad arguments", 0);
return;
}
}
- if (variant > 2 && zend_parse_parameters(ZEND_NUM_ARGS(),
+ if (variant > 2 && zend_parse_parameters_ex(zpp_flags, ZEND_NUM_ARGS(),
"lll|lll", &largs[0], &largs[1], &largs[2], &largs[3], &largs[4],
&largs[5]) == FAILURE) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
object_init_ex(return_value, GregorianCalendar_ce_ptr);
ZVAL_COPY_VALUE(&orig, return_value);
- _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
zval_dtor(&orig);
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);
+ _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
if (!EG(exception)) {
zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0);
#include "intl_data.h"
/* {{{ */
-static void collator_ctor(INTERNAL_FUNCTION_PARAMETERS)
+static void collator_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
{
const char* locale;
size_t locale_len = 0;
zval* object;
Collator_object* co;
+ int zpp_flags = is_constructor ? ZEND_PARSE_PARAMS_THROW : 0;
intl_error_reset( NULL );
object = return_value;
/* Parse parameters. */
- if( zend_parse_parameters( ZEND_NUM_ARGS(), "s",
+ if( zend_parse_parameters_ex( zpp_flags, ZEND_NUM_ARGS(), "s",
&locale, &locale_len ) == FAILURE )
{
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
PHP_FUNCTION( collator_create )
{
object_init_ex( return_value, Collator_ce_ptr );
- collator_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ collator_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
}
/* }}} */
zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, &error_handling);
return_value = getThis();
- collator_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ collator_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
if (!EG(exception)) {
zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0);
size_t src_len = sizeof("utf-8") - 1;
char *dest = src;
size_t dest_len = src_len;
- zend_error_handling zeh;
- int rv;
intl_error_reset(NULL);
- 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);
-
- if (rv == FAILURE) {
- intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "UConverter::__construct(): bad arguments", 0);
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "|s!s!", &dest, &dest_len, &src, &src_len) == FAILURE) {
return;
}
#include "zend_exceptions.h"
/* {{{ */
-static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
+static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
{
zval *object;
UChar* svalue = NULL; /* UTF-16 pattern_str */
int32_t slength = 0;
IntlDateFormatter_object* dfo;
+ int zpp_flags = is_constructor ? ZEND_PARSE_PARAMS_THROW : 0;
intl_error_reset(NULL);
object = return_value;
/* Parse parameters. */
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "sll|zzs",
+ if (zend_parse_parameters_ex(zpp_flags, 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( NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: "
U_CFUNC PHP_FUNCTION( datefmt_create )
{
object_init_ex( return_value, IntlDateFormatter_ce_ptr );
- datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
RETURN_NULL();
}
/* return_value param is being changed, therefore we will always return
* NULL here */
return_value = getThis();
- datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
if (!EG(exception)) {
zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0);
#include "intl_convert.h"
/* {{{ */
-static void numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
+static void numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
{
const char* locale;
char* pattern = NULL;
zend_long style;
UChar* spattern = NULL;
int32_t spattern_len = 0;
+ int zpp_flags = is_constructor ? ZEND_PARSE_PARAMS_THROW : 0;
FORMATTER_METHOD_INIT_VARS;
/* Parse parameters. */
- if( zend_parse_parameters( ZEND_NUM_ARGS(), "sl|s",
+ if( zend_parse_parameters_ex( zpp_flags, ZEND_NUM_ARGS(), "sl|s",
&locale, &locale_len, &style, &pattern, &pattern_len ) == FAILURE )
{
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
PHP_FUNCTION( numfmt_create )
{
object_init_ex( return_value, NumberFormatter_ce_ptr );
- numfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ numfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
RETURN_NULL();
}
zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, &error_handling);
return_value = getThis();
- numfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ numfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
if (!EG(exception)) {
zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 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( intl_error* err, char* msg, int copyMsg )
+void intl_error_set_custom_msg( intl_error* err, const char* msg, int copyMsg )
{
if( !msg )
return;
err->free_custom_error_message = copyMsg;
/* Set user's error text message */
- err->custom_error_message = copyMsg ? estrdup( msg ) : msg;
+ err->custom_error_message = copyMsg ? estrdup( msg ) : (char *) msg;
}
/* }}} */
/* {{{ void intl_error_set( intl_error* err, UErrorCode code, char* msg, int copyMsg )
* Set error code and message.
*/
-void intl_error_set( intl_error* err, UErrorCode code, char* msg, int copyMsg )
+void intl_error_set( intl_error* err, UErrorCode code, const char* msg, int copyMsg )
{
intl_error_set_code( err, code );
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 )
+void intl_errors_set( intl_error* err, UErrorCode code, const char* msg, int copyMsg )
{
intl_errors_set_code( err, code );
intl_errors_set_custom_msg( err, msg, copyMsg );
/* {{{ void intl_errors_set_custom_msg( intl_error* err, char* msg, int copyMsg )
*/
-void intl_errors_set_custom_msg( intl_error* err, char* msg, int copyMsg )
+void intl_errors_set_custom_msg( intl_error* err, const char* msg, int copyMsg )
{
if(err) {
intl_error_set_custom_msg( err, msg, copyMsg );
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( intl_error* err, UErrorCode code, char* msg, int copyMsg );
+void intl_error_set_custom_msg( intl_error* err, const char* msg, int copyMsg );
+void intl_error_set( intl_error* err, UErrorCode code, const char* msg, int copyMsg );
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( intl_error* err, const char* msg, int copyMsg );
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( intl_error* err, UErrorCode code, const char* msg, int copyMsg );
// Other error helpers
smart_str intl_parse_error_to_string( UParseError* pe );
#include "intl_convert.h"
/* {{{ */
-static void msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
+static void msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
{
const char* locale;
char* pattern;
int spattern_len = 0;
zval* object;
MessageFormatter_object* mfo;
+ int zpp_flags = is_constructor ? ZEND_PARSE_PARAMS_THROW : 0;
intl_error_reset( NULL );
object = return_value;
/* Parse parameters. */
- if( zend_parse_parameters( ZEND_NUM_ARGS(), "ss",
+ if( zend_parse_parameters_ex( zpp_flags, ZEND_NUM_ARGS(), "ss",
&locale, &locale_len, &pattern, &pattern_len ) == FAILURE )
{
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
PHP_FUNCTION( msgfmt_create )
{
object_init_ex( return_value, MessageFormatter_ce_ptr );
- msgfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ msgfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
RETURN_NULL();
}
zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, &error_handling);
return_value = getThis();
- msgfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ msgfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
if (!EG(exception)) {
zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0);
/* }}} */
/* {{{ ResourceBundle_ctor */
-static void resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS)
+static void resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
{
const char *bundlename;
size_t bundlename_len = 0;
const char *locale;
size_t locale_len = 0;
zend_bool fallback = 1;
+ int zpp_flags = is_constructor ? ZEND_PARSE_PARAMS_THROW : 0;
zval *object = return_value;
ResourceBundle_object *rb = Z_INTL_RESOURCEBUNDLE_P( object );
intl_error_reset( NULL );
- if( zend_parse_parameters( ZEND_NUM_ARGS(), "s!s!|b",
+ if( zend_parse_parameters_ex( zpp_flags, ZEND_NUM_ARGS(), "s!s!|b",
&locale, &locale_len, &bundlename, &bundlename_len, &fallback ) == FAILURE )
{
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, &error_handling);
return_value = getThis();
- resourcebundle_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ resourcebundle_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
if (!EG(exception)) {
zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0);
PHP_FUNCTION( resourcebundle_create )
{
object_init_ex( return_value, ResourceBundle_ce_ptr );
- resourcebundle_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ resourcebundle_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
RETURN_NULL();
}
zend_error_handling error_handling;
SPOOFCHECKER_METHOD_INIT_VARS;
- zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, &error_handling);
-
- if (zend_parse_parameters_none() == FAILURE) {
- zend_restore_error_handling(&error_handling);
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "") == FAILURE) {
return;
}
+ zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, &error_handling);
+
SPOOFCHECKER_METHOD_FETCH_OBJECT_NO_CHECK;
co->uspoof = uspoof_open(SPOOFCHECKER_ERROR_CODE_P(co));
}
try {
var_dump(new IntlRuleBasedBreakIterator());
-} catch (IntlException $e) {
+} catch (TypeException $e) {
print_exception($e);
}
try {
var_dump(new IntlRuleBasedBreakIterator(1,2,3));
-} catch (IntlException $e) {
+} catch (TypeException $e) {
print_exception($e);
}
try {
var_dump(new IntlRuleBasedBreakIterator('[\p{Letter}\uFFFD]+;[:number:]+;', array()));
-} catch (IntlException $e) {
+} catch (TypeException $e) {
print_exception($e);
}
try {
}
function print_exception($e) {
- echo "\nException: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n";
+ echo "\n" . get_class($e) . ": " . $e->getMessage()
+ . " in " . $e->getFile() . " on line " . $e->getLine() . "\n";
}
function crt($t, $l, $s) {
case $t == "O":
try {
return new NumberFormatter($l, $s);
- } catch (IntlException $e) {
+ } catch (BaseException $e) {
print_exception($e);
return null;
}
try {
$fmt = new NumberFormatter();
-} catch (IntlException $e) {
+} catch (TypeException $e) {
print_exception($e);
$fmt = null;
}
?>
--EXPECTF--
-Exception: NumberFormatter::__construct() expects at least 2 parameters, 0 given in %s on line %d
+TypeException: 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
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
+IntlException: 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: NumberFormatter::__construct() expects parameter 1 to be string, array given in %s on line %d
+TypeException: 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
Warning: numfmt_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'
-Exception: Constructor failed in %sformatter_fail.php on line %d
+IntlException: 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
+IntlException: 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'
}
try {
var_dump(new IntlGregorianCalendar(1,2,3,4,NULL,array()));
-} catch (IntlException $e) {
+} catch (TypeException $e) {
print_exception($e);
}
--EXPECTF--
}
function print_exception($e) {
- echo "\nException: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n";
+ echo "\n" . get_class($e) . ": " . $e->getMessage()
+ . " in " . $e->getFile() . " on line " . $e->getLine() . "\n";
}
function crt($t, $l, $s) {
case $t == "O":
try {
return new MessageFormatter($l, $s);
- } catch (IntlException $e) {
+ } catch (BaseException $e) {
print_exception($e);
return null;
}
try {
$fmt = new MessageFormatter();
-} catch (IntlException $e) {
+} catch (TypeException $e) {
print_exception($e);
$fmt = null;
}
err($fmt);
try {
$fmt = new MessageFormatter('en');
-} catch (IntlException $e) {
+} catch (TypeException $e) {
print_exception($e);
$fmt = null;
}
?>
--EXPECTF--
-Exception: MessageFormatter::__construct() expects exactly 2 parameters, 0 given in %s on line %d
+TypeException: 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
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'
-Exception: MessageFormatter::__construct() expects exactly 2 parameters, 1 given in %s on line %d
+TypeException: 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
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
+IntlException: 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
+IntlException: 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: MessageFormatter::__construct() expects parameter 1 to be string, array given in %s on line %d
+TypeException: 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
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
+IntlException: 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
+IntlException: 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
+IntlException: 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'
}
function print_exception($e) {
- echo "\nException: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n";
+ echo "\n" . get_class($e) . ": " . $e->getMessage()
+ . " in " . $e->getFile() . " on line " . $e->getLine() . "\n";
}
function crt($t, $l, $s) {
case $t == "O":
try {
return new MessageFormatter($l, $s);
- } catch (IntlException $e) {
+ } catch (BaseException $e) {
print_exception($e);
return null;
}
try {
$fmt = new MessageFormatter();
-} catch (IntlException $e) {
+} catch (TypeException $e) {
print_exception($e);
$fmt = null;
}
err($fmt);
try {
$fmt = new MessageFormatter('en');
-} catch (IntlException $e) {
+} catch (TypeException $e) {
print_exception($e);
$fmt = null;
}
?>
--EXPECTF--
-Exception: MessageFormatter::__construct() expects exactly 2 parameters, 0 given in %s on line %d
+TypeException: 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
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'
-Exception: MessageFormatter::__construct() expects exactly 2 parameters, 1 given in %s on line %d
+TypeException: 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
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
+IntlException: 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
+IntlException: 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: MessageFormatter::__construct() expects parameter 1 to be string, array given in %s on line %d
+TypeException: 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
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
+IntlException: 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
+IntlException: 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
+IntlException: 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'
int call_factory = 1;
zend_error_handling zeh;
- 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,
+ if (FAILURE == zend_parse_parameters_throw(ZEND_NUM_ARGS(),
+ "s|s!s!a!", &data_source, &data_source_len,
&username, &usernamelen, &password, &passwordlen, &options)) {
- zend_restore_error_handling(&zeh);
return;
}
- zend_restore_error_handling(&zeh);
/* parse the data source name */
colon = strchr(data_source, ':');
try {
if (NULL !== ($db = @new PDO()))
printf("[001] Too few parameters\n");
- } catch (Exception $ex) {
+ } catch (TypeException $ex) {
}
print tryandcatch(2, '$db = new PDO(chr(0));');
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) {
+ } catch (TypeException $e) {
}
if (!is_object($db = new PDO($dsn, $user, $pass, array())))
phar_archive_object *phar_obj;
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1, arg2;
- zend_error_handling zeh;
- int rv;
phar_obj = (phar_archive_object*)((char*)Z_OBJ_P(zobj) - Z_OBJ_P(zobj)->handlers->offset);
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- zend_replace_error_handling(EH_THROW, phar_ce_PharException, &zeh TSRMLS_CC);
- rv = zend_parse_parameters(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format);
- zend_restore_error_handling(&zeh TSRMLS_CC);
- if (rv == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- zend_replace_error_handling(EH_THROW, phar_ce_PharException, &zeh TSRMLS_CC);
- 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 */
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
phar_entry_info *entry_info;
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- zend_error_handling zeh;
- int rv;
- zend_replace_error_handling(EH_THROW, phar_ce_PharException, &zeh TSRMLS_CC);
- rv = zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len);
- zend_restore_error_handling(&zeh TSRMLS_CC);
-
- if (rv == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
return;
}
Phar::canCompress('hi');
try {
$a = new Phar(array());
-} catch (PharException $e) {
+} catch (TypeException $e) {
print_exception($e);
}
try {
--FILE--
<?php
-$nx = new Phar();
try {
+ $nx = new Phar();
$nx->getLinkTarget();
-} catch (Exception $e) {
+} catch (TypeException $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECTF--
-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
+Phar::__construct() expects at least 1 parameter, 0 given
unlink($fname);
}
+try {
$a = new PharFileInfo(array());
+} catch (TypeException $e) {
+echo $e->getMessage() . "\n";
+}
$a = new Phar($fname);
$a['a'] = 'hi';
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar'); ?>
--EXPECTF--
Cannot open phar file 'phar://%spharfileinfo_construct.phar/oops': internal corruption of phar "%spharfileinfo_construct.phar" (truncated entry)
-
-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
+PharFileInfo::__construct() expects parameter 1 to be string, array given
+Cannot access phar file entry '%s' in archive '%s'
+Cannot call constructor twice
+'%s' is not a valid phar archive URL (must have at least phar://filename.phar)
+===DONE===
zval name;
zval *object;
zval *closure = NULL;
- char *lcname;
+ char *lcname, *nsname;
reflection_object *intern;
zend_function *fptr;
char *name_str;
size_t name_len;
- int rv;
- zend_error_handling zeh;
object = getThis();
intern = Z_REFLECTION_P(object);
fptr = (zend_function*)zend_get_closure_method_def(closure);
Z_ADDREF_P(closure);
} else {
- zend_replace_error_handling(EH_THROW, reflection_exception_ptr, &zeh TSRMLS_CC);
- rv = zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name_str, &name_len);
- zend_restore_error_handling(&zeh TSRMLS_CC);
- if (rv == SUCCESS) {
- char *nsname;
- lcname = zend_str_tolower_dup(name_str, name_len);
-
- /* Ignore leading "\" */
- nsname = lcname;
- if (lcname[0] == '\\') {
- nsname = &lcname[1];
- name_len--;
- }
-
- if ((fptr = zend_hash_str_find_ptr(EG(function_table), nsname, name_len)) == NULL) {
- efree(lcname);
- zend_throw_exception_ex(reflection_exception_ptr, 0,
- "Function %s() does not exist", name_str);
- return;
- }
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &name_str, &name_len) == FAILURE) {
+ return;
+ }
+
+ lcname = zend_str_tolower_dup(name_str, name_len);
+
+ /* Ignore leading "\" */
+ nsname = lcname;
+ if (lcname[0] == '\\') {
+ nsname = &lcname[1];
+ name_len--;
+ }
+
+ if ((fptr = zend_hash_str_find_ptr(EG(function_table), nsname, name_len)) == NULL) {
efree(lcname);
- } else {
- /* Exception has been thrown. */
+ zend_throw_exception_ex(reflection_exception_ptr, 0,
+ "Function %s() does not exist", name_str);
return;
}
+ efree(lcname);
}
ZVAL_STR_COPY(&name, fptr->common.function_name);
zend_class_entry *ce = NULL;
zend_bool is_closure = 0;
zend_bool is_invoke = 0;
- zend_error_handling zeh;
- zend_replace_error_handling(EH_THROW, reflection_exception_ptr, &zeh TSRMLS_CC);
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "zz", &reference, ¶meter) == FAILURE) {
- zend_restore_error_handling(&zeh TSRMLS_CC);
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "zz", &reference, ¶meter) == FAILURE) {
return;
}
- zend_restore_error_handling(&zeh TSRMLS_CC);
object = getThis();
intern = Z_REFLECTION_P(object);
zval ztmp;
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "zs", &classname, &name_str, &name_len) == FAILURE) {
- zend_error_handling zeh;
- int rv;
-
- zend_replace_error_handling(EH_THROW, reflection_exception_ptr, &zeh TSRMLS_CC);
- rv = zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name_str, &name_len);
- zend_restore_error_handling(&zeh TSRMLS_CC);
- if (rv == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &name_str, &name_len) == FAILURE) {
return;
}
+
if ((tmp = strstr(name_str, "::")) == NULL) {
- zend_throw_exception_ex(reflection_exception_ptr, 0, "Invalid method name %s", name_str);
+ zend_throw_exception_ex(reflection_exception_ptr, 0,
+ "Invalid method name %s", name_str);
return;
}
classname = &ztmp;
zend_property_info *property_info = NULL;
property_reference *reference;
- int rv;
- zend_error_handling zeh;
-
- zend_replace_error_handling(EH_THROW, reflection_exception_ptr, &zeh TSRMLS_CC);
- rv = zend_parse_parameters(ZEND_NUM_ARGS(), "zs", &classname, &name_str, &name_len);
- zend_restore_error_handling(&zeh TSRMLS_CC);
-
- if (rv == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "zs", &classname, &name_str, &name_len) == FAILURE) {
return;
}
zend_module_entry *module;
char *name_str;
size_t name_len;
- int rv;
- zend_error_handling zeh;
ALLOCA_FLAG(use_heap)
- zend_replace_error_handling(EH_THROW, reflection_exception_ptr, &zeh TSRMLS_CC);
- rv = zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name_str, &name_len);
- zend_restore_error_handling(&zeh TSRMLS_CC);
-
- if (rv == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &name_str, &name_len) == FAILURE) {
return;
}
zend_extension *extension;
char *name_str;
size_t name_len;
- int rv;
- zend_error_handling zeh;
-
- zend_replace_error_handling(EH_THROW, reflection_exception_ptr, &zeh TSRMLS_CC);
- rv = zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name_str, &name_len);
- zend_restore_error_handling(&zeh TSRMLS_CC);
- if (rv == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &name_str, &name_len) == FAILURE) {
return;
}
<?php
try {
$obj = new ReflectionExtension();
-}
-catch(ReflectionException $re) {
+} catch (TypeException $re) {
echo "Ok - ".$re->getMessage().PHP_EOL;
}
try {
$obj = new ReflectionExtension('foo', 'bar');
-}
-catch(ReflectionException $re) {
+} catch (TypeException $re) {
echo "Ok - ".$re->getMessage().PHP_EOL;
}
try {
$obj = new ReflectionExtension([]);
-}
-catch(ReflectionException $re) {
+} catch (TypeException $re) {
echo "Ok - ".$re->getMessage().PHP_EOL;
}
try {
$a = new ReflectionFunction(array(1, 2, 3));
echo "exception not thrown.".PHP_EOL;
-}
-catch(ReflectionException $re) {
+} catch (TypeException $re) {
echo "Ok - ".$re->getMessage().PHP_EOL;
}
try {
$a = new ReflectionFunction('nonExistentFunction');
-} catch (Exception $e) {
+} catch (ReflectionException $e) {
echo $e->getMessage().PHP_EOL;
}
try {
$a = new ReflectionFunction();
-}
-catch(ReflectionException $re) {
+} catch (TypeException $re) {
echo "Ok - ".$re->getMessage().PHP_EOL;
}
try {
$a = new ReflectionFunction(1, 2);
-}
-catch(ReflectionException $re) {
+} catch (TypeException $re) {
echo "Ok - ".$re->getMessage().PHP_EOL;
}
try {
$a = new ReflectionFunction([]);
-}
-catch(ReflectionException $re) {
+} catch (TypeException $re) {
echo "Ok - ".$re->getMessage().PHP_EOL;
}
try {
new ReflectionMethod();
-}
-catch(ReflectionException $re) {
+} catch (TypeException $re) {
echo "Ok - ".$re->getMessage().PHP_EOL;
}
try {
new ReflectionMethod('a', 'b', 'c');
-}
-catch(ReflectionException $re) {
+} catch (TypeException $re) {
echo "Ok - ".$re->getMessage().PHP_EOL;
}
try {
echo "Too few arguments:\n";
$methodInfo = new ReflectionMethod();
-} catch (ReflectionException $re) {
+} catch (TypeException $re) {
echo "Ok - ".$re->getMessage().PHP_EOL;
}
try {
echo "\nToo many arguments:\n";
$methodInfo = new ReflectionMethod("TestClass", "foo", true);
-} catch (ReflectionException $re) {
+} catch (TypeException $re) {
echo "Ok - ".$re->getMessage().PHP_EOL;
}
try{
//invalid 2nd param
$methodInfo = new ReflectionMethod("TestClass", []);
-} catch (ReflectionException $re) {
+} catch (TypeException $re) {
echo "Ok - ".$re->getMessage().PHP_EOL;
}
try {
new ReflectionParameter(array ('A', 'b'));
}
-catch(ReflectionException $e) {
+catch(TypeException $e) {
printf( "Ok - %s\n", $e->getMessage());
}
try {
new ReflectionProperty();
-}
-catch(ReflectionException $re) {
+} catch (TypeException $re) {
echo "Ok - ".$re->getMessage().PHP_EOL;
}
try {
new ReflectionProperty('C::p');
-}
-catch(ReflectionException $re) {
+} catch (TypeException $re) {
echo "Ok - ".$re->getMessage().PHP_EOL;
}
try {
new ReflectionProperty('C', 'p', 'x');
-}
-catch(ReflectionException $re) {
+} catch (TypeException $re) {
echo "Ok - ".$re->getMessage().PHP_EOL;
}
xmlDocPtr docp;
zend_long options = 0;
zend_bool is_url = 0, isprefix = 0;
- zend_error_handling error_handling;
- zend_replace_error_handling(EH_THROW, NULL, &error_handling);
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|lbsb", &data, &data_len, &options, &is_url, &ns, &ns_len, &isprefix) == FAILURE) {
- zend_restore_error_handling(&error_handling);
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|lbsb", &data, &data_len, &options, &is_url, &ns, &ns_len, &isprefix) == FAILURE) {
return;
}
- zend_restore_error_handling(&error_handling);
-
docp = is_url ? xmlReadFile(data, NULL, options) : xmlReadMemory(data, data_len, NULL, NULL, options);
if (!docp) {
zend_long retries = SNMP_DEFAULT_RETRIES;
zend_long version = SNMP_DEFAULT_VERSION;
int argc = ZEND_NUM_ARGS();
- zend_error_handling error_handling;
snmp_object = Z_SNMP_P(object);
- zend_replace_error_handling(EH_THROW, NULL, &error_handling);
- if (zend_parse_parameters(argc, "lss|ll", &version, &a1, &a1_len, &a2, &a2_len, &timeout, &retries) == FAILURE) {
- zend_restore_error_handling(&error_handling);
+ if (zend_parse_parameters_throw(argc, "lss|ll", &version, &a1, &a1_len, &a2, &a2_len, &timeout, &retries) == FAILURE) {
return;
}
- zend_restore_error_handling(&error_handling);
-
- switch(version) {
+ switch (version) {
case SNMP_VERSION_1:
case SNMP_VERSION_2c:
case SNMP_VERSION_3:
zval *array;
zend_long ar_flags = 0;
zend_class_entry *ce_get_iterator = spl_ce_Iterator;
- zend_error_handling error_handling;
if (ZEND_NUM_ARGS() == 0) {
return; /* nothing to do */
}
- zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling);
-
- intern = Z_SPLARRAY_P(object);
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|lC", &array, &ar_flags, &ce_get_iterator) == FAILURE) {
- zend_restore_error_handling(&error_handling);
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "z|lC", &array, &ar_flags, &ce_get_iterator) == FAILURE) {
return;
}
+ intern = Z_SPLARRAY_P(object);
+
if (ZEND_NUM_ARGS() > 2) {
intern->ce_get_iterator = ce_get_iterator;
}
ar_flags &= ~SPL_ARRAY_INT_MASK;
spl_array_set_array(object, intern, array, ar_flags, ZEND_NUM_ARGS() == 1);
-
- zend_restore_error_handling(&error_handling);
-
}
/* }}} */
/* {{{ proto void SplFileInfo::__construct(string file_name)
Cronstructs a new SplFileInfo from a path. */
-/* zend_replace_error_handling() is used to throw exceptions in case
- the constructor fails. Here we use this to ensure the object
- has a valid directory resource.
-
- When the constructor gets called the object is already created
+/* When the constructor gets called the object is already created
by the engine, so we must only call 'additional' initializations.
*/
SPL_METHOD(SplFileInfo, __construct)
spl_filesystem_object *intern;
char *path;
size_t len;
- zend_error_handling error_handling;
-
- zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling);
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &path, &len) == FAILURE) {
- zend_restore_error_handling(&error_handling);
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &path, &len) == FAILURE) {
return;
}
spl_filesystem_info_set_filename(intern, path, len, 1);
- zend_restore_error_handling(&error_handling);
-
/* intern->type = SPL_FS_INFO; already set */
}
/* }}} */
size_t tmp_path_len;
zend_error_handling error_handling;
- zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling);
-
intern->u.file.open_mode = NULL;
intern->u.file.open_mode_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|sbr!",
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|sbr!",
&intern->file_name, &intern->file_name_len,
&intern->u.file.open_mode, &intern->u.file.open_mode_len,
&use_include_path, &intern->u.file.zcontext) == FAILURE) {
intern->u.file.open_mode = NULL;
intern->file_name = NULL;
- zend_restore_error_handling(&error_handling);
return;
}
intern->u.file.open_mode_len = 1;
}
+ zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling);
+
if (spl_filesystem_file_open(intern, use_include_path, 0) == SUCCESS) {
tmp_path_len = strlen(intern->u.file.stream->orig_path);
spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
zend_error_handling error_handling;
- zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling);
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &max_memory) == FAILURE) {
- zend_restore_error_handling(&error_handling);
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "|l", &max_memory) == FAILURE) {
return;
}
intern->u.file.open_mode = "wb";
intern->u.file.open_mode_len = 1;
+ zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling);
if (spl_filesystem_file_open(intern, 0, 0) == SUCCESS) {
intern->_path_len = 0;
intern->_path = estrndup("", 0);
spl_fixedarray_object *intern;
zend_long size = 0;
- int rv;
- zend_error_handling zeh;
-
- zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &zeh TSRMLS_CC);
- rv = zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &size);
- zend_restore_error_handling(&zeh TSRMLS_CC);
-
- if (rv == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "|l", &size) == FAILURE) {
return;
}
data = iterator->funcs->get_current_data(iterator);
+ /* Replace exception handling so the catchable fatal error that is thrown when a class
+ * without __toString is converted to string is converted into an exception. */
zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, &error_handling);
if (data) {
RETVAL_ZVAL(data, 1, 0);
return NULL;
}
- zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling);
-
intern->dit_type = dit_type;
switch (dit_type) {
case DIT_LimitIterator: {
intern->u.limit.offset = 0; /* start at beginning */
intern->u.limit.count = -1; /* get all */
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|ll", &zobject, ce_inner, &intern->u.limit.offset, &intern->u.limit.count) == FAILURE) {
- zend_restore_error_handling(&error_handling);
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "O|ll", &zobject, ce_inner, &intern->u.limit.offset, &intern->u.limit.count) == FAILURE) {
return NULL;
}
if (intern->u.limit.offset < 0) {
zend_throw_exception(spl_ce_OutOfRangeException, "Parameter offset must be >= 0", 0);
- zend_restore_error_handling(&error_handling);
return NULL;
}
if (intern->u.limit.count < 0 && intern->u.limit.count != -1) {
zend_throw_exception(spl_ce_OutOfRangeException, "Parameter count must either be -1 or a value greater than or equal 0", 0);
- zend_restore_error_handling(&error_handling);
return NULL;
}
break;
case DIT_CachingIterator:
case DIT_RecursiveCachingIterator: {
zend_long flags = CIT_CALL_TOSTRING;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|l", &zobject, ce_inner, &flags) == FAILURE) {
- zend_restore_error_handling(&error_handling);
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "O|l", &zobject, ce_inner, &flags) == FAILURE) {
return NULL;
}
if (spl_cit_check_flags(flags) != SUCCESS) {
zend_throw_exception(spl_ce_InvalidArgumentException, "Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_INNER", 0);
- zend_restore_error_handling(&error_handling);
return NULL;
}
intern->u.caching.flags |= flags & CIT_PUBLIC;
zend_class_entry *ce_cast;
zend_string *class_name;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|S", &zobject, ce_inner, &class_name) == FAILURE) {
- zend_restore_error_handling(&error_handling);
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "O|S", &zobject, ce_inner, &class_name) == FAILURE) {
return NULL;
}
ce = Z_OBJCE_P(zobject);
|| !ce_cast->get_iterator
) {
zend_throw_exception(spl_ce_LogicException, "Class to downcast to not found or not base class or does not implement Traversable", 0);
- zend_restore_error_handling(&error_handling);
return NULL;
}
ce = ce_cast;
zend_call_method_with_0_params(zobject, ce, &ce->iterator_funcs.zf_new_iterator, "getiterator", &retval);
if (EG(exception)) {
zval_ptr_dtor(&retval);
- zend_restore_error_handling(&error_handling);
return NULL;
}
if (Z_TYPE(retval) != IS_OBJECT || !instanceof_function(Z_OBJCE(retval), zend_ce_traversable)) {
zend_throw_exception_ex(spl_ce_LogicException, 0, "%s::getIterator() must return an object that implements Traversable", ce->name->val);
- zend_restore_error_handling(&error_handling);
return NULL;
}
zobject = &retval;
break;
}
case DIT_AppendIterator:
+ zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling);
spl_instantiate(spl_ce_ArrayIterator, &intern->u.append.zarrayit);
zend_call_method_with_0_params(&intern->u.append.zarrayit, spl_ce_ArrayIterator, &spl_ce_ArrayIterator->constructor, "__construct", NULL);
intern->u.append.iterator = spl_ce_ArrayIterator->get_iterator(spl_ce_ArrayIterator, &intern->u.append.zarrayit, 0);
intern->u.regex.use_flags = ZEND_NUM_ARGS() >= 5;
intern->u.regex.flags = 0;
intern->u.regex.preg_flags = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "OS|lll", &zobject, ce_inner, ®ex, &mode, &intern->u.regex.flags, &intern->u.regex.preg_flags) == FAILURE) {
- zend_restore_error_handling(&error_handling);
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "OS|lll", &zobject, ce_inner, ®ex, &mode, &intern->u.regex.flags, &intern->u.regex.preg_flags) == FAILURE) {
return NULL;
}
if (mode < 0 || mode >= REGIT_MODE_MAX) {
zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "Illegal mode %pd", mode);
- zend_restore_error_handling(&error_handling);
return NULL;
}
intern->u.regex.mode = mode;
intern->u.regex.regex = zend_string_copy(regex);
+
+ zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling);
intern->u.regex.pce = pcre_get_compiled_regex_cache(regex);
+ zend_restore_error_handling(&error_handling);
+
if (intern->u.regex.pce == NULL) {
/* pcre_get_compiled_regex_cache has already sent error */
- zend_restore_error_handling(&error_handling);
return NULL;
}
intern->u.regex.pce->refcount++;
case DIT_RecursiveCallbackFilterIterator: {
_spl_cbfilter_it_intern *cfi = emalloc(sizeof(*cfi));
cfi->fci.object = NULL;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "Of", &zobject, ce_inner, &cfi->fci, &cfi->fcc) == FAILURE) {
- zend_restore_error_handling(&error_handling);
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "Of", &zobject, ce_inner, &cfi->fci, &cfi->fcc) == FAILURE) {
efree(cfi);
return NULL;
}
break;
}
default:
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &zobject, ce_inner) == FAILURE) {
- zend_restore_error_handling(&error_handling);
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "O", &zobject, ce_inner) == FAILURE) {
return NULL;
}
break;
}
- zend_restore_error_handling(&error_handling);
-
if (inc_refcount) {
ZVAL_COPY(&intern->inner.zobject, zobject);
} else {
{
spl_SplObjectStorage *intern;
zend_long flags = MIT_NEED_ALL|MIT_KEYS_NUMERIC;
- zend_error_handling error_handling;
- zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling);
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &flags) == FAILURE) {
- zend_restore_error_handling(&error_handling);
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "|l", &flags) == FAILURE) {
return;
}
intern = Z_SPLOBJSTORAGE_P(getThis());
intern->flags = flags;
- zend_restore_error_handling(&error_handling);
}
/* }}} */
try {
new CallbackFilterIterator();
-} catch(InvalidArgumentException $e) {
+} catch (TypeException $e) {
echo $e->getMessage() . "\n";
}
try {
new CallbackFilterIterator(null);
-} catch(InvalidArgumentException $e) {
- echo $e->getMessage() . "\n";
-} catch(EngineException $e) {
+} catch (TypeException $e) {
echo $e->getMessage() . "\n";
}
try {
new CallbackFilterIterator(new ArrayIterator(array()), null);
-} catch(InvalidArgumentException $e) {
+} catch (TypeException $e) {
echo $e->getMessage() . "\n";
}
try {
new CallbackFilterIterator(new ArrayIterator(array()), array());
-} catch(InvalidArgumentException $e) {
+} catch (TypeException $e) {
echo $e->getMessage() . "\n";
}
try {
$array = new SplFixedArray( array("string", 1) );
-}
-catch(InvalidArgumentException $iae) {
+} catch (TypeException $iae) {
echo "Ok - ".$iae->getMessage().PHP_EOL;
}
?>
--EXPECTF--
-Ok - SplFixedArray::__construct() expects parameter 1 to be integer, array given
\ No newline at end of file
+Ok - SplFixedArray::__construct() expects parameter 1 to be integer, array given
<?php
try {
$array = new SplFixedArray( "string" );
-}
-catch(InvalidArgumentException $iae) {
+} catch (TypeException $iae) {
echo "Ok - ".$iae->getMessage().PHP_EOL;
}
<?php
try {
$array = new SplFixedArray(new SplFixedArray(3));
-}
-catch(InvalidArgumentException $iae) {
+} catch (TypeException $iae) {
echo "Ok - ".$iae->getMessage().PHP_EOL;
}
SPL SplTempFileObject constructor sets correct defaults when pass 0 arguments
--FILE--
<?php
-new SplTempFileObject('invalid');
+try {
+ new SplTempFileObject('invalid');
+} catch (TypeException $e) {
+ echo $e->getMessage(), "\n";
+}
?>
--EXPECTF--
-Fatal error: Uncaught exception 'RuntimeException' with message 'SplTempFileObject::__construct() expects parameter 1 to be integer, string given' in %s
-Stack trace:
-#0 %s: SplTempFileObject->__construct('invalid')
-#1 {main}
- thrown in %s
+SplTempFileObject::__construct() expects parameter 1 to be integer, string given
$a->p = 1;
try {
var_dump(new ArrayObject($a, 0, "Exception"));
-} catch (InvalidArgumentException $e) {
+} catch (TypeException $e) {
echo $e->getMessage() . "(" . $e->getLine() . ")\n";
}
echo "Non-existent class:\n";
try {
var_dump(new ArrayObject(new stdClass, 0, "nonExistentClassName"));
-} catch (InvalidArgumentException $e) {
+} catch (TypeException $e) {
echo $e->getMessage() . "(" . $e->getLine() . ")\n";
}
?>
try {
var_dump(new ArrayObject(new stdClass, 0, "C", "extra"));
-} catch (InvalidArgumentException $e) {
+} catch (TypeException $e) {
echo $e->getMessage() . "(" . $e->getLine() . ")\n";
}
?>
--EXPECTF--
Too many arguments:
-ArrayObject::__construct() expects at most 3 parameters, 4 given(12)
\ No newline at end of file
+ArrayObject::__construct() expects at most 3 parameters, 4 given(12)
foreach($ao as $key=>$value) {
echo " $key=>$value\n";
}
-} catch (Exception $e) {
+} catch (TypeException $e) {
var_dump($e->getMessage());
}
foreach($ao as $key=>$value) {
echo " $key=>$value\n";
}
-} catch (Exception $e) {
+} catch (TypeException $e) {
var_dump($e->getMessage());
}
try {
new SplFileObject('foo', array());
-} catch (Exception $e) {
+} catch (TypeException $e) {
var_dump($e->getMessage());
}
--TEST--
-SPL: FixedArray: Trying to instantiate passing object to constructor parameter
+SPL: FixedArray: Invalid arguments
--FILE--
<?php
-$b = new stdClass;
-
try {
- $a = new SplFixedArray($b);
+ $a = new SplFixedArray(new stdClass);
+} catch (TypeException $iae) {
+ echo "Ok - ".$iae->getMessage().PHP_EOL;
}
-catch(InvalidArgumentException $iae) {
+
+try {
+ $a = new SplFixedArray('FOO');
+} catch (TypeException $iae) {
echo "Ok - ".$iae->getMessage().PHP_EOL;
}
+try {
+ $a = new SplFixedArray('');
+} catch (TypeException $iae) {
+ echo "Ok - ".$iae->getMessage().PHP_EOL;
+}
?>
---EXPECTF--
+===DONE===
+--EXPECT--
Ok - SplFixedArray::__construct() expects parameter 1 to be integer, object given
+Ok - SplFixedArray::__construct() expects parameter 1 to be integer, string given
+Ok - SplFixedArray::__construct() expects parameter 1 to be integer, string given
+===DONE===
try {
$a = new SplFixedArray('FOO');
-}
-catch(InvalidArgumentException $iae) {
+} catch (TypeException $iae) {
echo "Ok - ".$iae->getMessage().PHP_EOL;
}
?>
try {
$a = new SplFixedArray('');
-}
-catch(InvalidArgumentException $iae) {
+} catch (TypeException $iae) {
echo "Ok - ".$iae->getMessage().PHP_EOL;
}
--TEST--
-SPL: FilterIterator::__construct(void)
+SPL: Calling __construct(void) on class extending SPL iterator
--CREDITS--
Sebastian Schürmann
--FILE--
<?php
+
class myFilterIterator extends FilterIterator {
- function accept() {
-
- }
+ function accept() { }
}
+
+class myCachingIterator extends CachingIterator { }
+
+class myRecursiveCachingIterator extends RecursiveCachingIterator { }
+
+class myParentIterator extends ParentIterator { }
+
+class myLimitIterator extends LimitIterator { }
+
+class myNoRewindIterator extends NoRewindIterator {}
+
try {
$it = new myFilterIterator();
-} catch (InvalidArgumentException $e) {
- echo 'InvalidArgumentException thrown';
+} catch (TypeException $e) {
+ echo $e->getMessage(), "\n";
}
+
+try {
+ $it = new myCachingIterator();
+} catch (TypeException $e) {
+ echo $e->getMessage(), "\n";
+}
+
+try {
+ $it = new myRecursiveCachingIterator();
+} catch (TypeException $e) {
+ echo $e->getMessage(), "\n";
+}
+
+try {
+ $it = new myParentIterator();
+} catch (TypeException $e) {
+ echo $e->getMessage(), "\n";
+}
+
+try {
+ $it = new myLimitIterator();
+} catch (TypeException $e) {
+ echo $e->getMessage(), "\n";
+}
+try {
+ $it = new myNoRewindIterator();
+} catch (TypeException $e) {
+ echo $e->getMessage(), "\n";
+}
+
?>
--EXPECT--
-InvalidArgumentException thrown
+FilterIterator::__construct() expects exactly 1 parameter, 0 given
+CachingIterator::__construct() expects at least 1 parameter, 0 given
+RecursiveCachingIterator::__construct() expects at least 1 parameter, 0 given
+ParentIterator::__construct() expects exactly 1 parameter, 0 given
+LimitIterator::__construct() expects at least 1 parameter, 0 given
+NoRewindIterator::__construct() expects exactly 1 parameter, 0 given
+++ /dev/null
---TEST--
-SPL: CachingIterator::__construct(void)
---CREDITS--
-Sebastian Schürmann
---FILE--
-<?php
-class myCachingIterator extends CachingIterator {
-
-}
-try {
- $it = new myCachingIterator();
-} catch (InvalidArgumentException $e) {
- echo 'InvalidArgumentException thrown';
-}
-?>
---EXPECT--
-InvalidArgumentException thrown
+++ /dev/null
---TEST--
-SPL: RecursiveCachingIterator::__construct(void)
---CREDITS--
-Sebastian Schürmann
---FILE--
-<?php
-class myRecursiveCachingIterator extends RecursiveCachingIterator {
-
-}
-try {
- $it = new myRecursiveCachingIterator();
-} catch (InvalidArgumentException $e) {
- echo 'InvalidArgumentException thrown';
-}
-?>
---EXPECT--
-InvalidArgumentException thrown
+++ /dev/null
---TEST--
-SPL: ParentIterator::__construct(void)
---CREDITS--
-Sebastian Schürmann
---FILE--
-<?php
-class myParentIterator extends ParentIterator {
-
-}
-try {
- $it = new myParentIterator();
-} catch (InvalidArgumentException $e) {
- echo 'InvalidArgumentException thrown';
-}
-?>
---EXPECT--
-InvalidArgumentException thrown
+++ /dev/null
---TEST--
-SPL: LimitIterator::__construct(void)
---CREDITS--
-Sebastian Schürmann
---FILE--
-<?php
-class myLimitIterator extends LimitIterator {
-
-}
-try {
- $it = new myLimitIterator();
-} catch (InvalidArgumentException $e) {
- echo 'InvalidArgumentException thrown';
-}
-?>
---EXPECT--
-InvalidArgumentException thrown
+++ /dev/null
---TEST--
-SPL: CachingIterator::__construct(void)
---CREDITS--
-Sebastian Schürmann
---FILE--
-<?php
-class myCachingIterator extends CachingIterator {}
-try {
- $it = new myCachingIterator();
-} catch (InvalidArgumentException $e) {
- echo 'InvalidArgumentException thrown';
-}
-?>
---EXPECT--
-InvalidArgumentException thrown
+++ /dev/null
---TEST--
-SPL: RecursiveCachingIterator::__construct(void)
---CREDITS--
-Sebastian Schürmann
---FILE--
-<?php
-class myRecursiveCachingIterator extends RecursiveCachingIterator {}
-try {
- $it = new myRecursiveCachingIterator();
-} catch (InvalidArgumentException $e) {
- echo 'InvalidArgumentException thrown';
-}
-?>
---EXPECT--
-InvalidArgumentException thrown
+++ /dev/null
---TEST--
-SPL: NoRewindIterator::__construct(void)
---CREDITS--
-Sebastian Schürmann
---FILE--
-<?php
-class myNoRewindIterator extends NoRewindIterator {}
-try {
- $it = new myNoRewindIterator();
-} catch (InvalidArgumentException $e) {
- echo 'InvalidArgumentException thrown';
-}
-?>
---EXPECT--
-InvalidArgumentException thrown
--TEST--
SPL: RecursiveTreeIterator(non-traversable)
---INI--
-error_reporting=E_ALL&~E_NOTICE
--FILE--
<?php
try {
new RecursiveTreeIterator(new ArrayIterator(array()));
-} catch (InvalidArgumentException $e) {
- echo "InvalidArgumentException thrown\n";
+} catch (TypeException $e) {
+ echo $e->getMessage(), "\n";
}
?>
===DONE===
---EXPECTF--
-InvalidArgumentException thrown
+--EXPECT--
+RecursiveCachingIterator::__construct() expects parameter 1 to be RecursiveIterator, object given
===DONE===
--FILE--
<?php
- //I think this is testing line 1297 of spl_iterators.c
-
- $array = array(array(7,8,9),1,2,3,array(4,5,6));
+$array = array(array(7,8,9),1,2,3,array(4,5,6));
$arrayIterator = new ArrayIterator($array);
try {
-$test = new IteratorIterator($arrayIterator);
-
-$test = new IteratorIterator($arrayIterator, 1);
-$test = new IteratorIterator($arrayIterator, 1, 1);
-$test = new IteratorIterator($arrayIterator, 1, 1, 1);
-$test = new IteratorIterator($arrayIterator, 1, 1, 1, 1);
+ $test = new IteratorIterator($arrayIterator);
-} catch (InvalidArgumentException $e){
- print $e->getMessage() . "\n";
+ $test = new IteratorIterator($arrayIterator, 1);
+ $test = new IteratorIterator($arrayIterator, 1, 1);
+ $test = new IteratorIterator($arrayIterator, 1, 1, 1);
+ $test = new IteratorIterator($arrayIterator, 1, 1, 1, 1);
+} catch (TypeException $e){
+ echo $e->getMessage() . "\n";
}
-
?>
===DONE===
--EXPECTF--
char *filename, *encryption_key, *fullpath;
size_t filename_len, encryption_key_len = 0;
zend_long flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
- zend_error_handling error_handling;
db_obj = Z_SQLITE3_DB_P(object);
- zend_replace_error_handling(EH_THROW, NULL, &error_handling);
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "p|ls", &filename, &filename_len, &flags, &encryption_key, &encryption_key_len)) {
- zend_restore_error_handling(&error_handling);
+ if (FAILURE == zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls", &filename, &filename_len, &flags, &encryption_key, &encryption_key_len)) {
return;
}
- zend_restore_error_handling(&error_handling);
-
if (db_obj->initialised) {
zend_throw_exception(zend_exception_get_default(), "Already initialised DB Object", 0);
}
php_sqlite3_free_list *free_item;
stmt_obj = Z_SQLITE3_STMT_P(object);
- zend_replace_error_handling(EH_THROW, NULL, &error_handling);
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "OS", &db_zval, php_sqlite3_sc_entry, &sql) == FAILURE) {
- zend_restore_error_handling(&error_handling);
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "OS", &db_zval, php_sqlite3_sc_entry, &sql) == FAILURE) {
return;
}
db_obj = Z_SQLITE3_DB_P(db_zval);
+ zend_replace_error_handling(EH_THROW, NULL, &error_handling);
SQLITE3_CHECK_INITIALIZED(db_obj, db_obj->initialised, SQLite3)
-
zend_restore_error_handling(&error_handling);
if (!sql->len) {
try {
$db = new SQLite3();
-} catch (Exception $e) {
+} catch (TypeException $e) {
var_dump($e->getMessage());
}