Add an enum for HASH_KEY_IS_* constants (GH-19376)

This commit is contained in:
Alexandre Daubois 2025-08-13 13:59:01 +02:00 committed by GitHub
parent 290c9aef56
commit bf64dfcd99
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 15 additions and 12 deletions

View file

@ -79,6 +79,7 @@ PHP 8.5 INTERNALS UPGRADE NOTES
delayed. Before, errors would be recorded but not delayed. delayed. Before, errors would be recorded but not delayed.
. zend_mm_refresh_key_child() must be called on any zend_mm_heap inherited . zend_mm_refresh_key_child() must be called on any zend_mm_heap inherited
from the parent process after a fork(). from the parent process after a fork().
. HASH_KEY_IS_* constants have been moved in the zend_hash_key_type enum.
- standard - standard
. ext/standard/php_smart_string.h and ext/standard/php_smart_string_public.h . ext/standard/php_smart_string.h and ext/standard/php_smart_string_public.h

View file

@ -2842,7 +2842,7 @@ ZEND_API zend_result ZEND_FASTCALL zend_hash_move_backwards_ex(const HashTable *
/* This function should be made binary safe */ /* This function should be made binary safe */
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) 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)
{ {
uint32_t idx; uint32_t idx;
Bucket *p; Bucket *p;
@ -2889,7 +2889,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_get_current_key_zval_ex(const HashTable *h
} }
} }
ZEND_API int ZEND_FASTCALL zend_hash_get_current_key_type_ex(const HashTable *ht, const HashPosition *pos) ZEND_API zend_hash_key_type ZEND_FASTCALL zend_hash_get_current_key_type_ex(const HashTable *ht, const HashPosition *pos)
{ {
uint32_t idx; uint32_t idx;
Bucket *p; Bucket *p;

View file

@ -26,9 +26,11 @@
#include "zend_string.h" #include "zend_string.h"
#include "zend_sort.h" #include "zend_sort.h"
#define HASH_KEY_IS_STRING 1 typedef enum {
#define HASH_KEY_IS_LONG 2 HASH_KEY_IS_STRING = 1,
#define HASH_KEY_NON_EXISTENT 3 HASH_KEY_IS_LONG,
HASH_KEY_NON_EXISTENT
} zend_hash_key_type;
#define HASH_UPDATE (1<<0) /* Create new entry, or update the existing one. */ #define HASH_UPDATE (1<<0) /* Create new entry, or update the existing one. */
#define HASH_ADD (1<<1) /* Create new entry, or fail if it exists. */ #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
ZEND_API zend_result ZEND_FASTCALL zend_hash_move_forward_ex(const HashTable *ht, HashPosition *pos); ZEND_API zend_result ZEND_FASTCALL zend_hash_move_forward_ex(const HashTable *ht, HashPosition *pos);
ZEND_API zend_result ZEND_FASTCALL zend_hash_move_backwards_ex(const HashTable *ht, HashPosition *pos); ZEND_API zend_result ZEND_FASTCALL zend_hash_move_backwards_ex(const HashTable *ht, HashPosition *pos);
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); 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);
ZEND_API void ZEND_FASTCALL zend_hash_get_current_key_zval_ex(const HashTable *ht, zval *key, const HashPosition *pos); ZEND_API void ZEND_FASTCALL zend_hash_get_current_key_zval_ex(const HashTable *ht, zval *key, const HashPosition *pos);
ZEND_API int ZEND_FASTCALL zend_hash_get_current_key_type_ex(const HashTable *ht, const HashPosition *pos); ZEND_API zend_hash_key_type ZEND_FASTCALL zend_hash_get_current_key_type_ex(const HashTable *ht, const HashPosition *pos);
ZEND_API zval* ZEND_FASTCALL zend_hash_get_current_data_ex(const HashTable *ht, const HashPosition *pos); ZEND_API zval* ZEND_FASTCALL zend_hash_get_current_data_ex(const HashTable *ht, const HashPosition *pos);
ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_reset_ex(const HashTable *ht, HashPosition *pos); ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_reset_ex(const HashTable *ht, HashPosition *pos);
ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_end_ex(const HashTable *ht, HashPosition *pos); 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) {
static zend_always_inline zend_result zend_hash_move_backwards(HashTable *ht) { static zend_always_inline zend_result zend_hash_move_backwards(HashTable *ht) {
return zend_hash_move_backwards_ex(ht, &ht->nInternalPointer); return zend_hash_move_backwards_ex(ht, &ht->nInternalPointer);
} }
static zend_always_inline int zend_hash_get_current_key(const HashTable *ht, zend_string **str_index, zend_ulong *num_index) { static zend_always_inline zend_hash_key_type zend_hash_get_current_key(const HashTable *ht, zend_string **str_index, zend_ulong *num_index) {
return zend_hash_get_current_key_ex(ht, str_index, num_index, &ht->nInternalPointer); return zend_hash_get_current_key_ex(ht, str_index, num_index, &ht->nInternalPointer);
} }
static zend_always_inline void zend_hash_get_current_key_zval(const HashTable *ht, zval *key) { static zend_always_inline void zend_hash_get_current_key_zval(const HashTable *ht, zval *key) {
zend_hash_get_current_key_zval_ex(ht, key, &ht->nInternalPointer); zend_hash_get_current_key_zval_ex(ht, key, &ht->nInternalPointer);
} }
static zend_always_inline int zend_hash_get_current_key_type(const HashTable *ht) { static zend_always_inline zend_hash_key_type zend_hash_get_current_key_type(const HashTable *ht) {
return zend_hash_get_current_key_type_ex(ht, &ht->nInternalPointer); return zend_hash_get_current_key_type_ex(ht, &ht->nInternalPointer);
} }
static zend_always_inline zval* zend_hash_get_current_data(const HashTable *ht) { static zend_always_inline zval* zend_hash_get_current_data(const HashTable *ht) {

View file

@ -648,7 +648,7 @@ static void zend_weakmap_iterator_get_current_key(zend_object_iterator *obj_iter
zend_string *string_key; zend_string *string_key;
zend_ulong num_key; zend_ulong num_key;
int key_type = zend_hash_get_current_key_ex(&wm->ht, &string_key, &num_key, pos); zend_hash_key_type key_type = zend_hash_get_current_key_ex(&wm->ht, &string_key, &num_key, pos);
if (key_type == HASH_KEY_NON_EXISTENT) { if (key_type == HASH_KEY_NON_EXISTENT) {
ZVAL_NULL(key); ZVAL_NULL(key);
return; return;

View file

@ -32,7 +32,7 @@ static void safe_array_from_zval(VARIANT *v, zval *z, int codepage)
SAFEARRAY *sa = NULL; SAFEARRAY *sa = NULL;
SAFEARRAYBOUND bound; SAFEARRAYBOUND bound;
HashPosition pos; HashPosition pos;
int keytype; zend_hash_key_type keytype;
zend_string *strindex; zend_string *strindex;
zend_ulong intindex = 0; zend_ulong intindex = 0;
VARIANT *va; VARIANT *va;

View file

@ -423,7 +423,7 @@ static void generate_dispids(php_dispatchex *disp)
HashPosition pos; HashPosition pos;
zend_string *name = NULL; zend_string *name = NULL;
zval *tmp, tmp2; zval *tmp, tmp2;
int keytype; zend_hash_key_type keytype;
zend_long pid; zend_long pid;
if (disp->dispid_to_name == NULL) { if (disp->dispid_to_name == NULL) {