}
efree(lcname);
module = module_ptr;
+ EG(current_module) = module;
if (module->functions && zend_register_functions(NULL, module->functions, NULL, module->type TSRMLS_CC)==FAILURE) {
+ EG(current_module) = NULL;
zend_error(E_CORE_WARNING,"%s: Unable to register functions, unable to load", module->name);
return NULL;
}
+ EG(current_module) = NULL;
return module;
}
target_function_table = CG(function_table);
}
internal_function->type = ZEND_INTERNAL_FUNCTION;
-
+ internal_function->module = EG(current_module);
+
if (scope) {
class_name_len = scope->name_length;
lc_class_name = zend_str_tolower_dup(scope->name, class_name_len);
Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant),
((zend_op_array *) function)->filename,
((zend_op_array *) function)->opcodes[0].lineno);
+ } else if (((zend_internal_function *)function)->module) {
+ zend_error(error_level, "Cannot redeclare %R() (internal function exists in module %s)",
+ Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant),
+ ((zend_internal_function *)function)->module->name);
} else {
zend_error(error_level, "Cannot redeclare %R()", Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant));
}
/* END of common elements */
void (*handler)(INTERNAL_FUNCTION_PARAMETERS);
+ struct _zend_module_entry *module;
} zend_internal_function;
#define ZEND_FN_SCOPE_NAME(function) ((function) && (function)->common.scope ? (function)->common.scope->name : EMPTY_STR)
if (zobj->ce->__call) {
zend_internal_function *call_user_call = emalloc(sizeof(zend_internal_function));
call_user_call->type = ZEND_INTERNAL_FUNCTION;
+ call_user_call->module = zobj->ce->module;
call_user_call->handler = zend_std_call_user_call;
call_user_call->arg_info = NULL;
call_user_call->num_args = 0;
}
string_printf(str, fptr->common.scope ? "%sMethod [ " : "%sFunction [ ", indent);
- string_printf(str, (fptr->type == ZEND_USER_FUNCTION) ? "<user> " : "<internal> ");
+ string_printf(str, (fptr->type == ZEND_USER_FUNCTION) ? "<user" : "<internal");
+ if (fptr->type == ZEND_INTERNAL_FUNCTION && ((zend_internal_function*)fptr)->module) {
+ string_printf(str, ":%s", ((zend_internal_function*)fptr)->module->name);
+ }
+ string_printf(str, "> ");
+
+
if (fptr->common.fn_flags & ZEND_ACC_CTOR) {
string_printf(str, "<ctor> ");
}
}
/* }}} */
-/* {{{ proto public ReflectionParameter[] Reflection_Function::getParameters()
+/* {{{ proto public ReflectionParameter[] ReflectionFunction::getParameters()
Returns an array of parameter objects for this function */
ZEND_METHOD(reflection_function, getParameters)
{
}
/* }}} */
+/* {{{ proto public ReflectionExtension|NULL ReflectionFunction::getExtension()
+ Returns NULL or the extension the function belongs to */
+ZEND_METHOD(reflection_function, getExtension)
+{
+ reflection_object *intern;
+ zend_function *fptr;
+ zend_internal_function *internal;
+
+ METHOD_NOTSTATIC;
+ GET_REFLECTION_OBJECT_PTR(fptr);
+
+ if (fptr->type != ZEND_INTERNAL_FUNCTION) {
+ RETURN_NULL();
+ }
+
+ internal = (zend_internal_function *)fptr;
+ if (internal->module) {
+ reflection_extension_factory(return_value, internal->module->name TSRMLS_CC);
+ } else {
+ RETURN_NULL();
+ }
+}
+/* }}} */
+
+/* {{{ proto public string|false ReflectionFunction::getExtensionName()
+ Returns false or the name of the extension the function belongs to */
+ZEND_METHOD(reflection_function, getExtensionName)
+{
+ reflection_object *intern;
+ zend_function *fptr;
+ zend_internal_function *internal;
+
+ METHOD_NOTSTATIC;
+ GET_REFLECTION_OBJECT_PTR(fptr);
+
+ if (fptr->type != ZEND_INTERNAL_FUNCTION) {
+ RETURN_FALSE;
+ }
+
+ internal = (zend_internal_function *)fptr;
+ if (internal->module) {
+ RETURN_STRING(internal->module->name, 1);
+ } else {
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
/* {{{ proto public static mixed ReflectionParameter::export(mixed function, mixed parameter [, bool return]) throws ReflectionException
Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
ZEND_METHOD(reflection_parameter, export)
ZEND_ME(reflection_function, getParameters, NULL, 0)
ZEND_ME(reflection_function, getNumberOfParameters, NULL, 0)
ZEND_ME(reflection_function, getNumberOfRequiredParameters, NULL, 0)
+ ZEND_ME(reflection_function, getExtension, NULL, 0)
+ ZEND_ME(reflection_function, getExtensionName, NULL, 0)
{NULL, NULL, NULL}
};
}
string_printf(str, fptr->common.scope ? "%sMethod [ " : "%sFunction [ ", indent);
- string_printf(str, (fptr->type == ZEND_USER_FUNCTION) ? "<user> " : "<internal> ");
+ string_printf(str, (fptr->type == ZEND_USER_FUNCTION) ? "<user" : "<internal");
+ if (fptr->type == ZEND_INTERNAL_FUNCTION && ((zend_internal_function*)fptr)->module) {
+ string_printf(str, ":%s", ((zend_internal_function*)fptr)->module->name);
+ }
+ string_printf(str, "> ");
+
+
if (fptr->common.fn_flags & ZEND_ACC_CTOR) {
string_printf(str, "<ctor> ");
}
}
/* }}} */
-/* {{{ proto public ReflectionParameter[] Reflection_Function::getParameters()
+/* {{{ proto public ReflectionParameter[] ReflectionFunction::getParameters()
Returns an array of parameter objects for this function */
ZEND_METHOD(reflection_function, getParameters)
{
}
/* }}} */
+/* {{{ proto public ReflectionExtension|NULL ReflectionFunction::getExtension()
+ Returns NULL or the extension the function belongs to */
+ZEND_METHOD(reflection_function, getExtension)
+{
+ reflection_object *intern;
+ zend_function *fptr;
+ zend_internal_function *internal;
+
+ METHOD_NOTSTATIC;
+ GET_REFLECTION_OBJECT_PTR(fptr);
+
+ if (fptr->type != ZEND_INTERNAL_FUNCTION) {
+ RETURN_NULL();
+ }
+
+ internal = (zend_internal_function *)fptr;
+ if (internal->module) {
+ reflection_extension_factory(return_value, internal->module->name TSRMLS_CC);
+ } else {
+ RETURN_NULL();
+ }
+}
+/* }}} */
+
+/* {{{ proto public string|false ReflectionFunction::getExtensionName()
+ Returns false or the name of the extension the function belongs to */
+ZEND_METHOD(reflection_function, getExtensionName)
+{
+ reflection_object *intern;
+ zend_function *fptr;
+ zend_internal_function *internal;
+
+ METHOD_NOTSTATIC;
+ GET_REFLECTION_OBJECT_PTR(fptr);
+
+ if (fptr->type != ZEND_INTERNAL_FUNCTION) {
+ RETURN_FALSE;
+ }
+
+ internal = (zend_internal_function *)fptr;
+ if (internal->module) {
+ RETURN_STRING(internal->module->name, 1);
+ } else {
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
/* {{{ proto public static mixed ReflectionParameter::export(mixed function, mixed parameter [, bool return]) throws ReflectionException
Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
ZEND_METHOD(reflection_parameter, export)
ZEND_ME(reflection_function, getParameters, NULL, 0)
ZEND_ME(reflection_function, getNumberOfParameters, NULL, 0)
ZEND_ME(reflection_function, getNumberOfRequiredParameters, NULL, 0)
+ ZEND_ME(reflection_function, getExtension, NULL, 0)
+ ZEND_ME(reflection_function, getExtensionName, NULL, 0)
{NULL, NULL, NULL}
};