reactphp / promise

Promises/A implementation for PHP.
https://reactphp.org/promise/
MIT License
2.38k stars 146 forks source link

Narrow down docblock type of Deferred::promise #156

Closed Gert-dev closed 4 years ago

Gert-dev commented 4 years ago

The interface indicates it returns a PromiseInterface, but the implementation returns a Promise, which also implements ExtendedPromiseInterface.

Calling Deferred::promise() will make PHPStan complain if you need to return an ExtendedPromiseInterface, as it cannot deduce that it does indeed return it from the implementation alone.

This should also aid autocompletion in IDEs.

Gert-dev commented 4 years ago

I didn't consider that, but you are right; it is a subtle BC break.

I see that you indeed added PromiseInterface on the master branch and the ExtendedPromiseInterface doesn't appear to exist anymore, so this becomes a nonissue there. I'll close this pull request in that case, thanks!