Browse Source

- Fixed var_export() to show public, protected and private modifiers properly.

- Exported (un)mangle_property_name.
PEAR_1_4DEV
Derick Rethans 23 years ago
parent
commit
6923a16c26
  1. 2
      NEWS
  2. 2
      Zend/zend.c
  3. 6
      Zend/zend_API.c
  4. 6
      Zend/zend_compile.c
  5. 4
      Zend/zend_compile.h
  6. 2
      Zend/zend_execute.c
  7. 2
      Zend/zend_object_handlers.c
  8. 6
      Zend/zend_reflection_api.c
  9. 6
      ext/reflection/php_reflection.c
  10. 2
      ext/standard/basic_functions.c
  11. 14
      ext/standard/var.c

2
NEWS

@ -1,6 +1,8 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2004, PHP 5 RC1
- Fixed var_export() to show public, protected and private modifiers properly.
(Derick)
- Fixed problems with longlong values in mysqli. (Georg)
- Fixed class name case preserving of user defined classes. (Marcus)
- Fixed bug #26762 (unserialize() produces lowercase classnames). (Marcus)

2
Zend/zend.c

@ -138,7 +138,7 @@ static void print_hash(HashTable *ht, int indent, zend_bool is_object TSRMLS_DC)
if (is_object) {
char *prop_name, *class_name;
unmangle_property_name(string_key, &class_name, &prop_name);
zend_unmangle_property_name(string_key, &class_name, &prop_name);
ZEND_PUTS(prop_name);
if (class_name) {
if (class_name[0]=='*') {

6
Zend/zend_API.c

@ -1763,7 +1763,7 @@ ZEND_API int zend_declare_property(zend_class_entry *ce, char *name, int name_le
char *priv_name;
int priv_name_length;
mangle_property_name(&priv_name, &priv_name_length, ce->name, ce->name_length, name, name_length, ce->type & ZEND_INTERNAL_CLASS);
zend_mangle_property_name(&priv_name, &priv_name_length, ce->name, ce->name_length, name, name_length, ce->type & ZEND_INTERNAL_CLASS);
zend_hash_update(target_symbol_table, priv_name, priv_name_length+1, &property, sizeof(zval *), NULL);
property_info.name = priv_name;
property_info.name_length = priv_name_length;
@ -1773,7 +1773,7 @@ ZEND_API int zend_declare_property(zend_class_entry *ce, char *name, int name_le
char *prot_name;
int prot_name_length;
mangle_property_name(&prot_name, &prot_name_length, "*", 1, name, name_length, ce->type & ZEND_INTERNAL_CLASS);
zend_mangle_property_name(&prot_name, &prot_name_length, "*", 1, name, name_length, ce->type & ZEND_INTERNAL_CLASS);
zend_hash_update(target_symbol_table, prot_name, prot_name_length+1, &property, sizeof(zval *), NULL);
property_info.name = prot_name;
property_info.name_length = prot_name_length;
@ -1784,7 +1784,7 @@ ZEND_API int zend_declare_property(zend_class_entry *ce, char *name, int name_le
char *prot_name;
int prot_name_length;
mangle_property_name(&prot_name, &prot_name_length, "*", 1, name, name_length, ce->type & ZEND_INTERNAL_CLASS);
zend_mangle_property_name(&prot_name, &prot_name_length, "*", 1, name, name_length, ce->type & ZEND_INTERNAL_CLASS);
zend_hash_del(target_symbol_table, prot_name, prot_name_length+1);
pefree(prot_name, ce->type & ZEND_INTERNAL_CLASS);
}

6
Zend/zend_compile.c

@ -1814,7 +1814,7 @@ static zend_bool do_inherit_property_access_check(HashTable *target_ht, zend_pro
char *prot_name;
int prot_name_length;
mangle_property_name(&prot_name, &prot_name_length, "*", 1, child_info->name, child_info->name_length, ce->type & ZEND_INTERNAL_CLASS);
zend_mangle_property_name(&prot_name, &prot_name_length, "*", 1, child_info->name, child_info->name_length, ce->type & ZEND_INTERNAL_CLASS);
if (child_info->flags & ZEND_ACC_STATIC) {
zval **prop;
if (zend_hash_find(parent_ce->static_members, prot_name, prot_name_length+1, (void**)&prop) == SUCCESS) {
@ -2421,7 +2421,7 @@ void zend_do_implements_interface(znode *interface_znode TSRMLS_DC)
}
void mangle_property_name(char **dest, int *dest_length, char *src1, int src1_length, char *src2, int src2_length, int internal)
ZEND_API void zend_mangle_property_name(char **dest, int *dest_length, char *src1, int src1_length, char *src2, int src2_length, int internal)
{
char *prop_name;
int prop_name_length;
@ -2437,7 +2437,7 @@ void mangle_property_name(char **dest, int *dest_length, char *src1, int src1_le
}
void unmangle_property_name(char *mangled_property, char **class_name, char **prop_name)
ZEND_API void zend_unmangle_property_name(char *mangled_property, char **class_name, char **prop_name)
{
*prop_name = *class_name = NULL;

4
Zend/zend_compile.h

@ -465,8 +465,8 @@ ZEND_API void destroy_zend_function(zend_function *function TSRMLS_DC);
ZEND_API void destroy_zend_class(zend_class_entry **pce);
void zend_class_add_ref(zend_class_entry **ce);
void mangle_property_name(char **dest, int *dest_length, char *src1, int src1_length, char *src2, int src2_length, int internal);
void unmangle_property_name(char *mangled_property, char **prop_name, char **class_name);
ZEND_API void zend_mangle_property_name(char **dest, int *dest_length, char *src1, int src1_length, char *src2, int src2_length, int internal);
ZEND_API void zend_unmangle_property_name(char *mangled_property, char **prop_name, char **class_name);
#define ZEND_FUNCTION_DTOR (void (*)(void *)) destroy_zend_function
#define ZEND_CLASS_DTOR (void (*)(void *)) destroy_zend_class

2
Zend/zend_execute.c

@ -3645,7 +3645,7 @@ int zend_fe_fetch_handler(ZEND_OPCODE_HANDLER_ARGS)
zend_hash_move_forward(fe_ht);
} while (zend_check_property_access(zobj, str_key TSRMLS_CC) != SUCCESS);
unmangle_property_name(str_key, &class_name, &prop_name);
zend_unmangle_property_name(str_key, &class_name, &prop_name);
str_key_len = strlen(prop_name);
str_key = estrndup(prop_name, str_key_len);
str_key_len++;

2
Zend/zend_object_handlers.c

@ -248,7 +248,7 @@ ZEND_API int zend_check_property_access(zend_object *zobj, char *prop_info_name
char *class_name, *prop_name;
zval member;
unmangle_property_name(prop_info_name, &class_name, &prop_name);
zend_unmangle_property_name(prop_info_name, &class_name, &prop_name);
ZVAL_STRING(&member, prop_name, 0);
property_info = zend_get_property_info(zobj, &member, 1 TSRMLS_CC);
if (!property_info) {

6
Zend/zend_reflection_api.c

@ -616,7 +616,7 @@ static void _property_string(string *str, zend_property_info *prop, char *prop_n
string_printf(str, "static ");
}
unmangle_property_name(prop->name, &class_name, &prop_name);
zend_unmangle_property_name(prop->name, &class_name, &prop_name);
string_printf(str, "$%s", prop_name);
}
@ -758,7 +758,7 @@ static void reflection_property_factory(zend_class_entry *ce, zend_property_info
property_reference *reference;
char *class_name, *prop_name;
unmangle_property_name(prop->name, &class_name, &prop_name);
zend_unmangle_property_name(prop->name, &class_name, &prop_name);
if (!(prop->flags & ZEND_ACC_PRIVATE)) {
/* we have to seach the class hierarchy for this (implicit) public or protected property */
@ -1866,7 +1866,7 @@ ZEND_METHOD(reflection_class, getDefaultProperties)
zend_hash_get_current_key_ex(&ce->default_properties, &key, &key_len, &num_index, 0, &pos);
zend_hash_move_forward_ex(&ce->default_properties, &pos);
unmangle_property_name(key, &class_name, &prop_name);
zend_unmangle_property_name(key, &class_name, &prop_name);
if (class_name && class_name[0] != '*' && strcmp(class_name, ce->name)) {
/* filter privates from base classes */
continue;

6
ext/reflection/php_reflection.c

@ -616,7 +616,7 @@ static void _property_string(string *str, zend_property_info *prop, char *prop_n
string_printf(str, "static ");
}
unmangle_property_name(prop->name, &class_name, &prop_name);
zend_unmangle_property_name(prop->name, &class_name, &prop_name);
string_printf(str, "$%s", prop_name);
}
@ -758,7 +758,7 @@ static void reflection_property_factory(zend_class_entry *ce, zend_property_info
property_reference *reference;
char *class_name, *prop_name;
unmangle_property_name(prop->name, &class_name, &prop_name);
zend_unmangle_property_name(prop->name, &class_name, &prop_name);
if (!(prop->flags & ZEND_ACC_PRIVATE)) {
/* we have to seach the class hierarchy for this (implicit) public or protected property */
@ -1866,7 +1866,7 @@ ZEND_METHOD(reflection_class, getDefaultProperties)
zend_hash_get_current_key_ex(&ce->default_properties, &key, &key_len, &num_index, 0, &pos);
zend_hash_move_forward_ex(&ce->default_properties, &pos);
unmangle_property_name(key, &class_name, &prop_name);
zend_unmangle_property_name(key, &class_name, &prop_name);
if (class_name && class_name[0] != '*' && strcmp(class_name, ce->name)) {
/* filter privates from base classes */
continue;

2
ext/standard/basic_functions.c

@ -2564,7 +2564,7 @@ PHP_FUNCTION(print_r)
php_start_ob_buffer (NULL, 0, 1 TSRMLS_CC);
}
zend_print_pval_r(var, 0 TSRMLS_CC);
zend_print_zval_r(var, 0 TSRMLS_CC);
if (i) {
php_ob_get_buffer (return_value TSRMLS_CC);

14
ext/standard/var.c

@ -310,12 +310,24 @@ static int php_array_element_export(zval **zv, int num_args, va_list args, zend_
static int php_object_element_export(zval **zv, int num_args, va_list args, zend_hash_key *hash_key)
{
int level;
char *prop_name, *class_name;
TSRMLS_FETCH();
level = va_arg(args, int);
if (hash_key->nKeyLength != 0) {
php_printf("%*cvar $%s = ", level + 1, ' ', hash_key->arKey);
php_printf("%*c", level + 1, ' ');
zend_unmangle_property_name(hash_key->arKey, &class_name, &prop_name);
if (class_name) {
if (class_name[0] == '*') {
php_printf("protected");
} else {
php_printf("private");
}
} else {
php_printf("public");
}
php_printf(" $%s = ", prop_name);
php_var_export(zv, level + 2 TSRMLS_CC);
PUTS (";\n");
}

Loading…
Cancel
Save