Skip to content
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

PHPC-2140: Make tentative return types definitive #1658

Merged
merged 4 commits into from
Sep 19, 2024

Conversation

alcaeus
Copy link
Member

@alcaeus alcaeus commented Sep 17, 2024

PHPC-2140

This PR removes the @tentative-return-type annotation in all stub files, making the return types definitive and causing errors if an extending or implementing class does not have a covariant return type.

It also changes the return types for various methods in MongoDB\Driver\Manager and MongoDB\Driver\Server from Cursor to CursorInterface.

Note: currently contains changes from #1653 to avoid fixing tests that will be removed.

@alcaeus alcaeus force-pushed the phpc-2140-return-types branch 3 times, most recently from 4aebdee to fc1f63f Compare September 18, 2024 13:57
@alcaeus alcaeus marked this pull request as ready for review September 18, 2024 13:58
@@ -9,18 +9,17 @@

interface CursorInterface extends \Iterator
{
/** @tentative-return-type */
public function current(): array|object|null {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I assume correctly that only current() and key() are included here because those are the only methods where we'd narrowing the return type from the parent interface?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This methods are mentioned in the upgrade file:

The return types for the key and current methods have been narrowed to the types returned by cursor instances.

@alcaeus alcaeus enabled auto-merge (squash) September 19, 2024 05:48
@alcaeus alcaeus merged commit 26a503a into mongodb:v2.x Sep 19, 2024
58 of 62 checks passed
@alcaeus alcaeus deleted the phpc-2140-return-types branch September 19, 2024 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants