Skip to content

Commit e1c09b0

Browse files
authored
PHPC-1000: Allow bsonSerialize to return BSON structure (#1449)
* Document and PackedArray classes implement Type interface * Narrow return type for Serializable::bsonSerialize The previously indicated return type was incorrect, as returning an object other than stdClass would result in an error. * Add compat macro for ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_TYPE_MASK_EX * PHPC-1000: Allow bsonSerialize to return BSON structures * Narrow return type of bsonSerialize implementations * Split BSON structure checks for legibility * Added todo to remove obsolete type check * Simplify handling of arrays when encoding BSON * Prevent Persistable implementations to return PackedArray instances * Extract utility function to check return types of bsonSerialize()
1 parent d2a600b commit e1c09b0

24 files changed

+173
-162
lines changed

src/BSON/Document.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ static HashTable* php_phongo_document_get_properties(phongo_compat_object_handle
473473

474474
void php_phongo_document_init_ce(INIT_FUNC_ARGS)
475475
{
476-
php_phongo_document_ce = register_class_MongoDB_BSON_Document(zend_ce_aggregate, zend_ce_serializable);
476+
php_phongo_document_ce = register_class_MongoDB_BSON_Document(zend_ce_aggregate, zend_ce_serializable, php_phongo_type_ce);
477477
php_phongo_document_ce->create_object = php_phongo_document_create_object;
478478

479479
#if PHP_VERSION_ID >= 80000

src/BSON/Document.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace MongoDB\BSON;
99

10-
final class Document implements \IteratorAggregate, \Serializable
10+
final class Document implements \IteratorAggregate, \Serializable, Type
1111
{
1212
private function __construct() {}
1313

src/BSON/Document_arginfo.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: e00ccf66afed0f51040527ee5ee24513f0c1f495 */
2+
* Stub hash: 703e15f17b01dd2b6f04cb89c080ba83a5a420d0 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_BSON_Document___construct, 0, 0, 0)
55
ZEND_END_ARG_INFO()
@@ -166,14 +166,14 @@ static const zend_function_entry class_MongoDB_BSON_Document_methods[] = {
166166
ZEND_FE_END
167167
};
168168

169-
static zend_class_entry *register_class_MongoDB_BSON_Document(zend_class_entry *class_entry_IteratorAggregate, zend_class_entry *class_entry_Serializable)
169+
static zend_class_entry *register_class_MongoDB_BSON_Document(zend_class_entry *class_entry_IteratorAggregate, zend_class_entry *class_entry_Serializable, zend_class_entry *class_entry_MongoDB_BSON_Type)
170170
{
171171
zend_class_entry ce, *class_entry;
172172

173173
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Document", class_MongoDB_BSON_Document_methods);
174174
class_entry = zend_register_internal_class_ex(&ce, NULL);
175175
class_entry->ce_flags |= ZEND_ACC_FINAL;
176-
zend_class_implements(class_entry, 2, class_entry_IteratorAggregate, class_entry_Serializable);
176+
zend_class_implements(class_entry, 3, class_entry_IteratorAggregate, class_entry_Serializable, class_entry_MongoDB_BSON_Type);
177177

178178
return class_entry;
179179
}

src/BSON/PackedArray.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ static HashTable* php_phongo_packedarray_get_properties(phongo_compat_object_han
403403

404404
void php_phongo_packedarray_init_ce(INIT_FUNC_ARGS)
405405
{
406-
php_phongo_packedarray_ce = register_class_MongoDB_BSON_PackedArray(zend_ce_aggregate, zend_ce_serializable);
406+
php_phongo_packedarray_ce = register_class_MongoDB_BSON_PackedArray(zend_ce_aggregate, zend_ce_serializable, php_phongo_type_ce);
407407
php_phongo_packedarray_ce->create_object = php_phongo_packedarray_create_object;
408408

409409
#if PHP_VERSION_ID >= 80000

src/BSON/PackedArray.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace MongoDB\BSON;
99

10-
final class PackedArray implements \IteratorAggregate, \Serializable
10+
final class PackedArray implements \IteratorAggregate, \Serializable, Type
1111
{
1212
private function __construct() {}
1313

src/BSON/PackedArray_arginfo.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: e9b57c4051440170531560cc355e0af1b43f3424 */
2+
* Stub hash: f9813432d7811e068f62a4b34d86919a52f63984 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_BSON_PackedArray___construct, 0, 0, 0)
55
ZEND_END_ARG_INFO()
@@ -128,14 +128,14 @@ static const zend_function_entry class_MongoDB_BSON_PackedArray_methods[] = {
128128
ZEND_FE_END
129129
};
130130

131-
static zend_class_entry *register_class_MongoDB_BSON_PackedArray(zend_class_entry *class_entry_IteratorAggregate, zend_class_entry *class_entry_Serializable)
131+
static zend_class_entry *register_class_MongoDB_BSON_PackedArray(zend_class_entry *class_entry_IteratorAggregate, zend_class_entry *class_entry_Serializable, zend_class_entry *class_entry_MongoDB_BSON_Type)
132132
{
133133
zend_class_entry ce, *class_entry;
134134

135135
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "PackedArray", class_MongoDB_BSON_PackedArray_methods);
136136
class_entry = zend_register_internal_class_ex(&ce, NULL);
137137
class_entry->ce_flags |= ZEND_ACC_FINAL;
138-
zend_class_implements(class_entry, 2, class_entry_IteratorAggregate, class_entry_Serializable);
138+
zend_class_implements(class_entry, 3, class_entry_IteratorAggregate, class_entry_Serializable, class_entry_MongoDB_BSON_Type);
139139

140140
return class_entry;
141141
}

src/BSON/Persistable.stub.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,11 @@
99

1010
interface Persistable extends Serializable, Unserializable
1111
{
12+
#if PHP_VERSION_ID >= 80000
13+
/** @tentative-return-type */
14+
public function bsonSerialize(): array|\stdClass|Document;
15+
#else
16+
/** @return array|\stdClass|Document */
17+
public function bsonSerialize();
18+
#endif
1219
}

src/BSON/Persistable_arginfo.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,30 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: babd07f95f47c3b66228ef23b66ab0446cd5c308 */
2+
* Stub hash: e61c06a90093af5468c6c29f6cbf16c5db8d54d1 */
33

4+
#if PHP_VERSION_ID >= 80000
5+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_MongoDB_BSON_Persistable_bsonSerialize, 0, 0, stdClass|MongoDB\\BSON\\Document, MAY_BE_ARRAY)
6+
ZEND_END_ARG_INFO()
7+
#endif
48

9+
#if !(PHP_VERSION_ID >= 80000)
10+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_BSON_Persistable_bsonSerialize, 0, 0, 0)
11+
ZEND_END_ARG_INFO()
12+
#endif
13+
14+
15+
#if PHP_VERSION_ID >= 80000
16+
#endif
17+
#if !(PHP_VERSION_ID >= 80000)
18+
#endif
519

620

721
static const zend_function_entry class_MongoDB_BSON_Persistable_methods[] = {
22+
#if PHP_VERSION_ID >= 80000
23+
ZEND_ABSTRACT_ME_WITH_FLAGS(MongoDB_BSON_Persistable, bsonSerialize, arginfo_class_MongoDB_BSON_Persistable_bsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
24+
#endif
25+
#if !(PHP_VERSION_ID >= 80000)
26+
ZEND_ABSTRACT_ME_WITH_FLAGS(MongoDB_BSON_Persistable, bsonSerialize, arginfo_class_MongoDB_BSON_Persistable_bsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
27+
#endif
828
ZEND_FE_END
929
};
1030

src/BSON/Serializable.stub.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ interface Serializable extends Type
1111
{
1212
#if PHP_VERSION_ID >= 80000
1313
/** @tentative-return-type */
14-
public function bsonSerialize(): array|object;
14+
public function bsonSerialize(): array|\stdClass|Document|PackedArray;
1515
#else
16-
/** @return array|object */
16+
/** @return array|\stdClass|Document|PackedArray */
1717
public function bsonSerialize();
1818
#endif
1919
}

src/BSON/Serializable_arginfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: cbb517e1d922625ff18bdc81620686a44a87e85c */
2+
* Stub hash: 92732bafa65af8a12b291f7bcb52b069c45724a7 */
33

44
#if PHP_VERSION_ID >= 80000
5-
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_MongoDB_BSON_Serializable_bsonSerialize, 0, 0, MAY_BE_ARRAY|MAY_BE_OBJECT)
5+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_MongoDB_BSON_Serializable_bsonSerialize, 0, 0, stdClass|MongoDB\\BSON\\Document|MongoDB\\BSON\\PackedArray, MAY_BE_ARRAY)
66
ZEND_END_ARG_INFO()
77
#endif
88

src/MongoDB/ReadConcern.stub.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,7 @@ final public function isDefault(): bool {}
4747

4848
final public static function __set_state(array $properties): ReadConcern {}
4949

50-
#if PHP_VERSION_ID >= 80000
51-
final public function bsonSerialize(): array|object {}
52-
#else
53-
/** @return array|object */
54-
final public function bsonSerialize() {}
55-
#endif
50+
final public function bsonSerialize(): \stdClass {}
5651

5752
final public function serialize(): string {}
5853

src/MongoDB/ReadConcern_arginfo.h

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: cc214d2fd99e6191747053214210d07da48831a7 */
2+
* Stub hash: da6e980fbfe2102334158e3018b827e0bb0a9ec3 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_ReadConcern___construct, 0, 0, 0)
55
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, level, IS_STRING, 1, "null")
@@ -15,15 +15,8 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_ReadConcern_
1515
ZEND_ARG_TYPE_INFO(0, properties, IS_ARRAY, 0)
1616
ZEND_END_ARG_INFO()
1717

18-
#if PHP_VERSION_ID >= 80000
19-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_MongoDB_Driver_ReadConcern_bsonSerialize, 0, 0, MAY_BE_ARRAY|MAY_BE_OBJECT)
20-
ZEND_END_ARG_INFO()
21-
#endif
22-
23-
#if !(PHP_VERSION_ID >= 80000)
24-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_ReadConcern_bsonSerialize, 0, 0, 0)
18+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_ReadConcern_bsonSerialize, 0, 0, stdClass, 0)
2519
ZEND_END_ARG_INFO()
26-
#endif
2720

2821
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_ReadConcern_serialize, 0, 0, IS_STRING, 0)
2922
ZEND_END_ARG_INFO()
@@ -52,12 +45,7 @@ static ZEND_METHOD(MongoDB_Driver_ReadConcern, __construct);
5245
static ZEND_METHOD(MongoDB_Driver_ReadConcern, getLevel);
5346
static ZEND_METHOD(MongoDB_Driver_ReadConcern, isDefault);
5447
static ZEND_METHOD(MongoDB_Driver_ReadConcern, __set_state);
55-
#if PHP_VERSION_ID >= 80000
56-
static ZEND_METHOD(MongoDB_Driver_ReadConcern, bsonSerialize);
57-
#endif
58-
#if !(PHP_VERSION_ID >= 80000)
5948
static ZEND_METHOD(MongoDB_Driver_ReadConcern, bsonSerialize);
60-
#endif
6149
static ZEND_METHOD(MongoDB_Driver_ReadConcern, serialize);
6250
#if PHP_VERSION_ID >= 80000
6351
static ZEND_METHOD(MongoDB_Driver_ReadConcern, unserialize);
@@ -74,12 +62,7 @@ static const zend_function_entry class_MongoDB_Driver_ReadConcern_methods[] = {
7462
ZEND_ME(MongoDB_Driver_ReadConcern, getLevel, arginfo_class_MongoDB_Driver_ReadConcern_getLevel, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
7563
ZEND_ME(MongoDB_Driver_ReadConcern, isDefault, arginfo_class_MongoDB_Driver_ReadConcern_isDefault, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
7664
ZEND_ME(MongoDB_Driver_ReadConcern, __set_state, arginfo_class_MongoDB_Driver_ReadConcern___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
77-
#if PHP_VERSION_ID >= 80000
7865
ZEND_ME(MongoDB_Driver_ReadConcern, bsonSerialize, arginfo_class_MongoDB_Driver_ReadConcern_bsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
79-
#endif
80-
#if !(PHP_VERSION_ID >= 80000)
81-
ZEND_ME(MongoDB_Driver_ReadConcern, bsonSerialize, arginfo_class_MongoDB_Driver_ReadConcern_bsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
82-
#endif
8366
ZEND_ME(MongoDB_Driver_ReadConcern, serialize, arginfo_class_MongoDB_Driver_ReadConcern_serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
8467
#if PHP_VERSION_ID >= 80000
8568
ZEND_ME(MongoDB_Driver_ReadConcern, unserialize, arginfo_class_MongoDB_Driver_ReadConcern_unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)

src/MongoDB/ReadPreference.stub.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,7 @@ final public function getTagSets(): array {}
100100

101101
final public static function __set_state(array $properties): ReadPreference {}
102102

103-
#if PHP_VERSION_ID >= 80000
104-
final public function bsonSerialize(): array|object {}
105-
#else
106-
/** @return array|object */
107-
final public function bsonSerialize() {}
108-
#endif
103+
final public function bsonSerialize(): \stdClass {}
109104

110105
final public function serialize(): string {}
111106

src/MongoDB/ReadPreference_arginfo.h

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: df8b13e252c05cbb7603dec8c1659fb88845ed73 */
2+
* Stub hash: 1a1a31ef5910ddfbe66ba6c350df216ffe25b5dd */
33

44
#if PHP_VERSION_ID >= 80000
55
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_ReadPreference___construct, 0, 0, 1)
@@ -35,15 +35,8 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_ReadPreferen
3535
ZEND_ARG_TYPE_INFO(0, properties, IS_ARRAY, 0)
3636
ZEND_END_ARG_INFO()
3737

38-
#if PHP_VERSION_ID >= 80000
39-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_MongoDB_Driver_ReadPreference_bsonSerialize, 0, 0, MAY_BE_ARRAY|MAY_BE_OBJECT)
40-
ZEND_END_ARG_INFO()
41-
#endif
42-
43-
#if !(PHP_VERSION_ID >= 80000)
44-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_ReadPreference_bsonSerialize, 0, 0, 0)
38+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_ReadPreference_bsonSerialize, 0, 0, stdClass, 0)
4539
ZEND_END_ARG_INFO()
46-
#endif
4740

4841
#define arginfo_class_MongoDB_Driver_ReadPreference_serialize arginfo_class_MongoDB_Driver_ReadPreference_getModeString
4942

@@ -78,12 +71,7 @@ static ZEND_METHOD(MongoDB_Driver_ReadPreference, getMode);
7871
static ZEND_METHOD(MongoDB_Driver_ReadPreference, getModeString);
7972
static ZEND_METHOD(MongoDB_Driver_ReadPreference, getTagSets);
8073
static ZEND_METHOD(MongoDB_Driver_ReadPreference, __set_state);
81-
#if PHP_VERSION_ID >= 80000
82-
static ZEND_METHOD(MongoDB_Driver_ReadPreference, bsonSerialize);
83-
#endif
84-
#if !(PHP_VERSION_ID >= 80000)
8574
static ZEND_METHOD(MongoDB_Driver_ReadPreference, bsonSerialize);
86-
#endif
8775
static ZEND_METHOD(MongoDB_Driver_ReadPreference, serialize);
8876
#if PHP_VERSION_ID >= 80000
8977
static ZEND_METHOD(MongoDB_Driver_ReadPreference, unserialize);
@@ -108,12 +96,7 @@ static const zend_function_entry class_MongoDB_Driver_ReadPreference_methods[] =
10896
ZEND_ME(MongoDB_Driver_ReadPreference, getModeString, arginfo_class_MongoDB_Driver_ReadPreference_getModeString, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
10997
ZEND_ME(MongoDB_Driver_ReadPreference, getTagSets, arginfo_class_MongoDB_Driver_ReadPreference_getTagSets, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
11098
ZEND_ME(MongoDB_Driver_ReadPreference, __set_state, arginfo_class_MongoDB_Driver_ReadPreference___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
111-
#if PHP_VERSION_ID >= 80000
11299
ZEND_ME(MongoDB_Driver_ReadPreference, bsonSerialize, arginfo_class_MongoDB_Driver_ReadPreference_bsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
113-
#endif
114-
#if !(PHP_VERSION_ID >= 80000)
115-
ZEND_ME(MongoDB_Driver_ReadPreference, bsonSerialize, arginfo_class_MongoDB_Driver_ReadPreference_bsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
116-
#endif
117100
ZEND_ME(MongoDB_Driver_ReadPreference, serialize, arginfo_class_MongoDB_Driver_ReadPreference_serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
118101
#if PHP_VERSION_ID >= 80000
119102
ZEND_ME(MongoDB_Driver_ReadPreference, unserialize, arginfo_class_MongoDB_Driver_ReadPreference_unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)

src/MongoDB/ServerApi.stub.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,7 @@ final public function __construct(string $version, ?bool $strict = null, ?bool $
1616

1717
final public static function __set_state(array $properties): ServerApi {}
1818

19-
#if PHP_VERSION_ID >= 80000
20-
final public function bsonSerialize(): array|object {}
21-
#else
22-
/** @return array|object */
23-
final public function bsonSerialize() {}
24-
#endif
19+
final public function bsonSerialize(): \stdClass {}
2520

2621
final public function serialize(): string {}
2722

src/MongoDB/ServerApi_arginfo.h

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 27db2a958d63eaf3ca813416bf0756c981dd013f */
2+
* Stub hash: 7678bfacdb398a3528feb4226a5ca1b8a21b9516 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_ServerApi___construct, 0, 0, 1)
55
ZEND_ARG_TYPE_INFO(0, version, IS_STRING, 0)
@@ -11,15 +11,8 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_ServerApi___
1111
ZEND_ARG_TYPE_INFO(0, properties, IS_ARRAY, 0)
1212
ZEND_END_ARG_INFO()
1313

14-
#if PHP_VERSION_ID >= 80000
15-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_MongoDB_Driver_ServerApi_bsonSerialize, 0, 0, MAY_BE_ARRAY|MAY_BE_OBJECT)
16-
ZEND_END_ARG_INFO()
17-
#endif
18-
19-
#if !(PHP_VERSION_ID >= 80000)
20-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_ServerApi_bsonSerialize, 0, 0, 0)
14+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_ServerApi_bsonSerialize, 0, 0, stdClass, 0)
2115
ZEND_END_ARG_INFO()
22-
#endif
2316

2417
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_ServerApi_serialize, 0, 0, IS_STRING, 0)
2518
ZEND_END_ARG_INFO()
@@ -46,12 +39,7 @@ ZEND_END_ARG_INFO()
4639

4740
static ZEND_METHOD(MongoDB_Driver_ServerApi, __construct);
4841
static ZEND_METHOD(MongoDB_Driver_ServerApi, __set_state);
49-
#if PHP_VERSION_ID >= 80000
50-
static ZEND_METHOD(MongoDB_Driver_ServerApi, bsonSerialize);
51-
#endif
52-
#if !(PHP_VERSION_ID >= 80000)
5342
static ZEND_METHOD(MongoDB_Driver_ServerApi, bsonSerialize);
54-
#endif
5543
static ZEND_METHOD(MongoDB_Driver_ServerApi, serialize);
5644
#if PHP_VERSION_ID >= 80000
5745
static ZEND_METHOD(MongoDB_Driver_ServerApi, unserialize);
@@ -66,12 +54,7 @@ static ZEND_METHOD(MongoDB_Driver_ServerApi, __serialize);
6654
static const zend_function_entry class_MongoDB_Driver_ServerApi_methods[] = {
6755
ZEND_ME(MongoDB_Driver_ServerApi, __construct, arginfo_class_MongoDB_Driver_ServerApi___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
6856
ZEND_ME(MongoDB_Driver_ServerApi, __set_state, arginfo_class_MongoDB_Driver_ServerApi___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
69-
#if PHP_VERSION_ID >= 80000
7057
ZEND_ME(MongoDB_Driver_ServerApi, bsonSerialize, arginfo_class_MongoDB_Driver_ServerApi_bsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
71-
#endif
72-
#if !(PHP_VERSION_ID >= 80000)
73-
ZEND_ME(MongoDB_Driver_ServerApi, bsonSerialize, arginfo_class_MongoDB_Driver_ServerApi_bsonSerialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
74-
#endif
7558
ZEND_ME(MongoDB_Driver_ServerApi, serialize, arginfo_class_MongoDB_Driver_ServerApi_serialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
7659
#if PHP_VERSION_ID >= 80000
7760
ZEND_ME(MongoDB_Driver_ServerApi, unserialize, arginfo_class_MongoDB_Driver_ServerApi_unserialize, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)

src/MongoDB/WriteConcern.stub.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,7 @@ final public function isDefault(): bool {}
3737

3838
final public static function __set_state(array $properties): WriteConcern {}
3939

40-
#if PHP_VERSION_ID >= 80000
41-
final public function bsonSerialize(): array|object {}
42-
#else
43-
/** @return array|object */
44-
final public function bsonSerialize() {}
45-
#endif
40+
final public function bsonSerialize(): \stdClass {}
4641

4742
final public function serialize(): string {}
4843

0 commit comments

Comments
 (0)