You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PHPC-2083: Allow enums to be instantiated during BSON decoding
Enums serialize like PHP objects with a "name" property (BackedEnum instance will also have a "value") and thus become BSON documents. In order for a document to unserialize back to an enum, it must implement either Unserializable or Persistable. The bsonUnserialize() method serves no purpose for initialization, but it will still be invoked.
if (!(ZEND_CLASS_CONST_FLAGS(c) &ZEND_CLASS_CONST_IS_CASE)) {
796
+
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE, "%s::%s is not an enum case", ZSTR_VAL(ce->name), case_name);
797
+
goto cleanup;
798
+
}
799
+
800
+
if (Z_TYPE(c->value) ==IS_CONSTANT_AST&&zval_update_constant_ex(&c->value, ce) ==FAILURE) {
801
+
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE, "Failed to evaluate constant expression AST for %s::%s", ZSTR_VAL(ce->name), case_name);
802
+
goto cleanup;
803
+
}
804
+
805
+
if (Z_TYPE(c->value) !=IS_OBJECT) {
806
+
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE, "Expected %s::%s to be an object, but it is: %s", ZSTR_VAL(ce->name), case_name, PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P(&c->value));
0 commit comments