From a1cd411be97c1d6a0a37652c490eb9bbe6be5e1a Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Thu, 5 Sep 2024 09:39:13 +0200 Subject: [PATCH] Make enum code unconditional --- src/phongo_bson.c | 4 ---- src/phongo_bson_encode.c | 6 ------ src/phongo_compat.c | 2 -- 3 files changed, 12 deletions(-) diff --git a/src/phongo_bson.c b/src/phongo_bson.c index 2e7bdd2eb..62b9cdceb 100644 --- a/src/phongo_bson.c +++ b/src/phongo_bson.c @@ -17,9 +17,7 @@ #include "bson/bson.h" #include -#if PHP_VERSION_ID >= 80100 #include -#endif #include #include @@ -67,11 +65,9 @@ static inline bool phongo_is_class_instantiatable(const zend_class_entry* ce) return false; } -#if PHP_VERSION_ID >= 80100 if (ce->ce_flags & ZEND_ACC_ENUM) { return false; } -#endif /* PHP_VERSION_ID < 80100 */ return true; } diff --git a/src/phongo_bson_encode.c b/src/phongo_bson_encode.c index afdfab97b..77f3551ec 100644 --- a/src/phongo_bson_encode.c +++ b/src/phongo_bson_encode.c @@ -17,9 +17,7 @@ #include "bson/bson.h" #include -#if PHP_VERSION_ID >= 80100 #include -#endif #include #include "php_phongo.h" @@ -293,7 +291,6 @@ static void php_phongo_bson_append_object(bson_t* bson, php_phongo_field_path* f return; } -#if PHP_VERSION_ID >= 80100 if (Z_TYPE_P(object) == IS_OBJECT && Z_OBJCE_P(object)->ce_flags & ZEND_ACC_ENUM) { if (Z_OBJCE_P(object)->enum_backing_type == IS_UNDEF) { char* path_string = php_phongo_field_path_as_string(field_path); @@ -305,7 +302,6 @@ static void php_phongo_bson_append_object(bson_t* bson, php_phongo_field_path* f php_phongo_bson_append(bson, field_path, flags, key, key_len, zend_enum_fetch_case_value(Z_OBJ_P(object))); return; } -#endif /* PHP_VERSION_ID >= 80100 */ { bson_t child; @@ -520,12 +516,10 @@ static void php_phongo_zval_to_bson_internal(zval* data, php_phongo_field_path* /* For the error handling that follows, we can safely assume that we * are at the root level, since php_phongo_bson_append_object would * have already been called for a non-root level. */ -#if PHP_VERSION_ID >= 80100 if (Z_OBJCE_P(data)->ce_flags & ZEND_ACC_ENUM) { phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE, "Enum %s cannot be serialized as a root element", ZSTR_VAL(Z_OBJCE_P(data)->name)); return; } -#endif /* PHP_VERSION_ID >= 80100 */ if (instanceof_function(Z_OBJCE_P(data), php_phongo_type_ce)) { phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE, "%s instance %s cannot be serialized as a root element", ZSTR_VAL(php_phongo_type_ce->name), ZSTR_VAL(Z_OBJCE_P(data)->name)); diff --git a/src/phongo_compat.c b/src/phongo_compat.c index e7e03510b..c5e8b8fa8 100644 --- a/src/phongo_compat.c +++ b/src/phongo_compat.c @@ -49,11 +49,9 @@ const char* zend_get_object_type_case(const zend_class_entry* ce, zend_bool uppe if (ce->ce_flags & ZEND_ACC_INTERFACE) { return upper_case ? "Interface" : "interface"; } -#if PHP_VERSION_ID >= 80100 if (ce->ce_flags & ZEND_ACC_ENUM) { return upper_case ? "Enum" : "enum"; } -#endif /* PHP_VERSION_ID > 80100 */ return upper_case ? "Class" : "class"; } #endif /* PHP_VERSION_ID < 80200 */