com php-src: Improve ERROR.CONVENTIONS: ext/intl/ERROR.CONVENTIONS
| From: | Gustavo André dos Santos Lopes | Date: | Tue, 29 Jan 2013 18:06:14 +0000 |
| Subject: | com php-src: Improve ERROR.CONVENTIONS: ext/intl/ERROR.CONVENTIONS | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-71064@lists.php.net to get a copy of this message | ||
Commit: 363fd6d6fb5c962c8d1339dfaad2bd18373de36c
Author: Gustavo Lopes <glopes@nebm.ist.utl.pt> Tue, 29 Jan 2013 16:17:55 +0100
Parents: b4ba46cb996e813ea3d99140cadbcc44822fcbe4
Branches: PHP-5.5 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=363fd6d6fb5c962c8d1339dfaad2bd18373de36c
Log:
Improve ERROR.CONVENTIONS
Changed paths:
M ext/intl/ERROR.CONVENTIONS
Diff:
diff --git a/ext/intl/ERROR.CONVENTIONS b/ext/intl/ERROR.CONVENTIONS
index 54f30ed..6f9079c 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.