INNER CODE UNIT · C
is_root_level
mongodb/mongo-php-driver · src/phongo_bson_encode.c:413
bool is_root_level = (field_path->size == 0);
if (is_root_level && !(flags & PHONGO_BSON_ALLOW_ROOT_ARRAY)) {
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE, "%s cannot be serialized as a root document", ZSTR_VAL(Z_OBJCE_P(data)->name));
return;
}
PHONGO_INTERN_FROM_ZVAL(packedarray, data);
phongo_bson_copy_to_noinit(intern->bson, bson);
goto done;
}
/* For any MongoDB\BSON\Serializable, invoke the bsonSerialize method
* and work with the result. */
if (instanceof_function(Z_OBJCE_P(data), phongo_serializable_ce)) {
if (!phongo_bson_encode_serializable(data, &obj_data)) {