version 1.1.1.1, 2012/02/21 23:47:52
|
version 1.1.1.2, 2012/05/29 12:34:35
|
Line 50 static ZEND_FUNCTION(method_exists);
|
Line 50 static ZEND_FUNCTION(method_exists);
|
static ZEND_FUNCTION(property_exists); |
static ZEND_FUNCTION(property_exists); |
static ZEND_FUNCTION(class_exists); |
static ZEND_FUNCTION(class_exists); |
static ZEND_FUNCTION(interface_exists); |
static ZEND_FUNCTION(interface_exists); |
|
static ZEND_FUNCTION(trait_exists); |
static ZEND_FUNCTION(function_exists); |
static ZEND_FUNCTION(function_exists); |
static ZEND_FUNCTION(class_alias); |
static ZEND_FUNCTION(class_alias); |
#if ZEND_DEBUG |
#if ZEND_DEBUG |
static ZEND_FUNCTION(leak); |
static ZEND_FUNCTION(leak); |
|
static ZEND_FUNCTION(leak_variable); |
#ifdef ZEND_TEST_EXCEPTIONS |
#ifdef ZEND_TEST_EXCEPTIONS |
static ZEND_FUNCTION(crash); |
static ZEND_FUNCTION(crash); |
#endif |
#endif |
Line 70 static ZEND_FUNCTION(restore_error_handler);
|
Line 72 static ZEND_FUNCTION(restore_error_handler);
|
static ZEND_FUNCTION(set_exception_handler); |
static ZEND_FUNCTION(set_exception_handler); |
static ZEND_FUNCTION(restore_exception_handler); |
static ZEND_FUNCTION(restore_exception_handler); |
static ZEND_FUNCTION(get_declared_classes); |
static ZEND_FUNCTION(get_declared_classes); |
|
static ZEND_FUNCTION(get_declared_traits); |
static ZEND_FUNCTION(get_declared_interfaces); |
static ZEND_FUNCTION(get_declared_interfaces); |
static ZEND_FUNCTION(get_defined_functions); |
static ZEND_FUNCTION(get_defined_functions); |
static ZEND_FUNCTION(get_defined_vars); |
static ZEND_FUNCTION(get_defined_vars); |
Line 140 ZEND_END_ARG_INFO()
|
Line 143 ZEND_END_ARG_INFO()
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_is_subclass_of, 0, 0, 2) |
ZEND_BEGIN_ARG_INFO_EX(arginfo_is_subclass_of, 0, 0, 2) |
ZEND_ARG_INFO(0, object) |
ZEND_ARG_INFO(0, object) |
ZEND_ARG_INFO(0, class_name) |
ZEND_ARG_INFO(0, class_name) |
|
ZEND_ARG_INFO(0, allow_string) |
ZEND_END_ARG_INFO() |
ZEND_END_ARG_INFO() |
|
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_get_class_vars, 0, 0, 1) |
ZEND_BEGIN_ARG_INFO_EX(arginfo_get_class_vars, 0, 0, 1) |
Line 169 ZEND_BEGIN_ARG_INFO_EX(arginfo_class_exists, 0, 0, 1)
|
Line 173 ZEND_BEGIN_ARG_INFO_EX(arginfo_class_exists, 0, 0, 1)
|
ZEND_ARG_INFO(0, autoload) |
ZEND_ARG_INFO(0, autoload) |
ZEND_END_ARG_INFO() |
ZEND_END_ARG_INFO() |
|
|
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_trait_exists, 0, 0, 1) |
|
ZEND_ARG_INFO(0, traitname) |
|
ZEND_ARG_INFO(0, autoload) |
|
ZEND_END_ARG_INFO() |
|
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_function_exists, 0, 0, 1) |
ZEND_BEGIN_ARG_INFO_EX(arginfo_function_exists, 0, 0, 1) |
ZEND_ARG_INFO(0, function_name) |
ZEND_ARG_INFO(0, function_name) |
ZEND_END_ARG_INFO() |
ZEND_END_ARG_INFO() |
Line 179 ZEND_BEGIN_ARG_INFO_EX(arginfo_class_alias, 0, 0, 2)
|
Line 188 ZEND_BEGIN_ARG_INFO_EX(arginfo_class_alias, 0, 0, 2)
|
ZEND_ARG_INFO(0, autoload) |
ZEND_ARG_INFO(0, autoload) |
ZEND_END_ARG_INFO() |
ZEND_END_ARG_INFO() |
|
|
|
#if ZEND_DEBUG |
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_leak_variable, 0, 0, 1) |
|
ZEND_ARG_INFO(0, variable) |
|
ZEND_ARG_INFO(0, leak_data) |
|
ZEND_END_ARG_INFO() |
|
#endif |
|
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_trigger_error, 0, 0, 1) |
ZEND_BEGIN_ARG_INFO_EX(arginfo_trigger_error, 0, 0, 1) |
ZEND_ARG_INFO(0, message) |
ZEND_ARG_INFO(0, message) |
ZEND_ARG_INFO(0, error_type) |
ZEND_ARG_INFO(0, error_type) |
Line 212 ZEND_END_ARG_INFO()
|
Line 228 ZEND_END_ARG_INFO()
|
|
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_debug_backtrace, 0, 0, 0) |
ZEND_BEGIN_ARG_INFO_EX(arginfo_debug_backtrace, 0, 0, 0) |
ZEND_ARG_INFO(0, options) |
ZEND_ARG_INFO(0, options) |
|
ZEND_ARG_INFO(0, limit) |
ZEND_END_ARG_INFO() |
ZEND_END_ARG_INFO() |
|
|
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_debug_print_backtrace, 0, 0, 0) |
|
ZEND_ARG_INFO(0, options) |
|
ZEND_END_ARG_INFO() |
|
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_extension_loaded, 0, 0, 1) |
ZEND_BEGIN_ARG_INFO_EX(arginfo_extension_loaded, 0, 0, 1) |
ZEND_ARG_INFO(0, extension_name) |
ZEND_ARG_INFO(0, extension_name) |
ZEND_END_ARG_INFO() |
ZEND_END_ARG_INFO() |
Line 240 static const zend_function_entry builtin_functions[] =
|
Line 261 static const zend_function_entry builtin_functions[] =
|
ZEND_FE(property_exists, arginfo_property_exists) |
ZEND_FE(property_exists, arginfo_property_exists) |
ZEND_FE(class_exists, arginfo_class_exists) |
ZEND_FE(class_exists, arginfo_class_exists) |
ZEND_FE(interface_exists, arginfo_class_exists) |
ZEND_FE(interface_exists, arginfo_class_exists) |
|
ZEND_FE(trait_exists, arginfo_trait_exists) |
ZEND_FE(function_exists, arginfo_function_exists) |
ZEND_FE(function_exists, arginfo_function_exists) |
ZEND_FE(class_alias, arginfo_class_alias) |
ZEND_FE(class_alias, arginfo_class_alias) |
#if ZEND_DEBUG |
#if ZEND_DEBUG |
ZEND_FE(leak, NULL) |
ZEND_FE(leak, NULL) |
|
ZEND_FE(leak_variable, arginfo_leak_variable) |
#ifdef ZEND_TEST_EXCEPTIONS |
#ifdef ZEND_TEST_EXCEPTIONS |
ZEND_FE(crash, NULL) |
ZEND_FE(crash, NULL) |
#endif |
#endif |
Line 262 static const zend_function_entry builtin_functions[] =
|
Line 285 static const zend_function_entry builtin_functions[] =
|
ZEND_FE(set_exception_handler, arginfo_set_exception_handler) |
ZEND_FE(set_exception_handler, arginfo_set_exception_handler) |
ZEND_FE(restore_exception_handler, arginfo_zend__void) |
ZEND_FE(restore_exception_handler, arginfo_zend__void) |
ZEND_FE(get_declared_classes, arginfo_zend__void) |
ZEND_FE(get_declared_classes, arginfo_zend__void) |
|
ZEND_FE(get_declared_traits, arginfo_zend__void) |
ZEND_FE(get_declared_interfaces, arginfo_zend__void) |
ZEND_FE(get_declared_interfaces, arginfo_zend__void) |
ZEND_FE(get_defined_functions, arginfo_zend__void) |
ZEND_FE(get_defined_functions, arginfo_zend__void) |
ZEND_FE(get_defined_vars, arginfo_zend__void) |
ZEND_FE(get_defined_vars, arginfo_zend__void) |
Line 272 static const zend_function_entry builtin_functions[] =
|
Line 296 static const zend_function_entry builtin_functions[] =
|
ZEND_FE(get_extension_funcs, arginfo_extension_loaded) |
ZEND_FE(get_extension_funcs, arginfo_extension_loaded) |
ZEND_FE(get_defined_constants, arginfo_get_defined_constants) |
ZEND_FE(get_defined_constants, arginfo_get_defined_constants) |
ZEND_FE(debug_backtrace, arginfo_debug_backtrace) |
ZEND_FE(debug_backtrace, arginfo_debug_backtrace) |
ZEND_FE(debug_print_backtrace, arginfo_debug_backtrace) | ZEND_FE(debug_print_backtrace, arginfo_debug_print_backtrace) |
#if ZEND_DEBUG |
#if ZEND_DEBUG |
ZEND_FE(zend_test_func, NULL) |
ZEND_FE(zend_test_func, NULL) |
#ifdef ZTS |
#ifdef ZTS |
Line 682 repeat:
|
Line 706 repeat:
|
zval_ptr_dtor(&val_free); |
zval_ptr_dtor(&val_free); |
} |
} |
c.flags = case_sensitive; /* non persistent */ |
c.flags = case_sensitive; /* non persistent */ |
c.name = zend_strndup(name, name_len); | c.name = IS_INTERNED(name) ? name : zend_strndup(name, name_len); |
| if(c.name == NULL) { |
| RETURN_FALSE; |
| } |
c.name_len = name_len+1; |
c.name_len = name_len+1; |
c.module_number = PHP_USER_CONSTANT; |
c.module_number = PHP_USER_CONSTANT; |
if (zend_register_constant(&c TSRMLS_CC) == SUCCESS) { |
if (zend_register_constant(&c TSRMLS_CC) == SUCCESS) { |
Line 721 ZEND_FUNCTION(defined)
|
Line 748 ZEND_FUNCTION(defined)
|
ZEND_FUNCTION(get_class) |
ZEND_FUNCTION(get_class) |
{ |
{ |
zval *obj = NULL; |
zval *obj = NULL; |
char *name = ""; | const char *name = ""; |
zend_uint name_len = 0; |
zend_uint name_len = 0; |
int dup; |
int dup; |
|
|
Line 769 ZEND_FUNCTION(get_parent_class)
|
Line 796 ZEND_FUNCTION(get_parent_class)
|
{ |
{ |
zval *arg; |
zval *arg; |
zend_class_entry *ce = NULL; |
zend_class_entry *ce = NULL; |
char *name; | const char *name; |
zend_uint name_length; |
zend_uint name_length; |
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &arg) == FAILURE) { |
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &arg) == FAILURE) { |
Line 823 static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, ze
|
Line 850 static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, ze
|
return; |
return; |
} |
} |
/* |
/* |
allow_string - is_a default is no, is_subclass_of is yes. | * allow_string - is_a default is no, is_subclass_of is yes. |
if it's allowed, then the autoloader will be called if the class does not exist. | * if it's allowed, then the autoloader will be called if the class does not exist. |
default behaviour is different, as 'is_a' usage is normally to test mixed return values | * default behaviour is different, as 'is_a' used to be used to test mixed return values |
*/ | * and there is no easy way to deprecate this. |
| */ |
|
|
if (allow_string && Z_TYPE_P(obj) == IS_STRING) { |
if (allow_string && Z_TYPE_P(obj) == IS_STRING) { |
zend_class_entry **the_ce; |
zend_class_entry **the_ce; |
Line 840 static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, ze
|
Line 868 static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, ze
|
RETURN_FALSE; |
RETURN_FALSE; |
} |
} |
|
|
if (zend_lookup_class_ex(class_name, class_name_len, 0, &ce TSRMLS_CC) == FAILURE) { | if (zend_lookup_class_ex(class_name, class_name_len, NULL, 0, &ce TSRMLS_CC) == FAILURE) { |
retval = 0; |
retval = 0; |
} else { |
} else { |
if (only_subclass && instance_ce == *ce) { |
if (only_subclass && instance_ce == *ce) { |
retval = 0; |
retval = 0; |
} else { | } else { |
retval = instanceof_function(instance_ce, *ce TSRMLS_CC); |
retval = instanceof_function(instance_ce, *ce TSRMLS_CC); |
} |
} |
} |
} |
Line 873 ZEND_FUNCTION(is_a)
|
Line 901 ZEND_FUNCTION(is_a)
|
|
|
|
|
/* {{{ add_class_vars */ |
/* {{{ add_class_vars */ |
static void add_class_vars(zend_class_entry *ce, HashTable *properties, zval *return_value TSRMLS_DC) | static void add_class_vars(zend_class_entry *ce, int statics, zval *return_value TSRMLS_DC) |
{ |
{ |
if (zend_hash_num_elements(properties) > 0) { | HashPosition pos; |
HashPosition pos; | zend_property_info *prop_info; |
zval **prop; | zval *prop, *prop_copy; |
| char *key; |
| uint key_len; |
| ulong num_index; |
|
|
zend_hash_internal_pointer_reset_ex(properties, &pos); | zend_hash_internal_pointer_reset_ex(&ce->properties_info, &pos); |
while (zend_hash_get_current_data_ex(properties, (void **) &prop, &pos) == SUCCESS) { | while (zend_hash_get_current_data_ex(&ce->properties_info, (void **) &prop_info, &pos) == SUCCESS) { |
char *key, *class_name, *prop_name; | zend_hash_get_current_key_ex(&ce->properties_info, &key, &key_len, &num_index, 0, &pos); |
uint key_len; | zend_hash_move_forward_ex(&ce->properties_info, &pos); |
ulong num_index; | if (((prop_info->flags & ZEND_ACC_SHADOW) && |
int prop_name_len = 0; | prop_info->ce != EG(scope)) || |
zval *prop_copy; | ((prop_info->flags & ZEND_ACC_PROTECTED) && |
zend_property_info *property_info; | !zend_check_protected(prop_info->ce, EG(scope))) || |
zval zprop_name; | ((prop_info->flags & ZEND_ACC_PRIVATE) && |
| ce != EG(scope) && |
| prop_info->ce != EG(scope))) { |
| continue; |
| } |
| prop = NULL; |
| if (prop_info->offset >= 0) { |
| if (statics && (prop_info->flags & ZEND_ACC_STATIC) != 0) { |
| prop = ce->default_static_members_table[prop_info->offset]; |
| } else if (!statics && (prop_info->flags & ZEND_ACC_STATIC) == 0) { |
| prop = ce->default_properties_table[prop_info->offset]; |
| } |
| } |
| if (!prop) { |
| continue; |
| } |
|
|
zend_hash_get_current_key_ex(properties, &key, &key_len, &num_index, 0, &pos); | /* copy: enforce read only access */ |
zend_hash_move_forward_ex(properties, &pos); | ALLOC_ZVAL(prop_copy); |
| *prop_copy = *prop; |
| zval_copy_ctor(prop_copy); |
| INIT_PZVAL(prop_copy); |
|
|
zend_unmangle_property_name(key, key_len-1, &class_name, &prop_name); | /* this is necessary to make it able to work with default array |
prop_name_len = strlen(prop_name); | * properties, returned to user */ |
| if (Z_TYPE_P(prop_copy) == IS_CONSTANT_ARRAY || (Z_TYPE_P(prop_copy) & IS_CONSTANT_TYPE_MASK) == IS_CONSTANT) { |
ZVAL_STRINGL(&zprop_name, prop_name, prop_name_len, 0); | zval_update_constant(&prop_copy, 0 TSRMLS_CC); |
property_info = zend_get_property_info(ce, &zprop_name, 1 TSRMLS_CC); | |
| |
if (!property_info || property_info == &EG(std_property_info)) { | |
continue; | |
} | |
| |
/* copy: enforce read only access */ | |
ALLOC_ZVAL(prop_copy); | |
*prop_copy = **prop; | |
zval_copy_ctor(prop_copy); | |
INIT_PZVAL(prop_copy); | |
| |
/* this is necessary to make it able to work with default array | |
* properties, returned to user */ | |
if (Z_TYPE_P(prop_copy) == IS_CONSTANT_ARRAY || (Z_TYPE_P(prop_copy) & IS_CONSTANT_TYPE_MASK) == IS_CONSTANT) { | |
zval_update_constant(&prop_copy, 0 TSRMLS_CC); | |
} | |
| |
add_assoc_zval(return_value, prop_name, prop_copy); | |
} |
} |
|
|
|
add_assoc_zval(return_value, key, prop_copy); |
} |
} |
} |
} |
/* }}} */ |
/* }}} */ |
Line 938 ZEND_FUNCTION(get_class_vars)
|
Line 970 ZEND_FUNCTION(get_class_vars)
|
} else { |
} else { |
array_init(return_value); |
array_init(return_value); |
zend_update_class_constants(*pce TSRMLS_CC); |
zend_update_class_constants(*pce TSRMLS_CC); |
add_class_vars(*pce, &(*pce)->default_properties, return_value TSRMLS_CC); | add_class_vars(*pce, 0, return_value TSRMLS_CC); |
add_class_vars(*pce, CE_STATIC_MEMBERS(*pce), return_value TSRMLS_CC); | add_class_vars(*pce, 1, return_value TSRMLS_CC); |
} |
} |
} |
} |
/* }}} */ |
/* }}} */ |
Line 953 ZEND_FUNCTION(get_object_vars)
|
Line 985 ZEND_FUNCTION(get_object_vars)
|
zval **value; |
zval **value; |
HashTable *properties; |
HashTable *properties; |
HashPosition pos; |
HashPosition pos; |
char *key, *prop_name, *class_name; | char *key; |
| const char *prop_name, *class_name; |
uint key_len; |
uint key_len; |
ulong num_index; |
ulong num_index; |
zend_object *zobj; |
zend_object *zobj; |
Line 1088 ZEND_FUNCTION(method_exists)
|
Line 1121 ZEND_FUNCTION(method_exists)
|
|
|
if (Z_TYPE_P(klass) == IS_OBJECT |
if (Z_TYPE_P(klass) == IS_OBJECT |
&& Z_OBJ_HT_P(klass)->get_method != NULL |
&& Z_OBJ_HT_P(klass)->get_method != NULL |
&& (func = Z_OBJ_HT_P(klass)->get_method(&klass, method_name, method_len TSRMLS_CC)) != NULL | && (func = Z_OBJ_HT_P(klass)->get_method(&klass, method_name, method_len, NULL TSRMLS_CC)) != NULL |
) { |
) { |
if (func->type == ZEND_INTERNAL_FUNCTION |
if (func->type == ZEND_INTERNAL_FUNCTION |
&& (func->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0 |
&& (func->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0 |
Line 1097 ZEND_FUNCTION(method_exists)
|
Line 1130 ZEND_FUNCTION(method_exists)
|
RETVAL_BOOL((func->common.scope == zend_ce_closure |
RETVAL_BOOL((func->common.scope == zend_ce_closure |
&& (method_len == sizeof(ZEND_INVOKE_FUNC_NAME)-1) |
&& (method_len == sizeof(ZEND_INVOKE_FUNC_NAME)-1) |
&& memcmp(lcname, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0) ? 1 : 0); |
&& memcmp(lcname, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0) ? 1 : 0); |
| |
efree(lcname); |
efree(lcname); |
efree(((zend_internal_function*)func)->function_name); | efree((char*)((zend_internal_function*)func)->function_name); |
efree(func); |
efree(func); |
return; |
return; |
} |
} |
Line 1154 ZEND_FUNCTION(property_exists)
|
Line 1187 ZEND_FUNCTION(property_exists)
|
|
|
if (Z_TYPE_P(object) == IS_OBJECT && |
if (Z_TYPE_P(object) == IS_OBJECT && |
Z_OBJ_HANDLER_P(object, has_property) && |
Z_OBJ_HANDLER_P(object, has_property) && |
Z_OBJ_HANDLER_P(object, has_property)(object, &property_z, 2 TSRMLS_CC)) { | Z_OBJ_HANDLER_P(object, has_property)(object, &property_z, 2, 0 TSRMLS_CC)) { |
RETURN_TRUE; |
RETURN_TRUE; |
} |
} |
RETURN_FALSE; |
RETURN_FALSE; |
Line 1194 ZEND_FUNCTION(class_exists)
|
Line 1227 ZEND_FUNCTION(class_exists)
|
|
|
found = zend_hash_find(EG(class_table), name, len+1, (void **) &ce); |
found = zend_hash_find(EG(class_table), name, len+1, (void **) &ce); |
free_alloca(lc_name, use_heap); |
free_alloca(lc_name, use_heap); |
RETURN_BOOL(found == SUCCESS && !((*ce)->ce_flags & ZEND_ACC_INTERFACE)); | RETURN_BOOL(found == SUCCESS && !(((*ce)->ce_flags & (ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT)) > ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)); |
} |
} |
|
|
if (zend_lookup_class(class_name, class_name_len, &ce TSRMLS_CC) == SUCCESS) { |
if (zend_lookup_class(class_name, class_name_len, &ce TSRMLS_CC) == SUCCESS) { |
RETURN_BOOL(((*ce)->ce_flags & ZEND_ACC_INTERFACE) == 0); | RETURN_BOOL(((*ce)->ce_flags & (ZEND_ACC_INTERFACE | (ZEND_ACC_TRAIT - ZEND_ACC_EXPLICIT_ABSTRACT_CLASS))) == 0); |
} else { |
} else { |
RETURN_FALSE; |
RETURN_FALSE; |
} |
} |
Line 1248 ZEND_FUNCTION(interface_exists)
|
Line 1281 ZEND_FUNCTION(interface_exists)
|
} |
} |
/* }}} */ |
/* }}} */ |
|
|
|
/* {{{ proto bool trait_exists(string traitname [, bool autoload]) |
|
Checks if the trait exists */ |
|
ZEND_FUNCTION(trait_exists) |
|
{ |
|
char *trait_name, *lc_name; |
|
zend_class_entry **ce; |
|
int trait_name_len; |
|
int found; |
|
zend_bool autoload = 1; |
|
ALLOCA_FLAG(use_heap) |
|
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &trait_name, &trait_name_len, &autoload) == FAILURE) { |
|
return; |
|
} |
|
|
|
if (!autoload) { |
|
char *name; |
|
int len; |
|
|
|
lc_name = do_alloca(trait_name_len + 1, use_heap); |
|
zend_str_tolower_copy(lc_name, trait_name, trait_name_len); |
|
|
|
/* Ignore leading "\" */ |
|
name = lc_name; |
|
len = trait_name_len; |
|
if (lc_name[0] == '\\') { |
|
name = &lc_name[1]; |
|
len--; |
|
} |
|
|
|
found = zend_hash_find(EG(class_table), name, len+1, (void **) &ce); |
|
free_alloca(lc_name, use_heap); |
|
RETURN_BOOL(found == SUCCESS && (((*ce)->ce_flags & ZEND_ACC_TRAIT) > ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)); |
|
} |
|
|
|
if (zend_lookup_class(trait_name, trait_name_len, &ce TSRMLS_CC) == SUCCESS) { |
|
RETURN_BOOL(((*ce)->ce_flags & ZEND_ACC_TRAIT) > ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); |
|
} else { |
|
RETURN_FALSE; |
|
} |
|
} |
|
/* }}} */ |
|
|
|
|
/* {{{ proto bool function_exists(string function_name) |
/* {{{ proto bool function_exists(string function_name) |
Checks if the function exists */ |
Checks if the function exists */ |
ZEND_FUNCTION(function_exists) |
ZEND_FUNCTION(function_exists) |
Line 1347 ZEND_FUNCTION(leak)
|
Line 1423 ZEND_FUNCTION(leak)
|
} |
} |
/* }}} */ |
/* }}} */ |
|
|
|
/* {{{ proto leak_variable(mixed variable [, bool leak_data]) */ |
|
ZEND_FUNCTION(leak_variable) |
|
{ |
|
zval *zv; |
|
zend_bool leak_data = 0; |
|
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|b", &zv, &leak_data) == FAILURE) { |
|
return; |
|
} |
|
|
|
if (!leak_data) { |
|
zval_add_ref(&zv); |
|
} else if (Z_TYPE_P(zv) == IS_RESOURCE) { |
|
zend_list_addref(Z_RESVAL_P(zv)); |
|
} else if (Z_TYPE_P(zv) == IS_OBJECT) { |
|
Z_OBJ_HANDLER_P(zv, add_ref)(zv TSRMLS_CC); |
|
} else { |
|
zend_error(E_WARNING, "Leaking non-zval data is only applicable to resources and objects"); |
|
} |
|
} |
|
/* }}} */ |
|
|
|
|
#ifdef ZEND_TEST_EXCEPTIONS |
#ifdef ZEND_TEST_EXCEPTIONS |
ZEND_FUNCTION(crash) |
ZEND_FUNCTION(crash) |
{ |
{ |
Line 1364 ZEND_FUNCTION(crash)
|
Line 1462 ZEND_FUNCTION(crash)
|
ZEND_FUNCTION(get_included_files) |
ZEND_FUNCTION(get_included_files) |
{ |
{ |
char *entry; |
char *entry; |
|
|
if (zend_parse_parameters_none() == FAILURE) { |
if (zend_parse_parameters_none() == FAILURE) { |
return; |
return; |
} |
} |
Line 1415 ZEND_FUNCTION(set_error_handler)
|
Line 1514 ZEND_FUNCTION(set_error_handler)
|
zval *error_handler; |
zval *error_handler; |
zend_bool had_orig_error_handler=0; |
zend_bool had_orig_error_handler=0; |
char *error_handler_name = NULL; |
char *error_handler_name = NULL; |
long error_type = E_ALL | E_STRICT; | long error_type = E_ALL; |
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &error_handler, &error_type) == FAILURE) { |
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &error_handler, &error_type) == FAILURE) { |
return; |
return; |
Line 1516 ZEND_FUNCTION(set_exception_handler)
|
Line 1615 ZEND_FUNCTION(set_exception_handler)
|
RETURN_TRUE; |
RETURN_TRUE; |
} |
} |
|
|
*EG(user_exception_handler) = *exception_handler; | MAKE_COPY_ZVAL(&exception_handler, EG(user_exception_handler)) |
zval_copy_ctor(EG(user_exception_handler)); | |
|
|
if (!had_orig_exception_handler) { |
if (!had_orig_exception_handler) { |
RETURN_NULL(); |
RETURN_NULL(); |
Line 1558 static int copy_class_or_interface_name(zend_class_ent
|
Line 1656 static int copy_class_or_interface_name(zend_class_ent
|
return ZEND_HASH_APPLY_KEEP; |
return ZEND_HASH_APPLY_KEEP; |
} |
} |
|
|
|
/* {{{ proto array get_declared_traits() |
|
Returns an array of all declared traits. */ |
|
ZEND_FUNCTION(get_declared_traits) |
|
{ |
|
zend_uint mask = ZEND_ACC_TRAIT; |
|
zend_uint comply = 1; |
|
|
|
if (zend_parse_parameters_none() == FAILURE) { |
|
return; |
|
} |
|
|
|
array_init(return_value); |
|
zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t) copy_class_or_interface_name, 3, return_value, mask, comply); |
|
} |
|
/* }}} */ |
|
|
|
|
/* {{{ proto array get_declared_classes() |
/* {{{ proto array get_declared_classes() |
Returns an array of all declared classes. */ |
Returns an array of all declared classes. */ |
ZEND_FUNCTION(get_declared_classes) |
ZEND_FUNCTION(get_declared_classes) |
{ |
{ |
zend_uint mask = ZEND_ACC_INTERFACE; | zend_uint mask = ZEND_ACC_INTERFACE | (ZEND_ACC_TRAIT & ~ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); |
zend_uint comply = 0; |
zend_uint comply = 0; |
|
|
if (zend_parse_parameters_none() == FAILURE) { |
if (zend_parse_parameters_none() == FAILURE) { |
Line 1752 ZEND_FUNCTION(zend_thread_id)
|
Line 1866 ZEND_FUNCTION(zend_thread_id)
|
Get the resource type name for a given resource */ |
Get the resource type name for a given resource */ |
ZEND_FUNCTION(get_resource_type) |
ZEND_FUNCTION(get_resource_type) |
{ |
{ |
char *resource_type; | const char *resource_type; |
zval *z_resource_type; |
zval *z_resource_type; |
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &z_resource_type) == FAILURE) { |
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &z_resource_type) == FAILURE) { |
Line 1930 void debug_print_backtrace_args(zval *arg_array TSRMLS
|
Line 2044 void debug_print_backtrace_args(zval *arg_array TSRMLS
|
} |
} |
} |
} |
|
|
/* {{{ proto void debug_print_backtrace([int options]) */ | /* {{{ proto void debug_print_backtrace([int options[, int limit]]) */ |
ZEND_FUNCTION(debug_print_backtrace) |
ZEND_FUNCTION(debug_print_backtrace) |
{ |
{ |
zend_execute_data *ptr, *skip; |
zend_execute_data *ptr, *skip; |
int lineno; | int lineno, frameno = 0; |
char *function_name; | const char *function_name; |
char *filename; | const char *filename; |
char *class_name = NULL; | const char *class_name = NULL; |
char *call_type; |
char *call_type; |
char *include_filename = NULL; | const char *include_filename = NULL; |
zval *arg_array = NULL; |
zval *arg_array = NULL; |
int indent = 0; |
int indent = 0; |
long options = 0; |
long options = 0; |
|
long limit = 0; |
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &options) == FAILURE) { | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ll", &options, &limit) == FAILURE) { |
return; |
return; |
} |
} |
|
|
Line 1953 ZEND_FUNCTION(debug_print_backtrace)
|
Line 2068 ZEND_FUNCTION(debug_print_backtrace)
|
/* skip debug_backtrace() */ |
/* skip debug_backtrace() */ |
ptr = ptr->prev_execute_data; |
ptr = ptr->prev_execute_data; |
|
|
while (ptr) { | while (ptr && (limit == 0 || frameno < limit)) { |
char *free_class_name = NULL; | const char *free_class_name = NULL; |
|
|
|
frameno++; |
class_name = call_type = NULL; |
class_name = call_type = NULL; |
arg_array = NULL; |
arg_array = NULL; |
|
|
Line 2016 ZEND_FUNCTION(debug_print_backtrace)
|
Line 2132 ZEND_FUNCTION(debug_print_backtrace)
|
function_name = "unknown"; |
function_name = "unknown"; |
build_filename_arg = 0; |
build_filename_arg = 0; |
} else |
} else |
switch (Z_LVAL(ptr->opline->op2.u.constant)) { | switch (ptr->opline->extended_value) { |
case ZEND_EVAL: |
case ZEND_EVAL: |
function_name = "eval"; |
function_name = "eval"; |
build_filename_arg = 0; |
build_filename_arg = 0; |
Line 2044 ZEND_FUNCTION(debug_print_backtrace)
|
Line 2160 ZEND_FUNCTION(debug_print_backtrace)
|
if (build_filename_arg && include_filename) { |
if (build_filename_arg && include_filename) { |
MAKE_STD_ZVAL(arg_array); |
MAKE_STD_ZVAL(arg_array); |
array_init(arg_array); |
array_init(arg_array); |
add_next_index_string(arg_array, include_filename, 1); | add_next_index_string(arg_array, (char*)include_filename, 1); |
} |
} |
call_type = NULL; |
call_type = NULL; |
} |
} |
Line 2083 ZEND_FUNCTION(debug_print_backtrace)
|
Line 2199 ZEND_FUNCTION(debug_print_backtrace)
|
ptr = skip->prev_execute_data; |
ptr = skip->prev_execute_data; |
++indent; |
++indent; |
if (free_class_name) { |
if (free_class_name) { |
efree(free_class_name); | efree((char*)free_class_name); |
} |
} |
} |
} |
} |
} |
|
|
/* }}} */ |
/* }}} */ |
|
|
ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int options TSRMLS_DC) | ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int options, int limit TSRMLS_DC) |
{ |
{ |
zend_execute_data *ptr, *skip; |
zend_execute_data *ptr, *skip; |
int lineno; | int lineno, frameno = 0; |
char *function_name; | const char *function_name; |
char *filename; | const char *filename; |
char *class_name; | const char *class_name; |
char *include_filename = NULL; | const char *include_filename = NULL; |
zval *stack_frame; |
zval *stack_frame; |
|
|
ptr = EG(current_execute_data); |
ptr = EG(current_execute_data); |
Line 2114 ZEND_API void zend_fetch_debug_backtrace(zval *return_
|
Line 2230 ZEND_API void zend_fetch_debug_backtrace(zval *return_
|
|
|
array_init(return_value); |
array_init(return_value); |
|
|
while (ptr) { | while (ptr && (limit == 0 || frameno < limit)) { |
| frameno++; |
MAKE_STD_ZVAL(stack_frame); |
MAKE_STD_ZVAL(stack_frame); |
array_init(stack_frame); |
array_init(stack_frame); |
|
|
Line 2132 ZEND_API void zend_fetch_debug_backtrace(zval *return_
|
Line 2249 ZEND_API void zend_fetch_debug_backtrace(zval *return_
|
if (skip->op_array) { |
if (skip->op_array) { |
filename = skip->op_array->filename; |
filename = skip->op_array->filename; |
lineno = skip->opline->lineno; |
lineno = skip->opline->lineno; |
add_assoc_string_ex(stack_frame, "file", sizeof("file"), filename, 1); | add_assoc_string_ex(stack_frame, "file", sizeof("file"), (char*)filename, 1); |
add_assoc_long_ex(stack_frame, "line", sizeof("line"), lineno); |
add_assoc_long_ex(stack_frame, "line", sizeof("line"), lineno); |
|
|
/* try to fetch args only if an FCALL was just made - elsewise we're in the middle of a function |
/* try to fetch args only if an FCALL was just made - elsewise we're in the middle of a function |
Line 2149 ZEND_API void zend_fetch_debug_backtrace(zval *return_
|
Line 2266 ZEND_API void zend_fetch_debug_backtrace(zval *return_
|
break; |
break; |
} |
} |
if (prev->op_array) { |
if (prev->op_array) { |
add_assoc_string_ex(stack_frame, "file", sizeof("file"), prev->op_array->filename, 1); | add_assoc_string_ex(stack_frame, "file", sizeof("file"), (char*)prev->op_array->filename, 1); |
add_assoc_long_ex(stack_frame, "line", sizeof("line"), prev->opline->lineno); |
add_assoc_long_ex(stack_frame, "line", sizeof("line"), prev->opline->lineno); |
break; |
break; |
} |
} |
Line 2161 ZEND_API void zend_fetch_debug_backtrace(zval *return_
|
Line 2278 ZEND_API void zend_fetch_debug_backtrace(zval *return_
|
function_name = ptr->function_state.function->common.function_name; |
function_name = ptr->function_state.function->common.function_name; |
|
|
if (function_name) { |
if (function_name) { |
add_assoc_string_ex(stack_frame, "function", sizeof("function"), function_name, 1); | add_assoc_string_ex(stack_frame, "function", sizeof("function"), (char*)function_name, 1); |
|
|
if (ptr->object && Z_TYPE_P(ptr->object) == IS_OBJECT) { |
if (ptr->object && Z_TYPE_P(ptr->object) == IS_OBJECT) { |
if (ptr->function_state.function->common.scope) { |
if (ptr->function_state.function->common.scope) { |
add_assoc_string_ex(stack_frame, "class", sizeof("class"), ptr->function_state.function->common.scope->name, 1); | add_assoc_string_ex(stack_frame, "class", sizeof("class"), (char*)ptr->function_state.function->common.scope->name, 1); |
} else { |
} else { |
zend_uint class_name_len; |
zend_uint class_name_len; |
int dup; |
int dup; |
|
|
dup = zend_get_object_classname(ptr->object, &class_name, &class_name_len TSRMLS_CC); |
dup = zend_get_object_classname(ptr->object, &class_name, &class_name_len TSRMLS_CC); |
add_assoc_string_ex(stack_frame, "class", sizeof("class"), class_name, dup); | add_assoc_string_ex(stack_frame, "class", sizeof("class"), (char*)class_name, dup); |
|
|
} |
} |
if ((options & DEBUG_BACKTRACE_PROVIDE_OBJECT) != 0) { |
if ((options & DEBUG_BACKTRACE_PROVIDE_OBJECT) != 0) { |
Line 2181 ZEND_API void zend_fetch_debug_backtrace(zval *return_
|
Line 2298 ZEND_API void zend_fetch_debug_backtrace(zval *return_
|
|
|
add_assoc_string_ex(stack_frame, "type", sizeof("type"), "->", 1); |
add_assoc_string_ex(stack_frame, "type", sizeof("type"), "->", 1); |
} else if (ptr->function_state.function->common.scope) { |
} else if (ptr->function_state.function->common.scope) { |
add_assoc_string_ex(stack_frame, "class", sizeof("class"), ptr->function_state.function->common.scope->name, 1); | add_assoc_string_ex(stack_frame, "class", sizeof("class"), (char*)ptr->function_state.function->common.scope->name, 1); |
add_assoc_string_ex(stack_frame, "type", sizeof("type"), "::", 1); |
add_assoc_string_ex(stack_frame, "type", sizeof("type"), "::", 1); |
} |
} |
|
|
Line 2200 ZEND_API void zend_fetch_debug_backtrace(zval *return_
|
Line 2317 ZEND_API void zend_fetch_debug_backtrace(zval *return_
|
function_name = "unknown"; |
function_name = "unknown"; |
build_filename_arg = 0; |
build_filename_arg = 0; |
} else |
} else |
switch (ptr->opline->op2.u.constant.value.lval) { | switch (ptr->opline->extended_value) { |
case ZEND_EVAL: |
case ZEND_EVAL: |
function_name = "eval"; |
function_name = "eval"; |
build_filename_arg = 0; |
build_filename_arg = 0; |
Line 2235 ZEND_API void zend_fetch_debug_backtrace(zval *return_
|
Line 2352 ZEND_API void zend_fetch_debug_backtrace(zval *return_
|
if we have called include in the frame above - this is the file we have included. |
if we have called include in the frame above - this is the file we have included. |
*/ |
*/ |
|
|
add_next_index_string(arg_array, include_filename, 1); | add_next_index_string(arg_array, (char*)include_filename, 1); |
add_assoc_zval_ex(stack_frame, "args", sizeof("args"), arg_array); |
add_assoc_zval_ex(stack_frame, "args", sizeof("args"), arg_array); |
} |
} |
|
|
add_assoc_string_ex(stack_frame, "function", sizeof("function"), function_name, 1); | add_assoc_string_ex(stack_frame, "function", sizeof("function"), (char*)function_name, 1); |
} |
} |
|
|
add_next_index_zval(return_value, stack_frame); |
add_next_index_zval(return_value, stack_frame); |
Line 2252 ZEND_API void zend_fetch_debug_backtrace(zval *return_
|
Line 2369 ZEND_API void zend_fetch_debug_backtrace(zval *return_
|
/* }}} */ |
/* }}} */ |
|
|
|
|
/* {{{ proto array debug_backtrace([int options]) | /* {{{ proto array debug_backtrace([int options[, int limit]]) |
Return backtrace as array */ |
Return backtrace as array */ |
ZEND_FUNCTION(debug_backtrace) |
ZEND_FUNCTION(debug_backtrace) |
{ |
{ |
long options = DEBUG_BACKTRACE_PROVIDE_OBJECT; |
long options = DEBUG_BACKTRACE_PROVIDE_OBJECT; |
|
long limit = 0; |
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &options) == FAILURE) { | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ll", &options, &limit) == FAILURE) { |
return; |
return; |
} |
} |
|
|
zend_fetch_debug_backtrace(return_value, 1, options TSRMLS_CC); | zend_fetch_debug_backtrace(return_value, 1, options, limit TSRMLS_CC); |
} |
} |
/* }}} */ |
/* }}} */ |
|
|