]> granicus.if.org Git - php/commitdiff
Give a meaningful name
authorXinchen Hui <laruence@gmail.com>
Tue, 24 Jul 2018 04:51:36 +0000 (12:51 +0800)
committerXinchen Hui <laruence@gmail.com>
Tue, 24 Jul 2018 04:51:36 +0000 (12:51 +0800)
Zend/zend_closures.c
Zend/zend_object_handlers.c
Zend/zend_object_handlers.h
ext/mysqli/mysqli.c
ext/snmp/snmp.c
ext/spl/spl_array.c
ext/standard/array.c

index 4eb2f1326698067afec1abef7aece0d1b8f62cc5..65193af563212e30a33c13c0c95480b9a9dca9ef 100644 (file)
@@ -412,7 +412,7 @@ static zval *zend_closure_get_property_ptr_ptr(zval *object, zval *member, int t
 
 static int zend_closure_has_property(zval *object, zval *member, int has_set_exists, void **cache_slot) /* {{{ */
 {
-       if (has_set_exists != 2) {
+       if (has_set_exists != ZEND_PROPERTY_EXISTS) {
                ZEND_CLOSURE_PROPERTY_ERROR();
        }
        return 0;
index 7889f523ee05c452f843bced99ff6c07b3af55c6..cb7710343df64875e5841672b7c692376f4db42d 100644 (file)
@@ -1657,16 +1657,17 @@ ZEND_API int zend_std_has_property(zval *object, zval *member, int has_set_exist
                                }
 found:
                                switch (has_set_exists) {
-                                       case 0:
+                                       case ZEND_PROPERTY_ISSET:
                                                ZVAL_DEREF(value);
                                                result = (Z_TYPE_P(value) != IS_NULL);
                                                break;
+                                       case ZEND_PROPERTY_EXISTS:
+                                               result = 1;
+                                               break;
+                                       case ZEND_PROPERTY_HAS:
                                        default:
                                                result = zend_is_true(value);
                                                break;
-                                       case 2:
-                                               result = 1;
-                                               break;
                                }
                                goto exit;
                        }
@@ -1677,7 +1678,7 @@ found:
        }
 
        result = 0;
-       if ((has_set_exists != 2) && zobj->ce->__isset) {
+       if ((has_set_exists != ZEND_PROPERTY_EXISTS) && zobj->ce->__isset) {
                uint32_t *guard = zend_get_property_guard(zobj, Z_STR_P(member));
 
                if (!((*guard) & IN_ISSET)) {
@@ -1694,7 +1695,7 @@ found:
                        if (Z_TYPE(rv) != IS_UNDEF) {
                                result = zend_is_true(&rv);
                                zval_ptr_dtor(&rv);
-                               if (has_set_exists && result) {
+                               if (has_set_exists == ZEND_PROPERTY_HAS && result) {
                                        if (EXPECTED(!EG(exception)) && zobj->ce->__get && !((*guard) & IN_GET)) {
                                                (*guard) |= IN_GET;
                                                zend_std_call_getter(zobj, member, &rv);
index 1dfed715f3535fea0e31a3512f0f9348e538502d..26b16adcc8f7dde5876bd9d36aa4212e7b05ca25 100644 (file)
@@ -173,6 +173,10 @@ extern const ZEND_API zend_object_handlers std_object_handlers;
 #define zend_get_function_root_class(fbc) \
        ((fbc)->common.prototype ? (fbc)->common.prototype->common.scope : (fbc)->common.scope)
 
+#define ZEND_PROPERTY_ISSET            0x0     /* Property is exists and not NULL */
+#define ZEND_PROPERTY_HAS              0x1 /* Property is exists and is TRUE */
+#define ZEND_PROPERTY_EXISTS   0x2 /* Property is exists */
+
 ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_string *function_name_strval, const zval *key);
 ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *property_name, zend_bool silent);
 ZEND_API ZEND_COLD zend_bool zend_std_unset_static_property(zend_class_entry *ce, zend_string *property_name);
index 6cc724f42ea2a44fa83c60c88407e231f5d3ef43..4a32fb41baa04f266bc0daacebc60feb60f357dd 100644 (file)
@@ -382,10 +382,10 @@ static int mysqli_object_has_property(zval *object, zval *member, int has_set_ex
 
        if ((p = zend_hash_find_ptr(obj->prop_handler, Z_STR_P(member))) != NULL) {
                switch (has_set_exists) {
-                       case 2:
+                       case ZEND_PROPERTY_EXISTS:
                                ret = 1;
                                break;
-                       case 1: {
+                       case ZEND_PROPERTY_HAS: {
                                zval rv;
                                zval *value = mysqli_read_property(object, member, BP_VAR_IS, cache_slot, &rv);
                                if (value != &EG(uninitialized_zval)) {
@@ -394,7 +394,7 @@ static int mysqli_object_has_property(zval *object, zval *member, int has_set_ex
                                }
                                break;
                        }
-                       case 0:{
+                       case ZEND_PROPERTY_ISSET: {
                                zval rv;
                                zval *value = mysqli_read_property(object, member, BP_VAR_IS, cache_slot, &rv);
                                if (value != &EG(uninitialized_zval)) {
index 42cc69c68576e5de138cf8c1515a8c55f93ddc2b..6f61eb2e289a3e0ab1456517e5eeaa9863f309a9 100644 (file)
@@ -1994,10 +1994,10 @@ static int php_snmp_has_property(zval *object, zval *member, int has_set_exists,
 
        if ((hnd = zend_hash_find_ptr(&php_snmp_properties, Z_STR_P(member))) != NULL) {
                switch (has_set_exists) {
-                       case 2:
+                       case ZEND_PROPERTY_EXISTS:
                                ret = 1;
                                break;
-                       case 0: {
+                       case ZEND_PROPERTY_ISSET: {
                                zval *value = php_snmp_read_property(object, member, BP_VAR_IS, cache_slot, &rv);
                                if (value != &EG(uninitialized_zval)) {
                                        ret = Z_TYPE_P(value) != IS_NULL? 1 : 0;
index 59ae0b8c8902bfa69ac7c005a6f9d33a530dec56..3039f10d7bfce1f28b1cb79f88c5acab47f5c82f 100644 (file)
@@ -872,7 +872,7 @@ static zval *spl_array_read_property(zval *object, zval *member, int type, void
        spl_array_object *intern = Z_SPLARRAY_P(object);
 
        if ((intern->ar_flags & SPL_ARRAY_ARRAY_AS_PROPS) != 0
-               && !zend_std_has_property(object, member, 2, NULL)) {
+               && !zend_std_has_property(object, member, ZEND_PROPERTY_EXISTS, NULL)) {
                return spl_array_read_dimension(object, member, type, rv);
        }
        return zend_std_read_property(object, member, type, cache_slot, rv);
@@ -883,7 +883,7 @@ static void spl_array_write_property(zval *object, zval *member, zval *value, vo
        spl_array_object *intern = Z_SPLARRAY_P(object);
 
        if ((intern->ar_flags & SPL_ARRAY_ARRAY_AS_PROPS) != 0
-       && !zend_std_has_property(object, member, 2, NULL)) {
+       && !zend_std_has_property(object, member, ZEND_PROPERTY_EXISTS, NULL)) {
                spl_array_write_dimension(object, member, value);
                return;
        }
@@ -895,7 +895,7 @@ static zval *spl_array_get_property_ptr_ptr(zval *object, zval *member, int type
        spl_array_object *intern = Z_SPLARRAY_P(object);
 
        if ((intern->ar_flags & SPL_ARRAY_ARRAY_AS_PROPS) != 0
-               && !zend_std_has_property(object, member, 2, NULL)) {
+               && !zend_std_has_property(object, member, ZEND_PROPERTY_EXISTS, NULL)) {
                /* If object has offsetGet() overridden, then fallback to read_property,
                 * which will call offsetGet(). */
                if (intern->fptr_offset_get) {
@@ -911,7 +911,7 @@ static int spl_array_has_property(zval *object, zval *member, int has_set_exists
        spl_array_object *intern = Z_SPLARRAY_P(object);
 
        if ((intern->ar_flags & SPL_ARRAY_ARRAY_AS_PROPS) != 0
-               && !zend_std_has_property(object, member, 2, NULL)) {
+               && !zend_std_has_property(object, member, ZEND_PROPERTY_EXISTS, NULL)) {
                return spl_array_has_dimension(object, member, has_set_exists);
        }
        return zend_std_has_property(object, member, has_set_exists, cache_slot);
@@ -922,7 +922,7 @@ static void spl_array_unset_property(zval *object, zval *member, void **cache_sl
        spl_array_object *intern = Z_SPLARRAY_P(object);
 
        if ((intern->ar_flags & SPL_ARRAY_ARRAY_AS_PROPS) != 0
-               && !zend_std_has_property(object, member, 2, NULL)) {
+               && !zend_std_has_property(object, member, ZEND_PROPERTY_EXISTS, NULL)) {
                spl_array_unset_dimension(object, member);
                return;
        }
index 28fbb5188db34b2319e30fff5ad47ba0c118d3d4..c073d7d5acb1797047a6aecf8ba722d1571853bc 100644 (file)
@@ -4110,8 +4110,8 @@ static inline zval *array_column_fetch_prop(zval *data, zval *name, zval *rv) /*
                /* The has_property check is first performed in "exists" mode (which returns true for
                 * properties that are null but exist) and then in "has" mode to handle objects that
                 * implement __isset (which is not called in "exists" mode). */
-               if (Z_OBJ_HANDLER_P(data, has_property)(data, name, 2, NULL)
-                               || Z_OBJ_HANDLER_P(data, has_property)(data, name, 0, NULL)) {
+               if (Z_OBJ_HANDLER_P(data, has_property)(data, name, ZEND_PROPERTY_EXISTS, NULL)
+                               || Z_OBJ_HANDLER_P(data, has_property)(data, name, ZEND_PROPERTY_ISSET, NULL)) {
                        prop = Z_OBJ_HANDLER_P(data, read_property)(data, name, BP_VAR_R, NULL, rv);
                        if (prop) {
                                ZVAL_DEREF(prop);