Skip to content

Commit a8a180b

Browse files
committed
Revise comments for document_to_array()
1 parent 1d1b26c commit a8a180b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/functions.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,9 @@ function apply_type_map_to_document($document, array $typeMap)
101101
* This is used to facilitate unified access to document fields. It also handles
102102
* Document, PackedArray, and Serializable objects.
103103
*
104-
* PackedArray is intentionally allowed because this function is not used for
105-
* type checking. Prohibiting PackedArray would only require callers to check
106-
* for a PackedArray in order to avoid an exception. Furthermore, this function
107-
* does not distinguish between Serializable::bsonSerialize() return values that
108-
* might encode as a BSON document or array.
104+
* This function is not used for type checking. Therefore, it does not reject
105+
* PackedArray objects or Serializable::bsonSerialize() return values that would
106+
* encode as BSON arrays.
109107
*
110108
* @internal
111109
* @param array|object $document
@@ -127,6 +125,9 @@ function document_to_array($document): array
127125
}
128126

129127
if (is_object($document)) {
128+
/* Note: this omits all uninitialized properties, whereas BSON encoding
129+
* includes untyped, uninitialized properties. This is acceptable given
130+
* document_to_array()'s use cases. */
130131
$document = get_object_vars($document);
131132
}
132133

0 commit comments

Comments
 (0)