diff --git a/docs/upgrade.txt b/docs/upgrade.txt index 5b0cb9194..c5420fa12 100644 --- a/docs/upgrade.txt +++ b/docs/upgrade.txt @@ -235,3 +235,63 @@ been replaced with a general-purpose :phpmethod:`MongoDB\\Collection::bulkWrite()` method. Whereas the legacy driver only allowed bulk operations of the same type, the new method allows operations to be mixed (e.g. inserts, updates, and deletes). + +BSON class upgrade guide +~~~~~~~~~~~~~~~~~~~~~~~~ + +When upgrading from the legacy driver, classes like :php:`MongoId ` +have to be replaced with classes in the ``MongoDB\\BSON`` namespace. The +following table lists all legacy classes along with the class that replaces +them. When typehinting against BSON values, use type interfaces instead of their +implementations. + +.. list-table:: + :header-rows: 1 + + * - Legacy class + - BSON type class + - BSON type interface + + * - :php:`MongoId ` + - :php:`MongoDB\\BSON\\ObjectId ` + - + + * - :php:`MongoCode ` + - :php:`MongoDB\\BSON\\Javascript ` + - :php:`MongoDB\\BSON\\JavascriptInterface ` + + * - :php:`MongoDate ` + - :php:`MongoDB\\BSON\\UTCDateTime ` + - :php:`MongoDB\\BSON\\UTCDateTimeInterface ` + + * - :php:`MongoRegex ` + - :php:`MongoDB\\BSON\\Regex ` + - :php:`MongoDB\\BSON\\RegexInterface ` + + * - :php:`MongoBinData ` + - :php:`MongoDB\\BSON\\Binary ` + - :php:`MongoDB\\BSON\\BinaryInterface ` + + * - :php:`MongoInt32 ` + - Dropped without replacement. + - + + * - :php:`MongoInt64 ` + - :php:`MongoDB\\BSON\\Int64 ` + - + + * - :php:`MongoDBRef ` + - Dropped without replacement. + - + + * - :php:`MongoMinKey ` + - :php:`MongoDB\\BSON\\MinKey ` + - :php:`MongoDB\\BSON\\MinKeyInterface ` + + * - :php:`MongoMaxKey ` + - :php:`MongoDB\\BSON\\MaxKey ` + - :php:`MongoDB\\BSON\\MaxKeyInterface ` + + * - :php:`MongoTimestamp ` + - :php:`MongoDB\\BSON\\Timestamp ` + - :php:`MongoDB\\BSON\\TimestampInterface `