summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2004-12-25 16:27:27 +0000
committerMarcus Boerger <helly@php.net>2004-12-25 16:27:27 +0000
commit8c7bd30a7bcaddb611660c998bcb4ce485c8070e (patch)
treea98c2e75ca17901ed69433e30621880330fa82fd /Zend
parentc8b2f43005c977fa52e889e835dfcde445751a1a (diff)
downloadphp-git-8c7bd30a7bcaddb611660c998bcb4ce485c8070e.tar.gz
- Add ReflectionClass::hasMethod() (thanks to Johannes S.)
Diffstat (limited to 'Zend')
-rw-r--r--Zend/zend_reflection_api.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/Zend/zend_reflection_api.c b/Zend/zend_reflection_api.c
index 73da40d62e..69ee635c03 100644
--- a/Zend/zend_reflection_api.c
+++ b/Zend/zend_reflection_api.c
@@ -2484,6 +2484,32 @@ ZEND_METHOD(reflection_class, getConstructor)
}
/* }}} */
+/* {{{ proto public bool ReflectionClass::hasMethod(string name)
+ Returns wether a method exists or not */
+ZEND_METHOD(reflection_class, hasMethod)
+{
+ reflection_object *intern;
+ zend_class_entry *ce;
+ char *name, *lc_name;
+ int name_len;
+
+ METHOD_NOTSTATIC;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
+ return;
+ }
+
+ GET_REFLECTION_OBJECT_PTR(ce);
+ lc_name = zend_str_tolower_dup(name, name_len);
+ if (zend_hash_exists(&ce->function_table, lc_name, name_len + 1)) {
+ efree(lc_name);
+ RETURN_TRUE;
+ } else {
+ efree(lc_name);
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
/* {{{ proto public ReflectionMethod ReflectionClass::getMethod(string name) throws ReflectionException
Returns the class' method specified by it's name */
ZEND_METHOD(reflection_class, getMethod)
@@ -3625,6 +3651,7 @@ static zend_function_entry reflection_class_functions[] = {
ZEND_ME(reflection_class, getEndLine, NULL, 0)
ZEND_ME(reflection_class, getDocComment, NULL, 0)
ZEND_ME(reflection_class, getConstructor, NULL, 0)
+ ZEND_ME(reflection_class, hasMethod, NULL, 0)
ZEND_ME(reflection_class, getMethod, NULL, 0)
ZEND_ME(reflection_class, getMethods, NULL, 0)
ZEND_ME(reflection_class, getProperty, NULL, 0)