-
Notifications
You must be signed in to change notification settings - Fork 37
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 Typehinting #122
Remove Typehinting #122
Conversation
As a promise could return another promise
Can you give us some examples on how you faced this bug? Fulfilled promises should not receive promises, but only responses IMO. @joelwurtz is the expert on the subject though. |
In the promise repo the type hinting has been removed in fact and yes you can see a use case in this PR: Tolerance/Tolerance#91 |
It is certainly because you return an Promise inside a then callback, which is not supported in this implementation (and don't want too as it's induce a lot of complexity / code that have not this place here), so you have two choice here :
|
Yes, because there is no restriction what resolved value you put there. Removing the typehint doesn't really solve your problem, as you would still receive a promise during unwrapping (unless that's what you want). Changing THAT logic would certainly be a BC break (not sure if anyone relies of receiving promises there though). |
Ok, I don't get anything about Promise I should admit. I just confirm that this change make the code working.
Ok let's do that but how can I tell php-http client to use another Promise implementation ? |
Does it actually work and does what it should do or just stops failing with this error? 😝 I commented on the linked merge request. |
It really does the job it should ;) thanks for the review anyway ! In fact the main code involved was already merged and coded by someone else, I just try to make it ran with php-http as we only rely on this great lib in our apps. |
I have no idea how that's possible. The retirned value is not a value, it's a promise in your code. You would still have to resolve the value: |
@sagikazarmark if we have to make a double wait of that kind it means that a promise is not resolved where it should no? |
It depends on the implementation. HTTPlug promises does not support nested promises, but some Guzzle implementations does: https://github.com/guzzle/promises/blob/master/src/Promise.php#L64 What I find incredibly strange in your implementation is that you have two promises, the fullfillment is decided based on the "external" promise without checking the state of the "internal" promise here: https://github.com/Tolerance/Tolerance/pull/91/files#diff-eefafbb24a67fa568614a664524e1adcR110 As far as I can see you expect the fact that you inject Also, if I am correct we are talking about kind of an integration layer between two kinds of promises. For that I suggest you to check our integration with Guzzle 6: https://github.com/php-http/guzzle6-adapter/blob/master/src/Promise.php |
Ok, thanks for you support 👍 I will drop the async support for php-http, I guess I had no other real option. |
As done on php-http/promise I removed the reponse typehinting.
I get the error when trying to make a retry middleware :
And I just saw that guzzle implementation does not have too.