Commit 44e59fed authored by Jeremy Mikola's avatar Jeremy Mikola

PHPLIB-280: Rename ObjectID to ObjectId

parent dcb4ccaa
......@@ -3,7 +3,7 @@ name: _id
type: mixed
description: |
Value to use as the file document identifier. Defaults to a new
:php:`MongoDB\\BSON\\ObjectID <class.mongodb-bson-objectid>` object.
:php:`MongoDB\\BSON\\ObjectId <class.mongodb-bson-objectid>` object.
interface: phpmethod
operation: ~
optional: true
......
......@@ -7,6 +7,6 @@ content: |
<manual/en/language.types.type-juggling.php>` rules. When matching a special
BSON type the query criteria should use the respective :php:`BSON class
<manual/en/book.bson.php>` in the driver (e.g. use
:php:`MongoDB\\BSON\\ObjectID <class.mongodb-bson-objectid>` to match an
:php:`MongoDB\\BSON\\ObjectId <class.mongodb-bson-objectid>` to match an
:manual:`ObjectId </reference/object-id/>`).
...
......@@ -124,7 +124,7 @@ Consider the following class definition:
public function __construct($name)
{
$this->id = new MongoDB\BSON\ObjectID;
$this->id = new MongoDB\BSON\ObjectId;
$this->name = (string) $name;
$this->createdAt = new MongoDB\BSON\UTCDateTime;
}
......@@ -167,7 +167,7 @@ The output would then resemble:
object(Person)#18 (3) {
["id":"Person":private]=>
object(MongoDB\BSON\ObjectID)#15 (1) {
object(MongoDB\BSON\ObjectId)#15 (1) {
["oid"]=>
string(24) "56fad2c36118fd2e9820cfc1"
}
......
......@@ -34,5 +34,5 @@ insert operations in the bulk write.
The index of each ID in the map corresponds to each document's position in the
bulk operation. If a document had an ID prior to inserting (i.e. the driver did
not generate an ID), the index will contain its ``_id`` field value. Any
driver-generated ID will be a :php:`MongoDB\\BSON\\ObjectID
driver-generated ID will be a :php:`MongoDB\\BSON\\ObjectId
<class.mongodb-bson-objectid>` instance.
......@@ -31,7 +31,7 @@ update and replace operations in the bulk write.
The index of each ID in the map corresponds to each document's position in the
bulk operation. If a document had an ID prior to upserting (i.e. the server did
not generate an ID), the index will contain its ``_id`` field value. Any
server-generated ID will be a :php:`MongoDB\\BSON\\ObjectID
server-generated ID will be a :php:`MongoDB\\BSON\\ObjectId
<class.mongodb-bson-objectid>` instance.
Errors/Exceptions
......
......@@ -83,7 +83,7 @@ The output would then resemble::
["storage":"ArrayObject":private]=>
array(4) {
["_id"]=>
object(MongoDB\BSON\ObjectID)#8 (1) {
object(MongoDB\BSON\ObjectId)#8 (1) {
["oid"]=>
string(24) "576023c6b02fa9281da3f983"
}
......@@ -99,7 +99,7 @@ The output would then resemble::
["storage":"ArrayObject":private]=>
array(4) {
["_id"]=>
object(MongoDB\BSON\ObjectID)#12 (1) {
object(MongoDB\BSON\ObjectId)#12 (1) {
["oid"]=>
string(24) "576023c6b02fa9281da3f98d"
}
......@@ -115,7 +115,7 @@ The output would then resemble::
["storage":"ArrayObject":private]=>
array(4) {
["_id"]=>
object(MongoDB\BSON\ObjectID)#10 (1) {
object(MongoDB\BSON\ObjectId)#10 (1) {
["oid"]=>
string(24) "576023c6b02fa9281da3f99b"
}
......@@ -131,7 +131,7 @@ The output would then resemble::
["storage":"ArrayObject":private]=>
array(4) {
["_id"]=>
object(MongoDB\BSON\ObjectID)#13 (1) {
object(MongoDB\BSON\ObjectId)#13 (1) {
["oid"]=>
string(24) "576023c6b02fa9281da3f9a8"
}
......@@ -147,7 +147,7 @@ The output would then resemble::
["storage":"ArrayObject":private]=>
array(4) {
["_id"]=>
object(MongoDB\BSON\ObjectID)#8 (1) {
object(MongoDB\BSON\ObjectId)#8 (1) {
["oid"]=>
string(24) "576023c6b02fa9281da3f9b4"
}
......
......@@ -56,9 +56,9 @@ Matching BSON Types in Query Criteria
In the following example, documents in the ``restaurants`` collection use an
:manual:`ObjectId </reference/object-id/>` for their identifier (the default)
and documents in the ``zips`` collection use a string. Since ObjectID is a
and documents in the ``zips`` collection use a string. Since ObjectId is a
special BSON type, the query criteria for selecting a restaurant must use the
:php:`MongoDB\\BSON\\ObjectID <class.mongodb-bson-objectid>` class.
:php:`MongoDB\\BSON\\ObjectId <class.mongodb-bson-objectid>` class.
.. code-block:: php
......@@ -67,7 +67,7 @@ special BSON type, the query criteria for selecting a restaurant must use the
$zip = $database->zips->findOne(['_id' => '10036']);
$restaurant = $database->restaurants->findOne([
'_id' => new MongoDB\BSON\ObjectID('594d5ef280a846852a4b3f70'),
'_id' => new MongoDB\BSON\ObjectId('594d5ef280a846852a4b3f70'),
]);
Projecting Fields
......@@ -104,7 +104,7 @@ The output would then resemble::
["storage":"ArrayObject":private]=>
array(4) {
["_id"]=>
object(MongoDB\BSON\ObjectID)#8 (1) {
object(MongoDB\BSON\ObjectId)#8 (1) {
["oid"]=>
string(24) "576023c6b02fa9281da3f983"
}
......
......@@ -79,7 +79,7 @@ The output would then resemble::
["storage":"ArrayObject":private]=>
array(4) {
["_id"]=>
object(MongoDB\BSON\ObjectID)#11 (1) {
object(MongoDB\BSON\ObjectId)#11 (1) {
["oid"]=>
string(24) "594d5ef280a846852a4b3f70"
}
......
......@@ -121,7 +121,7 @@ The output would then resemble::
["storage":"ArrayObject":private]=>
array(6) {
["_id"]=>
object(MongoDB\BSON\ObjectID)#11 (1) {
object(MongoDB\BSON\ObjectId)#11 (1) {
["oid"]=>
string(24) "594d5ef380a846852a4b5837"
}
......
......@@ -80,7 +80,7 @@ The output would then resemble::
["storage":"ArrayObject":private]=>
array(2) {
["_id"]=>
object(MongoDB\BSON\ObjectID)#12 (1) {
object(MongoDB\BSON\ObjectId)#12 (1) {
["oid"]=>
string(24) "594d5ef280a846852a4b3dee"
}
......
......@@ -84,12 +84,12 @@ The output would then resemble::
Inserted 2 document(s)
array(2) {
[0]=>
object(MongoDB\BSON\ObjectID)#11 (1) {
object(MongoDB\BSON\ObjectId)#11 (1) {
["oid"]=>
string(24) "579a25921f417dd1e5518141"
}
[1]=>
object(MongoDB\BSON\ObjectID)#12 (1) {
object(MongoDB\BSON\ObjectId)#12 (1) {
["oid"]=>
string(24) "579a25921f417dd1e5518142"
}
......
......@@ -74,7 +74,7 @@ The following operation inserts a document into the ``users`` collection in the
The output would then resemble::
Inserted 1 document(s)
object(MongoDB\BSON\ObjectID)#11 (1) {
object(MongoDB\BSON\ObjectId)#11 (1) {
["oid"]=>
string(24) "579a25921f417dd1e5518141"
}
......
......@@ -34,7 +34,7 @@ Return Values
The ``_id`` field of the metadata document associated with the newly created
GridFS file. If the ``_id`` option is not specified, a new
:php:`MongoDB\\BSON\\ObjectID <class.mongodb-bson-objectid>` object will be used
:php:`MongoDB\\BSON\\ObjectId <class.mongodb-bson-objectid>` object will be used
by default.
Errors/Exceptions
......
......@@ -32,5 +32,5 @@ A map of IDs (i.e. ``_id`` field values) for the inserted documents.
The index of each ID in the map corresponds to each document's position in the
bulk operation. If a document had an ID prior to inserting (i.e. the driver did
not generate an ID), the index will contain its ``_id`` field value. Any
driver-generated ID will be a :php:`MongoDB\\BSON\\ObjectID
driver-generated ID will be a :php:`MongoDB\\BSON\\ObjectId
<class.mongodb-bson-objectid>` instance.
......@@ -31,5 +31,5 @@ The ID (i.e. ``_id`` field value) of the inserted document.
If the document had an ID prior to inserting (i.e. the driver did not need to
generate an ID), this will contain its ``_id`` field value. Any driver-generated
ID will be a :php:`MongoDB\\BSON\\ObjectID <class.mongodb-bson-objectid>`
ID will be a :php:`MongoDB\\BSON\\ObjectId <class.mongodb-bson-objectid>`
instance.
......@@ -29,7 +29,7 @@ upserted, ``null`` will be returned.
If the document had an ID prior to upserting (i.e. the server did not need to
generate an ID), this will contain its ``_id`` field value. Any server-generated
ID will be a :php:`MongoDB\\BSON\\ObjectID <class.mongodb-bson-objectid>`
ID will be a :php:`MongoDB\\BSON\\ObjectId <class.mongodb-bson-objectid>`
instance.
Errors/Exceptions
......
......@@ -74,7 +74,7 @@ The output would then resemble::
["storage":"ArrayObject":private]=>
array(3) {
["_id"]=>
object(MongoDB\BSON\ObjectID)#3 (1) {
object(MongoDB\BSON\ObjectId)#3 (1) {
["oid"]=>
string(24) "55cba2486c522cafdb059bed"
}
......@@ -113,7 +113,7 @@ The output would then resemble::
["storage":"ArrayObject":private]=>
array(3) {
["_id"]=>
object(MongoDB\BSON\ObjectID)#15 (1) {
object(MongoDB\BSON\ObjectId)#15 (1) {
["oid"]=>
string(24) "55cba2476c522cafdb0544df"
}
......@@ -152,7 +152,7 @@ The output would then resemble::
["storage":"ArrayObject":private]=>
array(3) {
["_id"]=>
object(MongoDB\BSON\ObjectID)#20 (1) {
object(MongoDB\BSON\ObjectId)#20 (1) {
["oid"]=>
string(24) "55cba2476c522cafdb053c92"
}
......
......@@ -145,7 +145,7 @@ The output would then resemble::
``"94301"``. The same criteria would not have matched a document with an
integer value of ``94301`` due to MongoDB's :manual:`comparison rules for
BSON types </reference/bson-type-comparison-order>`. Similarly, users should
use a :php:`MongoDB\\BSON\\ObjectID <class.mongodb-bson-objectid>` object
use a :php:`MongoDB\\BSON\\ObjectId <class.mongodb-bson-objectid>` object
when matching an ``_id`` with an :manual:`ObjectId </reference/object-id/>`
value, as strings and ObjectIds are not directly comparable.
......@@ -237,7 +237,7 @@ The output would then resemble::
["storage":"ArrayObject":private]=>
array(4) {
["_id"]=>
object(MongoDB\BSON\ObjectID)#8 (1) {
object(MongoDB\BSON\ObjectId)#8 (1) {
["oid"]=>
string(24) "576023c6b02fa9281da3f983"
}
......@@ -253,7 +253,7 @@ The output would then resemble::
["storage":"ArrayObject":private]=>
array(4) {
["_id"]=>
object(MongoDB\BSON\ObjectID)#12 (1) {
object(MongoDB\BSON\ObjectId)#12 (1) {
["oid"]=>
string(24) "576023c6b02fa9281da3f98d"
}
......@@ -269,7 +269,7 @@ The output would then resemble::
["storage":"ArrayObject":private]=>
array(4) {
["_id"]=>
object(MongoDB\BSON\ObjectID)#10 (1) {
object(MongoDB\BSON\ObjectId)#10 (1) {
["oid"]=>
string(24) "576023c6b02fa9281da3f99b"
}
......@@ -285,7 +285,7 @@ The output would then resemble::
["storage":"ArrayObject":private]=>
array(4) {
["_id"]=>
object(MongoDB\BSON\ObjectID)#13 (1) {
object(MongoDB\BSON\ObjectId)#13 (1) {
["oid"]=>
string(24) "576023c6b02fa9281da3f9a8"
}
......@@ -658,7 +658,7 @@ The output would then resemble::
["storage":"ArrayObject":private]=>
array(3) {
["_id"]=>
object(MongoDB\BSON\ObjectID)#15 (1) {
object(MongoDB\BSON\ObjectId)#15 (1) {
["oid"]=>
string(24) "57509c4406d7241dad86e7c3"
}
......
......@@ -84,7 +84,7 @@ class BulkWriteResult
* The index of each ID in the map corresponds to each document's position
* in the bulk operation. If a document had an ID prior to inserting (i.e.
* the driver did not generate an ID), the index will contain its "_id"
* field value. Any driver-generated ID will be a MongoDB\BSON\ObjectID
* field value. Any driver-generated ID will be a MongoDB\BSON\ObjectId
* instance.
*
* @return mixed[]
......@@ -157,7 +157,7 @@ class BulkWriteResult
* The index of each ID in the map corresponds to each document's position
* in bulk operation. If a document had an ID prior to upserting (i.e. the
* server did not need to generate an ID), this will contain its "_id". Any
* server-generated ID will be a MongoDB\BSON\ObjectID instance.
* server-generated ID will be a MongoDB\BSON\ObjectId instance.
*
* This method should only be called if the write was acknowledged.
*
......
......@@ -66,7 +66,7 @@ class InsertManyResult
* The index of each ID in the map corresponds to each document's position
* in the bulk operation. If a document had an ID prior to inserting (i.e.
* the driver did not generate an ID), the index will contain its "_id"
* field value. Any driver-generated ID will be a MongoDB\BSON\ObjectID
* field value. Any driver-generated ID will be a MongoDB\BSON\ObjectId
* instance.
*
* @return mixed[]
......
......@@ -65,7 +65,7 @@ class InsertOneResult
*
* If the document had an ID prior to inserting (i.e. the driver did not
* need to generate an ID), this will contain its "_id". Any
* driver-generated ID will be a MongoDB\BSON\ObjectID instance.
* driver-generated ID will be a MongoDB\BSON\ObjectId instance.
*
* @return mixed
*/
......
......@@ -101,7 +101,7 @@ class UpdateResult
*
* If the document had an ID prior to upserting (i.e. the server did not
* need to generate an ID), this will contain its "_id". Any
* server-generated ID will be a MongoDB\BSON\ObjectID instance.
* server-generated ID will be a MongoDB\BSON\ObjectId instance.
*
* This value is undefined (i.e. null) if an upsert did not take place.
*
......
......@@ -46,7 +46,7 @@ class DocumentationExamplesTest extends FunctionalTestCase
// End Example 1
$this->assertSame(1, $insertOneResult->getInsertedCount());
$this->assertInstanceOf('MongoDB\BSON\ObjectID', $insertOneResult->getInsertedId());
$this->assertInstanceOf('MongoDB\BSON\ObjectId', $insertOneResult->getInsertedId());
$this->assertInventoryCount(1);
// Start Example 2
......@@ -85,7 +85,7 @@ class DocumentationExamplesTest extends FunctionalTestCase
$this->assertSame(3, $insertManyResult->getInsertedCount());
foreach ($insertManyResult->getInsertedIds() as $id) {
$this->assertInstanceOf('MongoDB\BSON\ObjectID', $id);
$this->assertInstanceOf('MongoDB\BSON\ObjectId', $id);
}
$this->assertInventoryCount(3);
}
......@@ -131,7 +131,7 @@ class DocumentationExamplesTest extends FunctionalTestCase
$this->assertSame(5, $insertManyResult->getInsertedCount());
foreach ($insertManyResult->getInsertedIds() as $id) {
$this->assertInstanceOf('MongoDB\BSON\ObjectID', $id);
$this->assertInstanceOf('MongoDB\BSON\ObjectId', $id);
}
$this->assertInventoryCount(5);
......@@ -234,7 +234,7 @@ class DocumentationExamplesTest extends FunctionalTestCase
$this->assertSame(5, $insertManyResult->getInsertedCount());
foreach ($insertManyResult->getInsertedIds() as $id) {
$this->assertInstanceOf('MongoDB\BSON\ObjectID', $id);
$this->assertInstanceOf('MongoDB\BSON\ObjectId', $id);
}
$this->assertInventoryCount(5);
......@@ -314,7 +314,7 @@ class DocumentationExamplesTest extends FunctionalTestCase
$this->assertSame(5, $insertManyResult->getInsertedCount());
foreach ($insertManyResult->getInsertedIds() as $id) {
$this->assertInstanceOf('MongoDB\BSON\ObjectID', $id);
$this->assertInstanceOf('MongoDB\BSON\ObjectId', $id);
}
$this->assertInventoryCount(5);
......@@ -424,7 +424,7 @@ class DocumentationExamplesTest extends FunctionalTestCase
$this->assertSame(5, $insertManyResult->getInsertedCount());
foreach ($insertManyResult->getInsertedIds() as $id) {
$this->assertInstanceOf('MongoDB\BSON\ObjectID', $id);
$this->assertInstanceOf('MongoDB\BSON\ObjectId', $id);
}
$this->assertInventoryCount(5);
......@@ -565,7 +565,7 @@ class DocumentationExamplesTest extends FunctionalTestCase
$this->assertSame(5, $insertManyResult->getInsertedCount());
foreach ($insertManyResult->getInsertedIds() as $id) {
$this->assertInstanceOf('MongoDB\BSON\ObjectID', $id);
$this->assertInstanceOf('MongoDB\BSON\ObjectId', $id);
}
$this->assertInventoryCount(5);
......@@ -785,7 +785,7 @@ class DocumentationExamplesTest extends FunctionalTestCase
$this->assertSame(10, $insertManyResult->getInsertedCount());
foreach ($insertManyResult->getInsertedIds() as $id) {
$this->assertInstanceOf('MongoDB\BSON\ObjectID', $id);
$this->assertInstanceOf('MongoDB\BSON\ObjectId', $id);
}
$this->assertInventoryCount(10);
......@@ -897,7 +897,7 @@ class DocumentationExamplesTest extends FunctionalTestCase
$this->assertSame(5, $insertManyResult->getInsertedCount());
foreach ($insertManyResult->getInsertedIds() as $id) {
$this->assertInstanceOf('MongoDB\BSON\ObjectID', $id);
$this->assertInstanceOf('MongoDB\BSON\ObjectId', $id);
}
$this->assertInventoryCount(5);
......
......@@ -41,11 +41,11 @@ abstract class FunctionalTestCase extends TestCase
$this->assertEquals(1, $document['ok']);
}
protected function assertSameObjectID($expectedObjectID, $actualObjectID)
protected function assertSameObjectId($expectedObjectId, $actualObjectId)
{
$this->assertInstanceOf('MongoDB\BSON\ObjectID', $expectedObjectID);
$this->assertInstanceOf('MongoDB\BSON\ObjectID', $actualObjectID);
$this->assertEquals((string) $expectedObjectID, (string) $actualObjectID);
$this->assertInstanceOf('MongoDB\BSON\ObjectId', $expectedObjectId);
$this->assertInstanceOf('MongoDB\BSON\ObjectId', $actualObjectId);
$this->assertEquals((string) $expectedObjectId, (string) $actualObjectId);
}
protected function assertSameDocument($expectedDocument, $actualDocument)
......
......@@ -388,7 +388,7 @@ class BucketFunctionalTest extends FunctionalTestCase
$fileDocument = $this->bucket->getFileDocumentForStream($stream);
$this->assertSameObjectID($id, $fileDocument->_id);
$this->assertSameObjectId($id, $fileDocument->_id);
$this->assertSame('filename', $fileDocument->filename);
$this->assertSame(6, $fileDocument->length);
$this->assertSameDocument($metadata, $fileDocument->metadata);
......@@ -435,7 +435,7 @@ class BucketFunctionalTest extends FunctionalTestCase
$id = $this->bucket->uploadFromStream('filename', $this->createStream('foobar'));
$stream = $this->bucket->openDownloadStream($id);
$this->assertSameObjectID($id, $this->bucket->getFileIdForStream($stream));
$this->assertSameObjectId($id, $this->bucket->getFileIdForStream($stream));
}
public function testGetFileIdForStreamWithWritableStream()
......
......@@ -118,7 +118,7 @@ class SpecFunctionalTest extends FunctionalTestCase
/**
* Convert encoded types in the array and return the modified array.
*
* Nested arrays with "$oid" and "$date" keys will be converted to ObjectID
* Nested arrays with "$oid" and "$date" keys will be converted to ObjectId
* and UTCDateTime instances, respectively. Nested arrays with "$hex" keys
* will be converted to a string or Binary object.
*
......
......@@ -3,7 +3,7 @@
namespace MongoDB\Tests\Operation;
use MongoDB\BSON\Javascript;
use MongoDB\BSON\ObjectID;
use MongoDB\BSON\ObjectId;
use MongoDB\Operation\MapReduce;
use stdClass;
......@@ -104,6 +104,6 @@ class MapReduceTest extends TestCase
private function getInvalidJavascriptValues()
{
return [123, 3.14, 'foo', true, [], new stdClass, new ObjectID];
return [123, 3.14, 'foo', true, [], new stdClass, new ObjectId];
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment