summaryrefslogtreecommitdiff
path: root/ext/reflection/php_reflection.c
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2006-03-12 17:22:34 +0000
committerMarcus Boerger <helly@php.net>2006-03-12 17:22:34 +0000
commit0add197ec8a5459a59561d5851d4db31be5db5a8 (patch)
treefa061fa77a40a85729f9921900d9e06ce9e8eee1 /ext/reflection/php_reflection.c
parent1c340d515ddbc9e0dbd8a935a18814debd42bb85 (diff)
downloadphp-git-0add197ec8a5459a59561d5851d4db31be5db5a8.tar.gz
- MFH:
- Fix ReflectionParameter . Reintroduce getClass() . Change getDeclaringClass() to return what it suggests . (inactive but tested) Add getDeclaringFunction() . (inactive but tested) Add getPosition() - Fix tests accordingly # This also fixes Bug #36687 ReflectionParameter::getDeclaringClass returns # wrong result
Diffstat (limited to 'ext/reflection/php_reflection.c')
-rw-r--r--ext/reflection/php_reflection.c72
1 files changed, 64 insertions, 8 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index b10b44f89e..47aefa5d37 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -1787,6 +1787,7 @@ ZEND_METHOD(reflection_parameter, __construct)
}
efree(lcname);
}
+ ce = fptr->common.scope;
break;
case IS_ARRAY: {
@@ -1901,9 +1902,10 @@ ZEND_METHOD(reflection_parameter, getName)
}
/* }}} */
-/* {{{ proto public ReflectionClass ReflectionParameter::getDeclaringClass()
- Returns this parameters's class hint or NULL if there is none */
-ZEND_METHOD(reflection_parameter, getDeclaringClass)
+#if MBO_0
+/* {{{ proto public ReflectionFunction ReflectionParameter::getDeclaringFunction()
+ Returns the ReflectionFunction for the function of this parameter */
+ZEND_METHOD(reflection_parameter, getDeclaringFunction)
{
reflection_object *intern;
parameter_reference *param;
@@ -1911,12 +1913,44 @@ ZEND_METHOD(reflection_parameter, getDeclaringClass)
METHOD_NOTSTATIC_NUMPARAMS(reflection_parameter_ptr, 0);
GET_REFLECTION_OBJECT_PTR(param);
- if (!param->arg_info->class_name) {
- RETURN_NULL();
+ if (!param->fptr->common.scope) {
+ reflection_function_factory(param->fptr, return_value TSRMLS_CC);
} else {
- zend_class_entry **pce;
+ reflection_method_factory(param->fptr->common.scope, param->fptr, return_value TSRMLS_CC);
+ }
+}
+/* }}} */
+#endif
+
+/* {{{ proto public ReflectionClass|NULL ReflectionParameter::getDeclaringClass()
+ Returns in which class this parameter is defined (not the typehint of the parameter) */
+ZEND_METHOD(reflection_parameter, getDeclaringClass)
+{
+ reflection_object *intern;
+ parameter_reference *param;
+
+ METHOD_NOTSTATIC_NUMPARAMS(reflection_parameter_ptr, 0);
+ GET_REFLECTION_OBJECT_PTR(param);
+
+ if (param->fptr->common.scope) {
+ zend_reflection_class_factory(param->fptr->common.scope, return_value TSRMLS_CC);
+ }
+}
+/* }}} */
+
+/* {{{ proto public ReflectionClass|NULL ReflectionParameter::getClass()
+ Returns this parameters's class hint or NULL if there is none */
+ZEND_METHOD(reflection_parameter, getClass)
+{
+ reflection_object *intern;
+ parameter_reference *param;
+ zend_class_entry **pce;
+
+ METHOD_NOTSTATIC_NUMPARAMS(reflection_parameter_ptr, 0);
+ GET_REFLECTION_OBJECT_PTR(param);
- if (zend_lookup_class_ex(param->arg_info->class_name, param->arg_info->class_name_len, 1, &pce TSRMLS_CC) == FAILURE) {
+ if (param->arg_info->class_name) {
+ if (zend_lookup_class(param->arg_info->class_name, param->arg_info->class_name_len, &pce TSRMLS_CC) == FAILURE) {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Class %s does not exist", param->arg_info->class_name);
return;
@@ -1968,6 +2002,22 @@ ZEND_METHOD(reflection_parameter, isPassedByReference)
}
/* }}} */
+#if MBO_0
+/* {{{ proto public bool ReflectionParameter::getPosition()
+ Returns whether this parameter is an optional parameter */
+ZEND_METHOD(reflection_parameter, getPosition)
+{
+ reflection_object *intern;
+ parameter_reference *param;
+
+ METHOD_NOTSTATIC_NUMPARAMS(reflection_parameter_ptr, 0);
+ GET_REFLECTION_OBJECT_PTR(param);
+
+ RETVAL_LONG(param->offset);
+}
+/* }}} */
+#endif
+
/* {{{ proto public bool ReflectionParameter::isOptional()
Returns whether this parameter is an optional parameter */
ZEND_METHOD(reflection_parameter, isOptional)
@@ -4295,10 +4345,16 @@ static zend_function_entry reflection_parameter_functions[] = {
ZEND_ME(reflection_parameter, __toString, NULL, 0)
ZEND_ME(reflection_parameter, getName, NULL, 0)
ZEND_ME(reflection_parameter, isPassedByReference, NULL, 0)
+#if MBO_0
+ ZEND_ME(reflection_parameter, getDeclaringFunction, NULL, 0)
+#endif
ZEND_ME(reflection_parameter, getDeclaringClass, NULL, 0)
- ZEND_MALIAS(reflection_parameter, getClass, getDeclaringClass, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED)
+ ZEND_ME(reflection_parameter, getClass, NULL, 0)
ZEND_ME(reflection_parameter, isArray, NULL, 0)
ZEND_ME(reflection_parameter, allowsNull, NULL, 0)
+#if MBO_0
+ ZEND_ME(reflection_parameter, getPosition, NULL, 0)
+#endif
ZEND_ME(reflection_parameter, isOptional, NULL, 0)
ZEND_ME(reflection_parameter, isDefaultValueAvailable, NULL, 0)
ZEND_ME(reflection_parameter, getDefaultValue, NULL, 0)