-
Notifications
You must be signed in to change notification settings - Fork 266
PHPLIB-675 Document new CollectionInfo methods #841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
$info = new CollectionInfo([ | ||
'type' => 'view', | ||
'name' => 'foo', | ||
'idIndex' => [ | ||
'v' => 2, | ||
'key' => ['_id' => 1], | ||
'name' => '_id', | ||
'ns' => 'test.foo', | ||
], | ||
]); | ||
|
||
var_dump($info->getIdIndex()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if these examples are really helpful. I believe we could optimise these by creating a collection first, then getting a CollectionInfo
object for a collection and dumping from there. Right now, the example doesn't really clarify that the info here is server dependent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I concur. There's absolutely no reason to construct this directly, as that's not the intended use of this API.
It looks like these examples date back to PHPLIB-278, which I signed off on. In the meantime, I'd suggest not adding any new examples and making a ticket to either replace all of these with integration examples or remove them entirely and just point users to the corresponding enumeration method that would return these objects in the first place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll leave these examples in for consistency and have created PHPLIB-689 to track improvements.
docs/reference/method/MongoDBModelCollectionInfo-getCappedMax.txt
Outdated
Show resolved
Hide resolved
@@ -29,6 +31,9 @@ Return Values | |||
The size limit for the capped collection in bytes. If the collection is not | |||
capped, ``null`` will be returned. | |||
|
|||
This method is deprecated in favor of using | |||
:phpmethod:`MongoDB\\Model\\CollectionInfo::getOptions()`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here for suggesting folks access the size
key.
|
||
.. code-block:: php | ||
|
||
function getInfo(): array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a thought about how this and getOptions
cast the returned value to an array and how that might be inconsistent is a nested value was a document and was reported as a stdClass. I then remembered that ListCollections doesn't support a typeMap
option at all and applies its own typeMap such that root and embedded docs become PHP arrays. So there's no reason to be concerned about inconsistency -- and I also don't worry about the MongoDB server returning a value that would be ambiguous (e.g. document with sequential numeric keys).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting for deprecated methods need double backticks. LGTM otherwise.
PHPLIB-675
Adds missing documentation for new method and documents the deprecation of helpers relating to capped collections.