diff options
author | Marcus Boerger <helly@php.net> | 2005-01-31 22:56:01 +0000 |
---|---|---|
committer | Marcus Boerger <helly@php.net> | 2005-01-31 22:56:01 +0000 |
commit | 0bb81ce1d636fd434ee3e57173f745097bedfbc9 (patch) | |
tree | 8ddcff7a2786ccbaf5877134d0705314e09da843 /Zend/zend_reflection_api.c | |
parent | fea1b5b3a0b8c1828266608aa2c184ff1487283f (diff) | |
download | php-git-0bb81ce1d636fd434ee3e57173f745097bedfbc9.tar.gz |
- Add ReclectionClass:hasProperty(), ReflectionClass::hasConstant()
to complete api (johannes@php.net)
Diffstat (limited to 'Zend/zend_reflection_api.c')
-rw-r--r-- | Zend/zend_reflection_api.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Zend/zend_reflection_api.c b/Zend/zend_reflection_api.c index 071bfec553..75ef5917a3 100644 --- a/Zend/zend_reflection_api.c +++ b/Zend/zend_reflection_api.c @@ -2581,6 +2581,29 @@ ZEND_METHOD(reflection_class, getMethods) } /* }}} */ +/* {{{ proto public bool ReflectionClass::hasProperty(string name) + Returns wether a property exists or not */ +ZEND_METHOD(reflection_class, hasProperty) +{ + reflection_object *intern; + zend_class_entry *ce; + char *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); + if (zend_hash_exists(&ce->properties_info, name, name_len + 1)) { + RETURN_TRUE; + } else { + RETURN_FALSE; + } +} +/* }}} */ + /* {{{ proto public ReflectionProperty ReflectionClass::getProperty(string name) throws ReflectionException Returns the class' property specified by it's name */ ZEND_METHOD(reflection_class, getProperty) @@ -2651,6 +2674,29 @@ ZEND_METHOD(reflection_class, getProperties) } /* }}} */ +/* {{{ proto public bool ReflectionClass::hasConstant(string name) + Returns wether a constant exists or not */ +ZEND_METHOD(reflection_class, hasConstant) +{ + reflection_object *intern; + zend_class_entry *ce; + char *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); + if (zend_hash_exists(&ce->constants_table, name, name_len + 1)) { + RETURN_TRUE; + } else { + RETURN_FALSE; + } +} +/* }}} */ + /* {{{ proto public array ReflectionClass::getConstants() Returns an associative array containing this class' constants and their values */ ZEND_METHOD(reflection_class, getConstants) @@ -3653,8 +3699,10 @@ static zend_function_entry reflection_class_functions[] = { 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, hasProperty, NULL, 0) ZEND_ME(reflection_class, getProperty, NULL, 0) ZEND_ME(reflection_class, getProperties, NULL, 0) + ZEND_ME(reflection_class, hasConstant, NULL, 0) ZEND_ME(reflection_class, getConstants, NULL, 0) ZEND_ME(reflection_class, getConstant, NULL, 0) ZEND_ME(reflection_class, getInterfaces, NULL, 0) |