Skip to content

Add type hinting to wait function #1

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

Merged
merged 1 commit into from
Dec 13, 2015
Merged

Conversation

joelwurtz
Copy link
Member

IMO, we should force the type hinting of the wait method.

There is some reason to that :

  1. The wait method will probably never be in a PSR so there is probably no BC break upcoming for that
  2. Not having this type hinting will mean we allow everything as the value fulfilled / reason, which will induce in every package to check that the return type / reason is correct

WDYT ?

@sagikazarmark
Copy link
Member

The wait method will probably never be in a PSR so there is probably no BC break upcoming for that

Why is that?

Not having this type hinting will mean we allow everything as the value fulfilled / reason, which will induce in every package to check that the return type / reason is correct

What will happen, if we switch to a PSR?

@joelwurtz
Copy link
Member Author

Why is that?

Because they will probably say that a promise should use an Event Loop, and by using an event loop you don't need the wait method.

What will happen, if we switch to a PSR?

Provide a compatibilty layer, otherwise we will have to do something like the follwing everywhere we use the value / reason of a promise :

$value = $promise->wait();

if (!$value instanceof ResponseInterface) {
    throw new UnexpectedValueException();
}

@sagikazarmark
Copy link
Member

Because they will probably say that a promise should use an Event Loop

I will fight four our wait method.

The promises are actually used INSIDE our libraries now and in case of a PSR, which means the chance of having an invalid value is exactly the same as we would use a PSR Promise implementation. But I am fine with that.

@joelwurtz
Copy link
Member Author

Yeah but if there is a promise PSR having some sort of layer to fix the type hinting would be nice also to avoid duplicate this work everywhere (like a decorated promise with a specific interface). The point here is we use the promise in the context of an http call.

Having something too generic does not relly make sense and imply too many work IMO.

sagikazarmark added a commit that referenced this pull request Dec 13, 2015
Add type hinting to wait function
@sagikazarmark sagikazarmark merged commit fbb2cf6 into master Dec 13, 2015
@sagikazarmark sagikazarmark deleted the feature/type-hinting branch December 13, 2015 11:07
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.

2 participants