Skip to content

Commit 488bc9c

Browse files
committed
Make enum code unconditional
1 parent 7c3a06f commit 488bc9c

File tree

3 files changed

+0
-12
lines changed

3 files changed

+0
-12
lines changed

src/phongo_bson.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
#include "bson/bson.h"
1818

1919
#include <php.h>
20-
#if PHP_VERSION_ID >= 80100
2120
#include <Zend/zend_enum.h>
22-
#endif
2321
#include <Zend/zend_interfaces.h>
2422
#include <Zend/zend_portability.h>
2523

@@ -67,11 +65,9 @@ static inline bool phongo_is_class_instantiatable(const zend_class_entry* ce)
6765
return false;
6866
}
6967

70-
#if PHP_VERSION_ID >= 80100
7168
if (ce->ce_flags & ZEND_ACC_ENUM) {
7269
return false;
7370
}
74-
#endif /* PHP_VERSION_ID < 80100 */
7571

7672
return true;
7773
}

src/phongo_bson_encode.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
#include "bson/bson.h"
1818

1919
#include <php.h>
20-
#if PHP_VERSION_ID >= 80100
2120
#include <Zend/zend_enum.h>
22-
#endif
2321
#include <Zend/zend_interfaces.h>
2422

2523
#include "php_phongo.h"
@@ -293,7 +291,6 @@ static void php_phongo_bson_append_object(bson_t* bson, php_phongo_field_path* f
293291
return;
294292
}
295293

296-
#if PHP_VERSION_ID >= 80100
297294
if (Z_TYPE_P(object) == IS_OBJECT && Z_OBJCE_P(object)->ce_flags & ZEND_ACC_ENUM) {
298295
if (Z_OBJCE_P(object)->enum_backing_type == IS_UNDEF) {
299296
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
305302
php_phongo_bson_append(bson, field_path, flags, key, key_len, zend_enum_fetch_case_value(Z_OBJ_P(object)));
306303
return;
307304
}
308-
#endif /* PHP_VERSION_ID >= 80100 */
309305

310306
{
311307
bson_t child;
@@ -520,12 +516,10 @@ static void php_phongo_zval_to_bson_internal(zval* data, php_phongo_field_path*
520516
/* For the error handling that follows, we can safely assume that we
521517
* are at the root level, since php_phongo_bson_append_object would
522518
* have already been called for a non-root level. */
523-
#if PHP_VERSION_ID >= 80100
524519
if (Z_OBJCE_P(data)->ce_flags & ZEND_ACC_ENUM) {
525520
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE, "Enum %s cannot be serialized as a root element", ZSTR_VAL(Z_OBJCE_P(data)->name));
526521
return;
527522
}
528-
#endif /* PHP_VERSION_ID >= 80100 */
529523

530524
if (instanceof_function(Z_OBJCE_P(data), php_phongo_type_ce)) {
531525
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));

src/phongo_compat.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,9 @@ const char* zend_get_object_type_case(const zend_class_entry* ce, zend_bool uppe
4949
if (ce->ce_flags & ZEND_ACC_INTERFACE) {
5050
return upper_case ? "Interface" : "interface";
5151
}
52-
#if PHP_VERSION_ID >= 80100
5352
if (ce->ce_flags & ZEND_ACC_ENUM) {
5453
return upper_case ? "Enum" : "enum";
5554
}
56-
#endif /* PHP_VERSION_ID > 80100 */
5755
return upper_case ? "Class" : "class";
5856
}
5957
#endif /* PHP_VERSION_ID < 80200 */

0 commit comments

Comments
 (0)