|
|
|
@ -235,8 +235,8 @@ static void _free_function(zend_function *fptr TSRMLS_DC) /* {{{ */ |
|
|
|
{ |
|
|
|
if (fptr |
|
|
|
&& fptr->type == ZEND_INTERNAL_FUNCTION |
|
|
|
&& (fptr->internal_function.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0 |
|
|
|
) { |
|
|
|
&& (fptr->internal_function.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0) |
|
|
|
{ |
|
|
|
efree(fptr->internal_function.function_name); |
|
|
|
efree(fptr); |
|
|
|
} |
|
|
|
@ -363,7 +363,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in |
|
|
|
/* The information where a class is declared is only available for user classes */ |
|
|
|
if (ce->type == ZEND_USER_CLASS) { |
|
|
|
string_printf(str, "%s @@ %s %d-%d\n", indent, ce->filename, |
|
|
|
ce->line_start, ce->line_end); |
|
|
|
ce->line_start, ce->line_end); |
|
|
|
} |
|
|
|
|
|
|
|
/* Constants */ |
|
|
|
@ -442,7 +442,8 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in |
|
|
|
|
|
|
|
while (zend_hash_get_current_data_ex(&ce->function_table, (void **) &mptr, &pos) == SUCCESS) { |
|
|
|
if (mptr->common.fn_flags & ZEND_ACC_STATIC |
|
|
|
&& ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce)) { |
|
|
|
&& ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce)) |
|
|
|
{ |
|
|
|
count_static_funcs++; |
|
|
|
} |
|
|
|
zend_hash_move_forward_ex(&ce->function_table, &pos); |
|
|
|
@ -459,7 +460,8 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in |
|
|
|
|
|
|
|
while (zend_hash_get_current_data_ex(&ce->function_table, (void **) &mptr, &pos) == SUCCESS) { |
|
|
|
if (mptr->common.fn_flags & ZEND_ACC_STATIC |
|
|
|
&& ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce)) { |
|
|
|
&& ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce)) |
|
|
|
{ |
|
|
|
string_printf(str, "\n"); |
|
|
|
_function_string(str, mptr, ce, sub_indent.string TSRMLS_CC); |
|
|
|
} |
|
|
|
@ -538,25 +540,26 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in |
|
|
|
zend_hash_internal_pointer_reset_ex(&ce->function_table, &pos); |
|
|
|
|
|
|
|
while (zend_hash_get_current_data_ex(&ce->function_table, (void **) &mptr, &pos) == SUCCESS) { |
|
|
|
if ((mptr->common.fn_flags & ZEND_ACC_STATIC) == 0 && |
|
|
|
((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce)) { |
|
|
|
if ((mptr->common.fn_flags & ZEND_ACC_STATIC) == 0 |
|
|
|
&& ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce)) |
|
|
|
{ |
|
|
|
char *key; |
|
|
|
uint key_len; |
|
|
|
ulong num_index; |
|
|
|
uint len = strlen(mptr->common.function_name); |
|
|
|
|
|
|
|
/* Do not display old-style inherited constructors */ |
|
|
|
if ((mptr->common.fn_flags & ZEND_ACC_CTOR) == 0 || |
|
|
|
mptr->common.scope == ce || |
|
|
|
zend_hash_get_current_key_ex(&ce->function_table, &key, &key_len, &num_index, 0, &pos) != HASH_KEY_IS_STRING || |
|
|
|
zend_binary_strcasecmp(key, key_len-1, mptr->common.function_name, len) == 0) { |
|
|
|
|
|
|
|
if ((mptr->common.fn_flags & ZEND_ACC_CTOR) == 0 |
|
|
|
|| mptr->common.scope == ce |
|
|
|
|| zend_hash_get_current_key_ex(&ce->function_table, &key, &key_len, &num_index, 0, &pos) != HASH_KEY_IS_STRING |
|
|
|
|| zend_binary_strcasecmp(key, key_len-1, mptr->common.function_name, len) == 0) |
|
|
|
{ |
|
|
|
zend_function *closure; |
|
|
|
/* see if this is a closure */ |
|
|
|
if (ce == zend_ce_closure && obj && (len == sizeof(ZEND_INVOKE_FUNC_NAME)-1) && |
|
|
|
memcmp(mptr->common.function_name, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0 && |
|
|
|
(closure = zend_get_closure_invoke_method(obj TSRMLS_CC)) != NULL |
|
|
|
) { |
|
|
|
if (ce == zend_ce_closure && obj && (len == sizeof(ZEND_INVOKE_FUNC_NAME)-1) |
|
|
|
&& memcmp(mptr->common.function_name, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0 |
|
|
|
&& (closure = zend_get_closure_invoke_method(obj TSRMLS_CC)) != NULL) |
|
|
|
{ |
|
|
|
mptr = closure; |
|
|
|
} else { |
|
|
|
closure = NULL; |
|
|
|
@ -601,10 +604,7 @@ static void _const_string(string *str, char *name, zval *value, char *indent TSR |
|
|
|
} |
|
|
|
|
|
|
|
string_printf(str, "%s Constant [ %s %s ] { %s }\n", |
|
|
|
indent, |
|
|
|
type, |
|
|
|
name, |
|
|
|
Z_STRVAL_P(value)); |
|
|
|
indent, type, name, Z_STRVAL_P(value)); |
|
|
|
|
|
|
|
if (use_copy) { |
|
|
|
zval_dtor(value); |
|
|
|
@ -620,11 +620,12 @@ static zend_op* _get_recv_op(zend_op_array *op_array, zend_uint offset) |
|
|
|
|
|
|
|
++offset; |
|
|
|
while (op < end) { |
|
|
|
if ((op->opcode == ZEND_RECV || op->opcode == ZEND_RECV_INIT) && |
|
|
|
op->op1.u.constant.value.lval == (long)offset) { |
|
|
|
return op; |
|
|
|
} |
|
|
|
++op; |
|
|
|
if ((op->opcode == ZEND_RECV || op->opcode == ZEND_RECV_INIT) |
|
|
|
&& op->op1.u.constant.value.lval == (long)offset) |
|
|
|
{ |
|
|
|
return op; |
|
|
|
} |
|
|
|
++op; |
|
|
|
} |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
@ -793,8 +794,8 @@ static void _function_string(string *str, zend_function *fptr, zend_class_entry |
|
|
|
string_printf(str, "protected "); |
|
|
|
break; |
|
|
|
default: |
|
|
|
string_printf(str, "<visibility error> "); |
|
|
|
break; |
|
|
|
string_printf(str, "<visibility error> "); |
|
|
|
break; |
|
|
|
} |
|
|
|
string_printf(str, "method "); |
|
|
|
} else { |
|
|
|
@ -808,9 +809,9 @@ static void _function_string(string *str, zend_function *fptr, zend_class_entry |
|
|
|
/* The information where a function is declared is only available for user classes */ |
|
|
|
if (fptr->type == ZEND_USER_FUNCTION) { |
|
|
|
string_printf(str, "%s @@ %s %d - %d\n", indent, |
|
|
|
fptr->op_array.filename, |
|
|
|
fptr->op_array.line_start, |
|
|
|
fptr->op_array.line_end); |
|
|
|
fptr->op_array.filename, |
|
|
|
fptr->op_array.line_start, |
|
|
|
fptr->op_array.line_end); |
|
|
|
} |
|
|
|
string_init(¶m_indent); |
|
|
|
string_printf(¶m_indent, "%s ", indent); |
|
|
|
@ -885,7 +886,7 @@ static int _extension_ini_string(zend_ini_entry *ini_entry TSRMLS_DC, int num_ar |
|
|
|
string_printf(str, "%sSYSTEM", comma); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
string_printf(str, "> ]\n"); |
|
|
|
string_printf(str, " %s Current = '%s'\n", indent, ini_entry->value ? ini_entry->value : ""); |
|
|
|
if (ini_entry->modified) { |
|
|
|
@ -936,8 +937,8 @@ static void _extension_string(string *str, zend_module_entry *module, char *inde |
|
|
|
string_printf(str, "<temporary>" ); |
|
|
|
} |
|
|
|
string_printf(str, " extension #%d %s version %s ] {\n", |
|
|
|
module->module_number, module->name, |
|
|
|
(module->version == NO_VERSION_YET) ? "<no_version>" : module->version); |
|
|
|
module->module_number, module->name, |
|
|
|
(module->version == NO_VERSION_YET) ? "<no_version>" : module->version); |
|
|
|
|
|
|
|
if (module->deps) { |
|
|
|
const zend_module_dep* dep = module->deps; |
|
|
|
@ -1778,13 +1779,13 @@ ZEND_METHOD(reflection_function, getParameters) |
|
|
|
|
|
|
|
array_init(return_value); |
|
|
|
for (i = 0; i < fptr->common.num_args; i++) { |
|
|
|
zval *parameter; |
|
|
|
zval *parameter; |
|
|
|
|
|
|
|
ALLOC_ZVAL(parameter); |
|
|
|
reflection_parameter_factory(fptr, arg_info, i, fptr->common.required_num_args, parameter TSRMLS_CC); |
|
|
|
add_next_index_zval(return_value, parameter); |
|
|
|
|
|
|
|
arg_info++; |
|
|
|
ALLOC_ZVAL(parameter); |
|
|
|
reflection_parameter_factory(fptr, arg_info, i, fptr->common.required_num_args, parameter TSRMLS_CC); |
|
|
|
add_next_index_zval(return_value, parameter); |
|
|
|
|
|
|
|
arg_info++; |
|
|
|
} |
|
|
|
} |
|
|
|
/* }}} */ |
|
|
|
@ -1896,7 +1897,8 @@ ZEND_METHOD(reflection_parameter, __construct) |
|
|
|
char *lcname; |
|
|
|
|
|
|
|
if ((zend_hash_index_find(Z_ARRVAL_P(reference), 0, (void **) &classref) == FAILURE) |
|
|
|
|| (zend_hash_index_find(Z_ARRVAL_P(reference), 1, (void **) &method) == FAILURE)) { |
|
|
|
|| (zend_hash_index_find(Z_ARRVAL_P(reference), 1, (void **) &method) == FAILURE)) |
|
|
|
{ |
|
|
|
_DO_THROW("Expected array($object, $method) or array($classname, $method)"); |
|
|
|
/* returns out of this function */ |
|
|
|
} |
|
|
|
@ -1916,11 +1918,11 @@ ZEND_METHOD(reflection_parameter, __construct) |
|
|
|
convert_to_string_ex(method); |
|
|
|
lcname_len = Z_STRLEN_PP(method); |
|
|
|
lcname = zend_str_tolower_dup(Z_STRVAL_PP(method), lcname_len); |
|
|
|
if (ce == zend_ce_closure && Z_TYPE_PP(classref) == IS_OBJECT && |
|
|
|
(lcname_len == sizeof(ZEND_INVOKE_FUNC_NAME)-1) && |
|
|
|
memcmp(lcname, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0 && |
|
|
|
(fptr = zend_get_closure_invoke_method(*classref TSRMLS_CC)) != NULL |
|
|
|
) { |
|
|
|
if (ce == zend_ce_closure && Z_TYPE_PP(classref) == IS_OBJECT |
|
|
|
&& (lcname_len == sizeof(ZEND_INVOKE_FUNC_NAME)-1) |
|
|
|
&& memcmp(lcname, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0 |
|
|
|
&& (fptr = zend_get_closure_invoke_method(*classref TSRMLS_CC)) != NULL) |
|
|
|
{ |
|
|
|
/* nothign to do */ |
|
|
|
} else if (zend_hash_find(&ce->function_table, lcname, lcname_len + 1, (void **) &fptr) == FAILURE) { |
|
|
|
efree(lcname); |
|
|
|
@ -2081,22 +2083,22 @@ ZEND_METHOD(reflection_parameter, getClass) |
|
|
|
if (0 == strncmp(param->arg_info->class_name, "self", sizeof("self")- 1)) { |
|
|
|
ce = param->fptr->common.scope; |
|
|
|
if (!ce) { |
|
|
|
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, |
|
|
|
"Parameter uses 'self' as type hint but function is not a class member!"); |
|
|
|
return; |
|
|
|
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, |
|
|
|
"Parameter uses 'self' as type hint but function is not a class member!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
pce= &ce; |
|
|
|
} else if (0 == strncmp(param->arg_info->class_name, "parent", sizeof("parent")- 1)) { |
|
|
|
ce = param->fptr->common.scope; |
|
|
|
if (!ce) { |
|
|
|
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, |
|
|
|
"Parameter uses 'parent' as type hint but function is not a class member!"); |
|
|
|
return; |
|
|
|
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, |
|
|
|
"Parameter uses 'parent' as type hint but function is not a class member!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (!ce->parent) { |
|
|
|
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, |
|
|
|
"Parameter uses 'parent' as type hint although class does not have a parent!"); |
|
|
|
return; |
|
|
|
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, |
|
|
|
"Parameter uses 'parent' as type hint although class does not have a parent!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
pce= &ce->parent; |
|
|
|
} else if (zend_lookup_class(param->arg_info->class_name, param->arg_info->class_name_len, &pce TSRMLS_CC) == FAILURE) { |
|
|
|
@ -2330,10 +2332,10 @@ ZEND_METHOD(reflection_method, __construct) |
|
|
|
|
|
|
|
lcname = zend_str_tolower_dup(name_str, name_len); |
|
|
|
|
|
|
|
if (ce == zend_ce_closure && orig_obj && (name_len == sizeof(ZEND_INVOKE_FUNC_NAME)-1) && |
|
|
|
memcmp(lcname, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0 && |
|
|
|
(mptr = zend_get_closure_invoke_method(orig_obj TSRMLS_CC)) != NULL |
|
|
|
) { |
|
|
|
if (ce == zend_ce_closure && orig_obj && (name_len == sizeof(ZEND_INVOKE_FUNC_NAME)-1) |
|
|
|
&& memcmp(lcname, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0 |
|
|
|
&& (mptr = zend_get_closure_invoke_method(orig_obj TSRMLS_CC)) != NULL) |
|
|
|
{ |
|
|
|
/* do nothing, mptr already set */ |
|
|
|
} else if (zend_hash_find(&ce->function_table, lcname, name_len + 1, (void **) &mptr) == FAILURE) { |
|
|
|
efree(lcname); |
|
|
|
@ -2414,8 +2416,9 @@ ZEND_METHOD(reflection_method, invoke) |
|
|
|
|
|
|
|
GET_REFLECTION_OBJECT_PTR(mptr); |
|
|
|
|
|
|
|
if (!(mptr->common.fn_flags & ZEND_ACC_PUBLIC) || |
|
|
|
(mptr->common.fn_flags & ZEND_ACC_ABSTRACT)) { |
|
|
|
if (!(mptr->common.fn_flags & ZEND_ACC_PUBLIC) |
|
|
|
|| (mptr->common.fn_flags & ZEND_ACC_ABSTRACT)) |
|
|
|
{ |
|
|
|
if (mptr->common.fn_flags & ZEND_ACC_ABSTRACT) { |
|
|
|
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, |
|
|
|
"Trying to invoke abstract method %s::%s()", |
|
|
|
@ -2521,8 +2524,9 @@ ZEND_METHOD(reflection_method, invokeArgs) |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (!(mptr->common.fn_flags & ZEND_ACC_PUBLIC) || |
|
|
|
(mptr->common.fn_flags & ZEND_ACC_ABSTRACT)) { |
|
|
|
if (!(mptr->common.fn_flags & ZEND_ACC_PUBLIC) |
|
|
|
|| (mptr->common.fn_flags & ZEND_ACC_ABSTRACT)) |
|
|
|
{ |
|
|
|
if (mptr->common.fn_flags & ZEND_ACC_ABSTRACT) { |
|
|
|
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, |
|
|
|
"Trying to invoke abstract method %s::%s", |
|
|
|
@ -2669,9 +2673,10 @@ ZEND_METHOD(reflection_function, inNamespace) |
|
|
|
if (zend_hash_find(Z_OBJPROP_P(getThis()), "name", sizeof("name"), (void **) &name) == FAILURE) { |
|
|
|
RETURN_FALSE; |
|
|
|
} |
|
|
|
if (Z_TYPE_PP(name) == IS_STRING && |
|
|
|
(colon = zend_memrchr(Z_STRVAL_PP(name), ':', Z_STRLEN_PP(name))) && |
|
|
|
colon > Z_STRVAL_PP(name) && *(colon-1) == ':') { |
|
|
|
if (Z_TYPE_PP(name) == IS_STRING |
|
|
|
&& (colon = zend_memrchr(Z_STRVAL_PP(name), ':', Z_STRLEN_PP(name))) |
|
|
|
&& colon > Z_STRVAL_PP(name) && *(colon-1) == ':') |
|
|
|
{ |
|
|
|
RETURN_TRUE; |
|
|
|
} |
|
|
|
RETURN_FALSE; |
|
|
|
@ -2689,9 +2694,10 @@ ZEND_METHOD(reflection_function, getNamespaceName) |
|
|
|
if (zend_hash_find(Z_OBJPROP_P(getThis()), "name", sizeof("name"), (void **) &name) == FAILURE) { |
|
|
|
RETURN_FALSE; |
|
|
|
} |
|
|
|
if (Z_TYPE_PP(name) == IS_STRING && |
|
|
|
(colon = zend_memrchr(Z_STRVAL_PP(name), ':', Z_STRLEN_PP(name))) && |
|
|
|
colon > Z_STRVAL_PP(name) && *(colon-1) == ':') { |
|
|
|
if (Z_TYPE_PP(name) == IS_STRING |
|
|
|
&& (colon = zend_memrchr(Z_STRVAL_PP(name), ':', Z_STRLEN_PP(name))) |
|
|
|
&& colon > Z_STRVAL_PP(name) && *(colon-1) == ':') |
|
|
|
{ |
|
|
|
RETURN_STRINGL(Z_STRVAL_PP(name), colon - Z_STRVAL_PP(name) - 1, 1); |
|
|
|
} |
|
|
|
RETURN_EMPTY_STRING(); |
|
|
|
@ -2709,9 +2715,10 @@ ZEND_METHOD(reflection_function, getShortName) |
|
|
|
if (zend_hash_find(Z_OBJPROP_P(getThis()), "name", sizeof("name"), (void **) &name) == FAILURE) { |
|
|
|
RETURN_FALSE; |
|
|
|
} |
|
|
|
if (Z_TYPE_PP(name) == IS_STRING && |
|
|
|
(colon = zend_memrchr(Z_STRVAL_PP(name), ':', Z_STRLEN_PP(name))) && |
|
|
|
colon > Z_STRVAL_PP(name) && *(colon-1) == ':') { |
|
|
|
if (Z_TYPE_PP(name) == IS_STRING |
|
|
|
&& (colon = zend_memrchr(Z_STRVAL_PP(name), ':', Z_STRLEN_PP(name))) |
|
|
|
&& colon > Z_STRVAL_PP(name) && *(colon-1) == ':') |
|
|
|
{ |
|
|
|
RETURN_STRINGL(colon + 1, Z_STRLEN_PP(name) - (colon - Z_STRVAL_PP(name) + 1), 1); |
|
|
|
} |
|
|
|
RETURN_ZVAL(*name, 1, 0); |
|
|
|
@ -3199,10 +3206,10 @@ ZEND_METHOD(reflection_class, getMethod) |
|
|
|
|
|
|
|
GET_REFLECTION_OBJECT_PTR(ce); |
|
|
|
lc_name = zend_str_tolower_dup(name, name_len); |
|
|
|
if (ce == zend_ce_closure && intern->obj && (name_len == sizeof(ZEND_INVOKE_FUNC_NAME)-1) && |
|
|
|
memcmp(lc_name, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0 && |
|
|
|
(mptr = zend_get_closure_invoke_method(intern->obj TSRMLS_CC)) != NULL |
|
|
|
) { |
|
|
|
if (ce == zend_ce_closure && intern->obj && (name_len == sizeof(ZEND_INVOKE_FUNC_NAME)-1) |
|
|
|
&& memcmp(lc_name, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0 |
|
|
|
&& (mptr = zend_get_closure_invoke_method(intern->obj TSRMLS_CC)) != NULL) |
|
|
|
{ |
|
|
|
reflection_method_factory(ce, mptr, return_value TSRMLS_CC); |
|
|
|
efree(lc_name); |
|
|
|
} else if (zend_hash_find(&ce->function_table, lc_name, name_len + 1, (void**) &mptr) == SUCCESS) { |
|
|
|
@ -3226,10 +3233,10 @@ static void _addmethod(zend_function *mptr, zend_class_entry *ce, zval *retval, |
|
|
|
|
|
|
|
if (mptr->common.fn_flags & filter) { |
|
|
|
ALLOC_ZVAL(method); |
|
|
|
if (ce == zend_ce_closure && obj && (len == sizeof(ZEND_INVOKE_FUNC_NAME)-1) && |
|
|
|
memcmp(mptr->common.function_name, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0 && |
|
|
|
(closure = zend_get_closure_invoke_method(obj TSRMLS_CC)) != NULL |
|
|
|
) { |
|
|
|
if (ce == zend_ce_closure && obj && (len == sizeof(ZEND_INVOKE_FUNC_NAME)-1) |
|
|
|
&& memcmp(mptr->common.function_name, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0 |
|
|
|
&& (closure = zend_get_closure_invoke_method(obj TSRMLS_CC)) != NULL) |
|
|
|
{ |
|
|
|
mptr = closure; |
|
|
|
} |
|
|
|
reflection_method_factory(ce, mptr, method TSRMLS_CC); |
|
|
|
@ -3766,7 +3773,7 @@ ZEND_METHOD(reflection_class, getInterfaces) |
|
|
|
if (ce->num_interfaces) { |
|
|
|
zend_uint i; |
|
|
|
|
|
|
|
for (i=0; i < ce->num_interfaces; i++) { |
|
|
|
for (i=0; i < ce->num_interfaces; i++) { |
|
|
|
zval *interface; |
|
|
|
ALLOC_ZVAL(interface); |
|
|
|
zend_reflection_class_factory(ce->interfaces[i], interface TSRMLS_CC); |
|
|
|
@ -3790,7 +3797,7 @@ ZEND_METHOD(reflection_class, getInterfaceNames) |
|
|
|
/* Return an empty array if this class implements no interfaces */ |
|
|
|
array_init(return_value); |
|
|
|
|
|
|
|
for (i=0; i < ce->num_interfaces; i++) { |
|
|
|
for (i=0; i < ce->num_interfaces; i++) { |
|
|
|
add_next_index_stringl(return_value, ce->interfaces[i]->name, ce->interfaces[i]->name_length, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -3968,11 +3975,12 @@ ZEND_METHOD(reflection_class, inNamespace) |
|
|
|
if (zend_hash_find(Z_OBJPROP_P(getThis()), "name", sizeof("name"), (void **) &name) == FAILURE) { |
|
|
|
RETURN_FALSE; |
|
|
|
} |
|
|
|
if (Z_TYPE_PP(name) == IS_STRING && |
|
|
|
(colon = zend_memrchr(Z_STRVAL_PP(name), ':', Z_STRLEN_PP(name))) && |
|
|
|
colon > Z_STRVAL_PP(name) && *(colon-1) == ':') { |
|
|
|
if (Z_TYPE_PP(name) == IS_STRING |
|
|
|
&& (colon = zend_memrchr(Z_STRVAL_PP(name), ':', Z_STRLEN_PP(name))) |
|
|
|
&& colon > Z_STRVAL_PP(name) && *(colon-1) == ':') |
|
|
|
{ |
|
|
|
RETURN_TRUE; |
|
|
|
} |
|
|
|
} |
|
|
|
RETURN_FALSE; |
|
|
|
} |
|
|
|
/* }}} */ |
|
|
|
@ -3988,11 +3996,12 @@ ZEND_METHOD(reflection_class, getNamespaceName) |
|
|
|
if (zend_hash_find(Z_OBJPROP_P(getThis()), "name", sizeof("name"), (void **) &name) == FAILURE) { |
|
|
|
RETURN_FALSE; |
|
|
|
} |
|
|
|
if (Z_TYPE_PP(name) == IS_STRING && |
|
|
|
(colon = zend_memrchr(Z_STRVAL_PP(name), ':', Z_STRLEN_PP(name))) && |
|
|
|
colon > Z_STRVAL_PP(name) && *(colon-1) == ':') { |
|
|
|
if (Z_TYPE_PP(name) == IS_STRING |
|
|
|
&& (colon = zend_memrchr(Z_STRVAL_PP(name), ':', Z_STRLEN_PP(name))) |
|
|
|
&& colon > Z_STRVAL_PP(name) && *(colon-1) == ':') |
|
|
|
{ |
|
|
|
RETURN_STRINGL(Z_STRVAL_PP(name), colon - Z_STRVAL_PP(name) - 1, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
RETURN_EMPTY_STRING(); |
|
|
|
} |
|
|
|
/* }}} */ |
|
|
|
@ -4008,12 +4017,13 @@ ZEND_METHOD(reflection_class, getShortName) |
|
|
|
if (zend_hash_find(Z_OBJPROP_P(getThis()), "name", sizeof("name"), (void **) &name) == FAILURE) { |
|
|
|
RETURN_FALSE; |
|
|
|
} |
|
|
|
if (Z_TYPE_PP(name) == IS_STRING && |
|
|
|
(colon = zend_memrchr(Z_STRVAL_PP(name), ':', Z_STRLEN_PP(name))) && |
|
|
|
colon > Z_STRVAL_PP(name) && *(colon-1) == ':') { |
|
|
|
if (Z_TYPE_PP(name) == IS_STRING |
|
|
|
&& (colon = zend_memrchr(Z_STRVAL_PP(name), ':', Z_STRLEN_PP(name))) |
|
|
|
&& colon > Z_STRVAL_PP(name) && *(colon-1) == ':') |
|
|
|
{ |
|
|
|
RETURN_STRINGL(colon + 1, Z_STRLEN_PP(name) - (colon - Z_STRVAL_PP(name) + 1), 1); |
|
|
|
} |
|
|
|
RETURN_ZVAL(*name, 1, 0); |
|
|
|
} |
|
|
|
RETURN_ZVAL(*name, 1, 0); |
|
|
|
} |
|
|
|
/* }}} */ |
|
|
|
|
|
|
|
@ -5103,9 +5113,9 @@ static zend_object_handlers *zend_std_obj_handlers; |
|
|
|
static void _reflection_write_property(zval *object, zval *member, zval *value TSRMLS_DC) |
|
|
|
{ |
|
|
|
if ((Z_TYPE_P(member) == IS_STRING) |
|
|
|
&& zend_hash_exists(&Z_OBJCE_P(object)->default_properties, Z_STRVAL_P(member), Z_STRLEN_P(member)+1) |
|
|
|
&& ((Z_STRLEN_P(member) == sizeof("name") - 1 && !memcmp(Z_STRVAL_P(member), "name", sizeof("name"))) || |
|
|
|
(Z_STRLEN_P(member) == sizeof("class") - 1 && !memcmp(Z_STRVAL_P(member), "class", sizeof("class"))))) |
|
|
|
&& zend_hash_exists(&Z_OBJCE_P(object)->default_properties, Z_STRVAL_P(member), Z_STRLEN_P(member)+1) |
|
|
|
&& ((Z_STRLEN_P(member) == sizeof("name") - 1 && !memcmp(Z_STRVAL_P(member), "name", sizeof("name"))) |
|
|
|
|| (Z_STRLEN_P(member) == sizeof("class") - 1 && !memcmp(Z_STRVAL_P(member), "class", sizeof("class"))))) |
|
|
|
{ |
|
|
|
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, |
|
|
|
"Cannot set read-only property %s::$%s", Z_OBJCE_P(object)->name, Z_STRVAL_P(member)); |
|
|
|
@ -5140,7 +5150,7 @@ PHP_MINIT_FUNCTION(reflection) /* {{{ */ |
|
|
|
reflection_function_abstract_ptr = zend_register_internal_class(&_reflection_entry TSRMLS_CC); |
|
|
|
reflection_register_implement(reflection_function_abstract_ptr, reflector_ptr TSRMLS_CC); |
|
|
|
zend_declare_property_string(reflection_function_abstract_ptr, "name", sizeof("name")-1, "", ZEND_ACC_ABSTRACT TSRMLS_CC); |
|
|
|
|
|
|
|
|
|
|
|
INIT_CLASS_ENTRY(_reflection_entry, "ReflectionFunction", reflection_function_functions); |
|
|
|
_reflection_entry.create_object = reflection_objects_new; |
|
|
|
reflection_function_ptr = zend_register_internal_class_ex(&_reflection_entry, reflection_function_abstract_ptr, NULL TSRMLS_CC); |
|
|
|
|