-
Notifications
You must be signed in to change notification settings - Fork 264
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
Remove compatibility layer for CursorId deprecation #1425
Conversation
The CI build fails as we're not testing with the 2.0 version yet. This depends on mongodb/mongo-php-driver#1672. It may be necessary to wrap this work into #1391. |
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.
Some questions, but I don't think I have any actionable feedback.
{ | ||
/** | ||
* @return TValue|null | ||
* @psalm-ignore-nullable-return |
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.
IIUC, @psalm-ignore-nullable-return
tells Psalm to never consider a null return value. But current()
and key()
can certainly return null
if valid()
is false
. Why needn't we consider that case?
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.
This was blatantly copied over from psalm's iterator stubs. The way I see it, this is a shortcoming of the original interface. The interface doesn't specify whether current
and key
should throw when on an invalid position, and most iterators return null
instead. IMO, we should throw, but I imagine a lot of code isn't exactly built to handle throwing in the methods. At the same time, we do expect people to not call current
and key
without checking that the iterator is on a valid position, hence that annotation.
For immutable classes, the psalm-assert-if-true
annotation would solve this, but since next
has to reset a previously memoized result from valid
I'm not sure if psalm can handle it. It would definitely be a worthwhile improvement.
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.
Thanks for the explanation.
I imagine throwing would be incredibly annoying, as manual iteration is already a complicated subject. I reckon the average PHP developer isn't familiar with the sequence of method calls to mimic a foreach
loop.
Not so much the case with our write result getters relying on isAcknowledged()
, as that's easier to wrap one's head around.
'MongoDB\Driver\Cursor::getId(): The method "MongoDB\Driver\Cursor::getId" will no longer return a "MongoDB\Driver\CursorId" instance in the future. Pass "true" as argument to change to the new behavior and receive a "MongoDB\BSON\Int64" instance instead.', | ||
$deprecations[1][1], | ||
); | ||
} |
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.
Folded into #1391 |
This pull request removes the compatibility layer introduced to handle the deprecation of
MongoDB\Driver\CursorId
. To work around psalm not having updated stubs, we introduce stubs temporarily until the stubs are properly updated.Note that due to an issue in psalm, we still need a workaround for
ChangeStreamIterator::getInnerIterator
. I've created vimeo/psalm#11100 to fix this issue, and the errors are suppressed in the baseline until a fix is released.