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

Added support for ReactPHP Promise v3 #53

Closed
wants to merge 9 commits into from

Conversation

davidcole1340
Copy link
Contributor

@davidcole1340 davidcole1340 commented Feb 23, 2021

Unit tests are passing, can test by changing react/promise version to dev-master at 2.9.9.

@davidcole1340 davidcole1340 marked this pull request as ready for review February 23, 2021 00:33
Copy link
Owner

@clue clue left a comment

Choose a reason for hiding this comment

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

@davidcole1340 Thanks for looking into this! I like the direction this is heading and only added some minor remarks below 👍

if ($promise instanceof CancellablePromiseInterface) {
$promise->cancel();
if ($promise instanceof PromiseInterface) {
Promise\resolve($promise)->cancel();
Copy link
Owner

Choose a reason for hiding this comment

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

Interesting! I see why this was done, but it looks like static analysis complains about this because resolve() has a PromiseInterface return type for Promise v2 and Promise v1.

Perhaps use logic similar to https://github.com/reactphp/promise-timer/pull/37/files#diff-fe65dcdace9cc44252b537bee79dd574edd1bccf6cee646cc860006a6ec50e8bR15? /cc @WyriHaximus

What do you think about this?

Choose a reason for hiding this comment

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

Perhaps use logic similar to https://github.com/reactphp/promise-timer/pull/37/files#diff-fe65dcdace9cc44252b537bee79dd574edd1bccf6cee646cc860006a6ec50e8bR15? /cc @WyriHaximus

That is the preferred way, making it more explicit, and more performant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I thought so, had this initially but changed it due to this comment. I'll change it back as it's more lightweight.

@@ -34,8 +34,10 @@ public function testAwaitAllRejected()
Block\awaitAll($all, $this->loop);
}

public function testAwaitAllRejectedWithFalseWillWrapInUnexpectedValueException()
public function testAwaitAllRejectedWithExceptionWillWrapInUnexpectedValueException()
Copy link
Owner

Choose a reason for hiding this comment

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

It looks like the name should not have been changed as the logic didn't actually change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops - accident!

{
$this->skipForPromise3();
Copy link
Owner

Choose a reason for hiding this comment

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

I see why you've decided to add a helper method for this, but I wonder if it could be more descriptive if we added a reason each time? What do you think? See also all following occurrences.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a reason parameter for the function to pass through when skipping the test

@@ -18,7 +18,7 @@ public function testAwaitAnyEmpty()
public function testAwaitAnyFirstResolved()
{
$all = array(
$this->createPromiseRejected(1),
$this->createPromiseRejected(new \Exception(1)),
Copy link
Owner

Choose a reason for hiding this comment

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

Minor nit only: First argument is a string instead of an int. See also all following occurrences.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Assuming you mean about the first argument of Exception taking a string? I've changed these to strings now.

@clue clue added this to the v1.5.0 milestone Feb 25, 2021
@davidcole1340 davidcole1340 requested a review from clue February 27, 2021 05:42
@SimonFrings
Copy link
Contributor

Thanks for all the work on this PR so far @davidcole1340.
I talked with @clue about this and your changes are looking good, besides some minor clean up.

We have a new version for reactphp/block coming up soon, that's why I am opening a following PR building on top of this one. In there I just squash a bunch of commits together, so we can merge and close both of these 👍

@clue clue closed this in #61 Oct 19, 2021
@clue clue removed this from the v1.5.0 milestone Oct 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants