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

This commit is contained in:
Dmitry Stogov 2008-08-07 11:45:35 +00:00
parent 333ae016f0
commit c1e5b1345d
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

@ -1197,14 +1197,22 @@ ZEND_API int zend_hash_update_current_key_ex(HashTable *ht, int key_type, const
if (mode & HASH_UPDATE_KEY_IF_BEFORE) {
break;
} else {
zend_hash_index_del(ht, p->h);
if (p->nKeyLength) {
zend_hash_del(ht, p->arKey, 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_hash_del(ht, p->arKey, p->nKeyLength);
} else {
zend_hash_index_del(ht, p->h);
}
return FAILURE;
}
}
@ -1234,14 +1242,22 @@ ZEND_API int zend_hash_update_current_key_ex(HashTable *ht, int key_type, const
if (mode & HASH_UPDATE_KEY_IF_BEFORE) {
break;
} else {
zend_hash_del(ht, p->arKey, p->nKeyLength);
if (p->nKeyLength) {
zend_hash_del(ht, p->arKey, p->nKeyLength);
} else {
zend_hash_index_del(ht, p->h);
}
return FAILURE;
}
} else {
if (mode & HASH_UPDATE_KEY_IF_AFTER) {
break;
} else {
zend_hash_del(ht, p->arKey, p->nKeyLength);
if (p->nKeyLength) {
zend_hash_del(ht, p->arKey, p->nKeyLength);
} else {
zend_hash_index_del(ht, p->h);
}
return FAILURE;
}
}