summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2003-10-17 17:51:01 +0000
committerMarcus Boerger <helly@php.net>2003-10-17 17:51:01 +0000
commit641a55a4dd58f2430dc0f5b5823c186f36b21c64 (patch)
tree59581796aaef31c0056a0c673eba00d74f9c5de9
parent9fbaa7aca53f377d96d69b87538f74c80e296e3f (diff)
downloadphp-git-641a55a4dd58f2430dc0f5b5823c186f36b21c64.tar.gz
Show if a class/object is iterateable
-rw-r--r--Zend/zend_reflection_api.c18
-rw-r--r--ext/reflection/php_reflection.c18
2 files changed, 36 insertions, 0 deletions
diff --git a/Zend/zend_reflection_api.c b/Zend/zend_reflection_api.c
index 34695fd49e..ea06aedb3b 100644
--- a/Zend/zend_reflection_api.c
+++ b/Zend/zend_reflection_api.c
@@ -260,6 +260,9 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
string_printf(str, "%s%s [ ", indent, (ce->ce_flags & ZEND_ACC_INTERFACE) ? "Interface" : "Class");
}
string_printf(str, (ce->type == ZEND_USER_CLASS) ? "<user> " : "<internal> ");
+ if (ce->get_iterator != NULL) {
+ string_printf(str, "<iterateable> ");
+ }
if (ce->ce_flags & ZEND_ACC_ABSTRACT_CLASS) {
string_printf(str, "abstract ");
}
@@ -2385,6 +2388,20 @@ ZEND_METHOD(reflection_class, isSubclassOf)
}
/* }}} */
+/* {{{ proto public bool Reflection_Class::isIterateable()
+ Returns whether this class is iterateable (can be used inside foreach) */
+ZEND_METHOD(reflection_class, isIterateable)
+{
+ reflection_object *intern;
+ zend_class_entry *ce;
+
+ METHOD_NOTSTATIC;
+ GET_REFLECTION_OBJECT_PTR(ce);
+
+ RETURN_BOOL(ce->get_iterator != NULL);
+}
+/* }}} */
+
/* {{{ proto public static mixed Reflection_Object::export(mixed argument, [, bool return]) throws Exception
Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
ZEND_METHOD(reflection_object, export)
@@ -2949,6 +2966,7 @@ static zend_function_entry reflection_class_functions[] = {
ZEND_ME(reflection_class, isSubclassOf, NULL, 0)
ZEND_ME(reflection_class, getStaticProperties, NULL, 0)
ZEND_ME(reflection_class, getDefaultProperties, NULL, 0)
+ ZEND_ME(reflection_class, isIterateable, NULL, 0)
{NULL, NULL, NULL}
};
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 34695fd49e..ea06aedb3b 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -260,6 +260,9 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
string_printf(str, "%s%s [ ", indent, (ce->ce_flags & ZEND_ACC_INTERFACE) ? "Interface" : "Class");
}
string_printf(str, (ce->type == ZEND_USER_CLASS) ? "<user> " : "<internal> ");
+ if (ce->get_iterator != NULL) {
+ string_printf(str, "<iterateable> ");
+ }
if (ce->ce_flags & ZEND_ACC_ABSTRACT_CLASS) {
string_printf(str, "abstract ");
}
@@ -2385,6 +2388,20 @@ ZEND_METHOD(reflection_class, isSubclassOf)
}
/* }}} */
+/* {{{ proto public bool Reflection_Class::isIterateable()
+ Returns whether this class is iterateable (can be used inside foreach) */
+ZEND_METHOD(reflection_class, isIterateable)
+{
+ reflection_object *intern;
+ zend_class_entry *ce;
+
+ METHOD_NOTSTATIC;
+ GET_REFLECTION_OBJECT_PTR(ce);
+
+ RETURN_BOOL(ce->get_iterator != NULL);
+}
+/* }}} */
+
/* {{{ proto public static mixed Reflection_Object::export(mixed argument, [, bool return]) throws Exception
Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
ZEND_METHOD(reflection_object, export)
@@ -2949,6 +2966,7 @@ static zend_function_entry reflection_class_functions[] = {
ZEND_ME(reflection_class, isSubclassOf, NULL, 0)
ZEND_ME(reflection_class, getStaticProperties, NULL, 0)
ZEND_ME(reflection_class, getDefaultProperties, NULL, 0)
+ ZEND_ME(reflection_class, isIterateable, NULL, 0)
{NULL, NULL, NULL}
};