* use the separator where applicable
[m6w6/ext-http] / php_http_object.c
index 5a1a2799b533357cf19ded1d1e20d282dc168bbc..13252e681d4b327512269d1ec8d0e0c5cc1dfd92 100644 (file)
@@ -35,14 +35,14 @@ PHP_HTTP_API zend_error_handling_t php_http_object_get_error_handling(zval *obje
 
        zeh = zend_read_property(Z_OBJCE_P(object), object, ZEND_STRL("errorHandling"), 0 TSRMLS_CC);
        if (Z_TYPE_P(zeh) != IS_NULL) {
-               lzeh = php_http_zsep(IS_LONG, zeh);
+               lzeh = php_http_ztyp(IS_LONG, zeh);
                eh = Z_LVAL_P(lzeh);
                zval_ptr_dtor(&lzeh);
                return eh;
        }
        zeh = zend_read_static_property(php_http_object_class_entry, ZEND_STRL("defaultErrorHandling"), 0 TSRMLS_CC);
        if (Z_TYPE_P(zeh) != IS_NULL) {
-               lzeh = php_http_zsep(IS_LONG, zeh);
+               lzeh = php_http_ztyp(IS_LONG, zeh);
                eh = Z_LVAL_P(lzeh);
                zval_ptr_dtor(&lzeh);
                return eh;
@@ -94,7 +94,7 @@ zend_object_value php_http_object_new_ex(zend_class_entry *ce, void *nothing, ph
        php_http_object_t *o;
 
        o = ecalloc(1, sizeof(php_http_object_t));
-       zend_object_std_init((zend_object *)o, ce TSRMLS_CC);
+       zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
        object_properties_init((zend_object *) o, ce);
 
        if (ptr) {
@@ -115,7 +115,7 @@ PHP_METHOD(HttpObject, factory)
        zend_fcall_info fci;
        zend_fcall_info_cache fcc;
 
-       with_error_handling(EH_THROW, PHP_HTTP_EX_CE(runtime)) {
+       with_error_handling(EH_THROW, php_http_exception_class_entry) {
                if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "C|a/!", &class_entry, &ctor_args)) {
                        object_init_ex(return_value, class_entry);
 
@@ -142,26 +142,21 @@ PHP_METHOD(HttpObject, getErrorHandling)
 PHP_METHOD(HttpObject, setErrorHandling)
 {
        long eh;
-       zval *old;
 
-       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &eh)) {
-               RETURN_FALSE;
-       }
+       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &eh)) {
+               switch (eh) {
+                       case EH_NORMAL:
+                       case EH_SUPPRESS:
+                       case EH_THROW:
+                               zend_update_property_long(php_http_object_class_entry, getThis(), ZEND_STRL("errorHandling"), eh TSRMLS_CC);
+                               break;
 
-       switch (eh) {
-               case EH_NORMAL:
-               case EH_SUPPRESS:
-               case EH_THROW:
-                       break;
-               default:
-                       php_http_error(HE_WARNING, PHP_HTTP_E_RUNTIME, "unknown error handling code (%ld)", eh);
-                       RETURN_FALSE;
+                       default:
+                               php_http_error(HE_WARNING, PHP_HTTP_E_RUNTIME, "unknown error handling code (%ld)", eh);
+               }
        }
-       
-       old = zend_read_property(php_http_object_class_entry, getThis(), ZEND_STRL("errorHandling"), 0 TSRMLS_CC);
-       Z_ADDREF_P(old);
-       zend_update_property_long(php_http_object_class_entry, getThis(), ZEND_STRL("errorHandling"), eh TSRMLS_CC);
-       RETURN_ZVAL(old, 0, 0);
+
+       RETURN_ZVAL(getThis(), 1, 0);
 }
 
 PHP_METHOD(HttpObject, getDefaultErrorHandling)
@@ -172,27 +167,21 @@ PHP_METHOD(HttpObject, getDefaultErrorHandling)
 PHP_METHOD(HttpObject, setDefaultErrorHandling)
 {
        long eh;
-       zval *old;
 
-       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &eh)) {
-               RETURN_FALSE;
-       }
+       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &eh)) {
+               switch (eh) {
+                       case EH_NORMAL:
+                       case EH_SUPPRESS:
+                       case EH_THROW:
+                               zend_update_static_property_long(php_http_object_class_entry, ZEND_STRL("defaultErrorHandling"), eh TSRMLS_CC);
+                               break;
 
-       switch (eh) {
-               case EH_NORMAL:
-               case EH_SUPPRESS:
-               case EH_THROW:
-                       break;
-               default:
-                       php_http_error(HE_WARNING, PHP_HTTP_E_RUNTIME, "unknown error handling code (%ld)", eh);
-                       RETURN_FALSE;
+                       default:
+                               php_http_error(HE_WARNING, PHP_HTTP_E_RUNTIME, "unknown error handling code (%ld)", eh);
+               }
        }
-
-       old = zend_read_static_property(php_http_object_class_entry, ZEND_STRL("defaultErrorHandling"), 0 TSRMLS_CC);
-       Z_ADDREF_P(old);
-       zend_update_static_property_long(php_http_object_class_entry, ZEND_STRL("defaultErrorHandling"), eh TSRMLS_CC);
-       RETURN_ZVAL(old, 0, 1);
 }
+
 PHP_MINIT_FUNCTION(http_object)
 {
        PHP_HTTP_REGISTER_CLASS(http, Object, http_object, NULL, ZEND_ACC_ABSTRACT);