Fixed bug #45742 (Wrong class array inpretetion using constant indexes)

This commit is contained in:
Dmitry Stogov 2008-08-07 11:45:00 +00:00
parent a51e5ebaeb
commit a3d8718b9a
2 changed files with 44 additions and 4 deletions

24
Zend/tests/bug45742.phpt Normal file
View File

@ -0,0 +1,24 @@
--TEST--
Bug #45742 Wrong class array inpretetion using constant indexes
--FILE--
<?php
class Constants {
// Needs to be equal
const A = 1;
const B = 1;
}
class ArrayProperty {
public static $array = array(
Constants::A => 23,
Constants::B => 42,
);
}
var_dump( ArrayProperty::$array );
?>
--EXPECT--
array(1) {
[1]=>
int(23)
}

View File

@ -1674,14 +1674,22 @@ ZEND_API int zend_hash_update_current_key_ex(HashTable *ht, int key_type, zstr s
if (mode & HASH_UPDATE_KEY_IF_BEFORE) {
break;
} else {
zend_hash_index_del(ht, p->h);
if (p->nKeyLength) {
zend_u_hash_del(ht, p->key.type, ZSTR(p->key.arKey.s), p->nKeyLength);
} else {
zend_hash_index_del(ht, p->h);
}
return FAILURE;
}
} else {
if (mode & HASH_UPDATE_KEY_IF_AFTER) {
break;
} else {
zend_hash_index_del(ht, p->h);
if (p->nKeyLength) {
zend_u_hash_del(ht, p->key.type, ZSTR(p->key.arKey.s), p->nKeyLength);
} else {
zend_hash_index_del(ht, p->h);
}
return FAILURE;
}
}
@ -1715,14 +1723,22 @@ ZEND_API int zend_hash_update_current_key_ex(HashTable *ht, int key_type, zstr s
if (mode & HASH_UPDATE_KEY_IF_BEFORE) {
break;
} else {
zend_u_hash_del(ht, p->key.type, ZSTR(p->key.arKey.s), p->nKeyLength);
if (p->nKeyLength) {
zend_u_hash_del(ht, p->key.type, ZSTR(p->key.arKey.s), p->nKeyLength);
} else {
zend_hash_index_del(ht, p->h);
}
return FAILURE;
}
} else {
if (mode & HASH_UPDATE_KEY_IF_AFTER) {
break;
} else {
zend_u_hash_del(ht, p->key.type, ZSTR(p->key.arKey.s), p->nKeyLength);
if (p->nKeyLength) {
zend_u_hash_del(ht, p->key.type, ZSTR(p->key.arKey.s), p->nKeyLength);
} else {
zend_hash_index_del(ht, p->h);
}
return FAILURE;
}
}