]> granicus.if.org Git - php/commitdiff
- Make ReflectionObject::hasProperty() recognize dynamically added props
authorMarcus Boerger <helly@php.net>
Thu, 12 May 2005 21:25:42 +0000 (21:25 +0000)
committerMarcus Boerger <helly@php.net>
Thu, 12 May 2005 21:25:42 +0000 (21:25 +0000)
Zend/zend_reflection_api.c
ext/reflection/php_reflection.c

index c77bc69d077e0c8391e13f8a6cdfafd394f1295a..aeee738af89a214ce0fce808b4e7eebcd2476c03 100644 (file)
@@ -2656,6 +2656,7 @@ ZEND_METHOD(reflection_class, hasProperty)
        zend_class_entry *ce;
        char *name; 
        int name_len;
+       zval *property;
 
        METHOD_NOTSTATIC;
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
@@ -2666,6 +2667,16 @@ ZEND_METHOD(reflection_class, hasProperty)
        if (zend_hash_exists(&ce->properties_info, name, name_len + 1)) {
                RETURN_TRUE;
        } else {
+               if (intern->obj && Z_OBJ_HANDLER_P(intern->obj, has_property))
+               {
+                       MAKE_STD_ZVAL(property);
+                       ZVAL_STRINGL(property, name, name_len, 1);
+                       if (Z_OBJ_HANDLER_P(intern->obj, has_property)(intern->obj, property, 2 TSRMLS_CC)) {
+                               zval_ptr_dtor(&property);
+                               RETURN_TRUE;
+                       }
+                       zval_ptr_dtor(&property);
+               }
                RETURN_FALSE;
        }
 }
index c77bc69d077e0c8391e13f8a6cdfafd394f1295a..aeee738af89a214ce0fce808b4e7eebcd2476c03 100644 (file)
@@ -2656,6 +2656,7 @@ ZEND_METHOD(reflection_class, hasProperty)
        zend_class_entry *ce;
        char *name; 
        int name_len;
+       zval *property;
 
        METHOD_NOTSTATIC;
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
@@ -2666,6 +2667,16 @@ ZEND_METHOD(reflection_class, hasProperty)
        if (zend_hash_exists(&ce->properties_info, name, name_len + 1)) {
                RETURN_TRUE;
        } else {
+               if (intern->obj && Z_OBJ_HANDLER_P(intern->obj, has_property))
+               {
+                       MAKE_STD_ZVAL(property);
+                       ZVAL_STRINGL(property, name, name_len, 1);
+                       if (Z_OBJ_HANDLER_P(intern->obj, has_property)(intern->obj, property, 2 TSRMLS_CC)) {
+                               zval_ptr_dtor(&property);
+                               RETURN_TRUE;
+                       }
+                       zval_ptr_dtor(&property);
+               }
                RETURN_FALSE;
        }
 }