--- /dev/null
+--TEST--
+Bug #35509 (string constant as array key has different behavior inside object)
+--FILE--
+<?php
+class mytest
+{
+ const classConstant = '01';
+
+ private $classArray = array( mytest::classConstant => 'value' );
+
+ public function __construct()
+ {
+ print_r($this->classArray);
+ }
+}
+
+$classtest = new mytest();
+
+define( "normalConstant", '01' );
+$normalArray = array( normalConstant => 'value' );
+print_r($normalArray);
+?>
+--EXPECT--
+Array
+(
+ [01] => value
+)
+Array
+(
+ [01] => value
+)
*element = new_val;
switch (const_value.type) {
- case IS_STRING: {
- long lval;
- double dval;
-
- if (is_numeric_string(Z_STRVAL(const_value), Z_STRLEN(const_value), &lval, &dval, 0) == IS_LONG) {
- zend_hash_update_current_key(p->value.ht, HASH_KEY_IS_LONG, NULL, 0, lval);
- } else {
- zend_hash_update_current_key(p->value.ht, HASH_KEY_IS_STRING, Z_STRVAL(const_value), Z_STRLEN(const_value)+1, 0);
- }
+ case IS_STRING:
+ case IS_UNICODE:
+ zend_u_symtable_update_current_key(p->value.ht, Z_TYPE(const_value), Z_UNIVAL(const_value), Z_UNILEN(const_value)+1);
break;
- }
- case IS_UNICODE: {
- long lval;
- double dval;
-
- if (is_numeric_unicode(Z_USTRVAL(const_value), Z_USTRLEN(const_value), &lval, &dval, 0) == IS_LONG) {
- zend_hash_update_current_key(p->value.ht, HASH_KEY_IS_LONG, NULL, 0, lval);
- } else {
- zend_hash_update_current_key(p->value.ht, HASH_KEY_IS_UNICODE, Z_USTRVAL(const_value), Z_USTRLEN(const_value)+1, 0);
- }
- break;
- }
case IS_BINARY:
zend_hash_update_current_key(p->value.ht, HASH_KEY_IS_BINARY, Z_STRVAL(const_value), Z_STRLEN(const_value)+1, 0);
break;
return zend_u_hash_exists(ht, type, arKey, nKeyLength);
}
+
+ZEND_API int zend_u_symtable_update_current_key(HashTable *ht, zend_uchar type, void *arKey, uint nKeyLength)
+{
+ zend_uchar key_type;
+
+ if (type == IS_STRING) {
+ key_type = HASH_KEY_IS_STRING;
+ HANDLE_NUMERIC((char*)arKey, nKeyLength, zend_hash_update_current_key(ht, HASH_KEY_IS_LONG, NULL, 0, idx));
+ } else if (type == IS_UNICODE) {
+ key_type = HASH_KEY_IS_UNICODE;
+ HANDLE_U_NUMERIC((UChar*)arKey, nKeyLength, zend_hash_update_current_key(ht, HASH_KEY_IS_LONG, NULL, 0, idx));
+ } else {
+ key_type = HASH_KEY_IS_BINARY;
+ }
+ return zend_hash_update_current_key(ht, key_type, arKey, nKeyLength, 0);
+}
+
+
ZEND_API int zend_symtable_update(HashTable *ht, char *arKey, uint nKeyLength, void *pData, uint nDataSize, void **pDest)
{
HANDLE_NUMERIC(arKey, nKeyLength, zend_hash_index_update(ht, idx, pData, nDataSize, pDest));
return zend_hash_exists(ht, arKey, nKeyLength);
}
+
+ZEND_API int zend_symtable_update_current_key(HashTable *ht, char *arKey, uint nKeyLength)
+{
+ HANDLE_NUMERIC(arKey, nKeyLength, zend_hash_update_current_key(ht, HASH_KEY_IS_LONG, NULL, 0, idx));
+ return zend_hash_update_current_key(ht, HASH_KEY_IS_STRING, arKey, nKeyLength, 0);
+}
+
#if ZEND_DEBUG
void zend_hash_display_pListTail(HashTable *ht)
{
ZEND_API int zend_symtable_del(HashTable *ht, char *arKey, uint nKeyLength);
ZEND_API int zend_symtable_find(HashTable *ht, char *arKey, uint nKeyLength, void **pData);
ZEND_API int zend_symtable_exists(HashTable *ht, char *arKey, uint nKeyLength);
+ZEND_API int zend_symtable_update_current_key(HashTable *ht, char *arKey, uint nKeyLength);
ZEND_API int zend_u_symtable_update(HashTable *ht, zend_uchar type, void *arKey, uint nKeyLength, void *pData, uint nDataSize, void **pDest);
ZEND_API int zend_u_symtable_del(HashTable *ht, zend_uchar type, void *arKey, uint nKeyLength);
ZEND_API int zend_u_symtable_find(HashTable *ht, zend_uchar type, void *arKey, uint nKeyLength, void **pData);
ZEND_API int zend_u_symtable_exists(HashTable *ht, zend_uchar type, void *arKey, uint nKeyLength);
+ZEND_API int zend_u_symtable_update_current_key(HashTable *ht, zend_uchar type, void *arKey, uint nKeyLength);
#endif /* ZEND_HASH_H */