Skip to content

Commit bf64dfc

Browse files
Add an enum for HASH_KEY_IS_* constants (GH-19376)
1 parent 290c9ae commit bf64dfc

File tree

6 files changed

+15
-12
lines changed

6 files changed

+15
-12
lines changed

UPGRADING.INTERNALS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ PHP 8.5 INTERNALS UPGRADE NOTES
7979
delayed. Before, errors would be recorded but not delayed.
8080
. zend_mm_refresh_key_child() must be called on any zend_mm_heap inherited
8181
from the parent process after a fork().
82+
. HASH_KEY_IS_* constants have been moved in the zend_hash_key_type enum.
8283

8384
- standard
8485
. ext/standard/php_smart_string.h and ext/standard/php_smart_string_public.h

Zend/zend_hash.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2842,7 +2842,7 @@ ZEND_API zend_result ZEND_FASTCALL zend_hash_move_backwards_ex(const HashTable *
28422842

28432843

28442844
/* This function should be made binary safe */
2845-
ZEND_API int ZEND_FASTCALL zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str_index, zend_ulong *num_index, const HashPosition *pos)
2845+
ZEND_API zend_hash_key_type ZEND_FASTCALL zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str_index, zend_ulong *num_index, const HashPosition *pos)
28462846
{
28472847
uint32_t idx;
28482848
Bucket *p;
@@ -2889,7 +2889,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_get_current_key_zval_ex(const HashTable *h
28892889
}
28902890
}
28912891

2892-
ZEND_API int ZEND_FASTCALL zend_hash_get_current_key_type_ex(const HashTable *ht, const HashPosition *pos)
2892+
ZEND_API zend_hash_key_type ZEND_FASTCALL zend_hash_get_current_key_type_ex(const HashTable *ht, const HashPosition *pos)
28932893
{
28942894
uint32_t idx;
28952895
Bucket *p;

Zend/zend_hash.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@
2626
#include "zend_string.h"
2727
#include "zend_sort.h"
2828

29-
#define HASH_KEY_IS_STRING 1
30-
#define HASH_KEY_IS_LONG 2
31-
#define HASH_KEY_NON_EXISTENT 3
29+
typedef enum {
30+
HASH_KEY_IS_STRING = 1,
31+
HASH_KEY_IS_LONG,
32+
HASH_KEY_NON_EXISTENT
33+
} zend_hash_key_type;
3234

3335
#define HASH_UPDATE (1<<0) /* Create new entry, or update the existing one. */
3436
#define HASH_ADD (1<<1) /* Create new entry, or fail if it exists. */
@@ -251,9 +253,9 @@ ZEND_API HashPosition ZEND_FASTCALL zend_hash_get_current_pos(const HashTable *h
251253

252254
ZEND_API zend_result ZEND_FASTCALL zend_hash_move_forward_ex(const HashTable *ht, HashPosition *pos);
253255
ZEND_API zend_result ZEND_FASTCALL zend_hash_move_backwards_ex(const HashTable *ht, HashPosition *pos);
254-
ZEND_API int ZEND_FASTCALL zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str_index, zend_ulong *num_index, const HashPosition *pos);
256+
ZEND_API zend_hash_key_type ZEND_FASTCALL zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str_index, zend_ulong *num_index, const HashPosition *pos);
255257
ZEND_API void ZEND_FASTCALL zend_hash_get_current_key_zval_ex(const HashTable *ht, zval *key, const HashPosition *pos);
256-
ZEND_API int ZEND_FASTCALL zend_hash_get_current_key_type_ex(const HashTable *ht, const HashPosition *pos);
258+
ZEND_API zend_hash_key_type ZEND_FASTCALL zend_hash_get_current_key_type_ex(const HashTable *ht, const HashPosition *pos);
257259
ZEND_API zval* ZEND_FASTCALL zend_hash_get_current_data_ex(const HashTable *ht, const HashPosition *pos);
258260
ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_reset_ex(const HashTable *ht, HashPosition *pos);
259261
ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_end_ex(const HashTable *ht, HashPosition *pos);
@@ -270,13 +272,13 @@ static zend_always_inline zend_result zend_hash_move_forward(HashTable *ht) {
270272
static zend_always_inline zend_result zend_hash_move_backwards(HashTable *ht) {
271273
return zend_hash_move_backwards_ex(ht, &ht->nInternalPointer);
272274
}
273-
static zend_always_inline int zend_hash_get_current_key(const HashTable *ht, zend_string **str_index, zend_ulong *num_index) {
275+
static zend_always_inline zend_hash_key_type zend_hash_get_current_key(const HashTable *ht, zend_string **str_index, zend_ulong *num_index) {
274276
return zend_hash_get_current_key_ex(ht, str_index, num_index, &ht->nInternalPointer);
275277
}
276278
static zend_always_inline void zend_hash_get_current_key_zval(const HashTable *ht, zval *key) {
277279
zend_hash_get_current_key_zval_ex(ht, key, &ht->nInternalPointer);
278280
}
279-
static zend_always_inline int zend_hash_get_current_key_type(const HashTable *ht) {
281+
static zend_always_inline zend_hash_key_type zend_hash_get_current_key_type(const HashTable *ht) {
280282
return zend_hash_get_current_key_type_ex(ht, &ht->nInternalPointer);
281283
}
282284
static zend_always_inline zval* zend_hash_get_current_data(const HashTable *ht) {

Zend/zend_weakrefs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ static void zend_weakmap_iterator_get_current_key(zend_object_iterator *obj_iter
648648

649649
zend_string *string_key;
650650
zend_ulong num_key;
651-
int key_type = zend_hash_get_current_key_ex(&wm->ht, &string_key, &num_key, pos);
651+
zend_hash_key_type key_type = zend_hash_get_current_key_ex(&wm->ht, &string_key, &num_key, pos);
652652
if (key_type == HASH_KEY_NON_EXISTENT) {
653653
ZVAL_NULL(key);
654654
return;

ext/com_dotnet/com_variant.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static void safe_array_from_zval(VARIANT *v, zval *z, int codepage)
3232
SAFEARRAY *sa = NULL;
3333
SAFEARRAYBOUND bound;
3434
HashPosition pos;
35-
int keytype;
35+
zend_hash_key_type keytype;
3636
zend_string *strindex;
3737
zend_ulong intindex = 0;
3838
VARIANT *va;

ext/com_dotnet/com_wrapper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ static void generate_dispids(php_dispatchex *disp)
423423
HashPosition pos;
424424
zend_string *name = NULL;
425425
zval *tmp, tmp2;
426-
int keytype;
426+
zend_hash_key_type keytype;
427427
zend_long pid;
428428

429429
if (disp->dispid_to_name == NULL) {

0 commit comments

Comments
 (0)