From: Gustavo Lopes Date: Tue, 29 Jan 2013 15:17:55 +0000 (+0100) Subject: Improve ERROR.CONVENTIONS X-Git-Tag: php-5.5.0alpha5~58^2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=363fd6d6fb5c962c8d1339dfaad2bd18373de36c;p=php Improve ERROR.CONVENTIONS --- diff --git a/ext/intl/ERROR.CONVENTIONS b/ext/intl/ERROR.CONVENTIONS index 54f30edcaa..6f9079c56d 100644 --- a/ext/intl/ERROR.CONVENTIONS +++ b/ext/intl/ERROR.CONVENTIONS @@ -81,3 +81,35 @@ ICU operates, where functions return immediately if an error is set. Error resetting can be done with: void intl_error_reset(NULL TSRMLS_DC); /* reset global error */ void intl_errors_reset(intl_error* err TSRMLS_DC ); /* reset global and object error */ + +In practice, intl_errors_reset() is not used because most classes have also +plain functions mapped to the same internal functions as their instance methods. +Fetching of the object is done with zend_parse_method_parameters() instead of +directly using getThis(). Therefore, no reference to object is obtained until +the arguments are fully parsed. Without a reference to the object, there's no +way to reset the object's internal error code. Instead, resetting of the +object's internal error code is done upon fetching the object from its zval. + +Example: +U_CFUNC PHP_FUNCTION(breakiter_set_text) +{ + /* ... variable declations ... */ + BREAKITER_METHOD_INIT_VARS; /* macro also resets global error */ + object = getThis(); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", + &text, &text_len) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + "breakiter_set_text: bad arguments", 0 TSRMLS_CC); + RETURN_FALSE; + } + + /* ... */ + + BREAKITER_METHOD_FETCH_OBJECT; /* macro also resets object's error */ + + /* ... */ +} + +Implementations of ::getErrorCode() and ::getErrorMessage() should not reset the +object's error code.