cvs: ZendEngine2 / zend_reflection_api.c

From: Date: Mon, 31 Jan 2005 22:56:02 +0000
Subject: cvs: ZendEngine2 / zend_reflection_api.c
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-3347@lists.php.net to get a copy of this message
helly Mon Jan 31 17:56:02 2005 EDT Modified files: /ZendEngine2 zend_reflection_api.c Log: - Add ReclectionClass:hasProperty(), ReflectionClass::hasConstant() to complete api (johannes@php.net) http://cvs.php.net/diff.php/ZendEngine2/zend_reflection_api.c?r1=1.145&r2=1.146&ty=u Index: ZendEngine2/zend_reflection_api.c diff -u ZendEngine2/zend_reflection_api.c:1.145 ZendEngine2/zend_reflection_api.c:1.146 --- ZendEngine2/zend_reflection_api.c:1.145 Sat Jan 22 07:23:01 2005 +++ ZendEngine2/zend_reflection_api.c Mon Jan 31 17:56:01 2005 @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_reflection_api.c,v 1.145 2005/01/22 12:23:01 helly Exp $ */ +/* $Id: zend_reflection_api.c,v 1.146 2005/01/31 22:56:01 helly Exp $ */ #include "zend.h" #include "zend_API.h" #include "zend_exceptions.h" @@ -2581,6 +2581,29 @@ } /* }}} */ +/* {{{ 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 @@ } /* }}} */ +/* {{{ 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 @@ 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)

« previous php.zend-engine.cvs (#3347) next »