mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
- Add ReclectionClass:hasProperty(), ReflectionClass::hasConstant()
to complete api (johannes@php.net)
This commit is contained in:
parent
fea1b5b3a0
commit
0bb81ce1d6
2 changed files with 96 additions and 0 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue