]> granicus.if.org Git - php/commitdiff
- Extend API to support real existance test without the need to add any new
authorMarcus Boerger <helly@php.net>
Mon, 2 May 2005 16:18:02 +0000 (16:18 +0000)
committerMarcus Boerger <helly@php.net>
Mon, 2 May 2005 16:18:02 +0000 (16:18 +0000)
  functions or change any behavior

Zend/zend_builtin_functions.c
Zend/zend_object_handlers.c
Zend/zend_object_handlers.h

index d5604c447b8f47ad9ab3c8490d24f7ca3526e66b..abd599662372d2cdf81cf445f6abd599f1b54329 100644 (file)
@@ -953,7 +953,7 @@ ZEND_FUNCTION(property_exists)
                RETURN_FALSE;
        
        case IS_OBJECT:
-               if (Z_OBJ_HANDLER_PP(object, has_property) && Z_OBJ_HANDLER_PP(object, has_property)(*object, *property, 0 TSRMLS_CC)) {
+               if (Z_OBJ_HANDLER_PP(object, has_property) && Z_OBJ_HANDLER_PP(object, has_property)(*object, *property, 2 TSRMLS_CC)) {
                        RETURN_TRUE;
                }
                RETURN_FALSE;
index 91faa67cfac32ec4dd13e6080449acddb406a259..dc9a1b9106f7d687f7c61afaccca9f358a604851 100644 (file)
@@ -806,8 +806,7 @@ static int zend_std_compare_objects(zval *o1, zval *o2 TSRMLS_DC)
        return zend_compare_symbol_tables_i(zobj1->properties, zobj2->properties TSRMLS_CC);
 }
 
-
-static int zend_std_has_property(zval *object, zval *member, int check_empty TSRMLS_DC)
+static int zend_std_has_property(zval *object, zval *member, int has_set_exists TSRMLS_DC)
 {
        zend_object *zobj;
        int result;
@@ -833,10 +832,16 @@ static int zend_std_has_property(zval *object, zval *member, int check_empty TSR
        }
 
        if (zend_hash_find(zobj->properties, property_info->name, property_info->name_length+1, (void **) &value) == SUCCESS) {
-               if (check_empty) {
-                       result = zend_is_true(*value);
-               } else {
+               switch (has_set_exists) {
+               case 0:
                        result = (Z_TYPE_PP(value) != IS_NULL);
+                       break;
+               default:
+                       result = zend_is_true(*value);
+                       break;
+               case 2:
+                       result = 1;
+                       break;
                }
        } else {
                result = 0;
index 5284ba2efd6cfa1f28018d172ded9f66e300feaa..106e4041445380bc6d56d38d3ed286fc77e2b596 100644 (file)
@@ -61,7 +61,12 @@ typedef void (*zend_object_set_t)(zval **property, zval *value TSRMLS_DC);
 typedef zval* (*zend_object_get_t)(zval *property TSRMLS_DC);
 
 /* Used to check if a property of the object exists */
-typedef int (*zend_object_has_property_t)(zval *object, zval *member, int check_empty TSRMLS_DC);
+/* param has_set_exists:
+ * 0 (has) whetehr property exists and is not NULL
+ * 1 (set) whether property exists and is true
+ * 2 (exists) whether property exists
+ */
+typedef int (*zend_object_has_property_t)(zval *object, zval *member, int has_set_exists TSRMLS_DC);
 
 /* Used to check if a dimension of the object exists */
 typedef int (*zend_object_has_dimension_t)(zval *object, zval *member, int check_empty TSRMLS_DC);