Add then method to ExtendedPromiseInterface#137
Add then method to ExtendedPromiseInterface#137psafarov wants to merge 1 commit intoreactphp:2.xfrom psafarov:2.x
then method to ExtendedPromiseInterface#137Conversation
|
To be perfectly honest I'm not sure what has to be fixed here since |
|
@WyriHaximus, the problem is, the return type of function test(ExtendedPromiseInterface $promise) {
$promise2 = $promise->then(...);
// oops, static type check tells us that `otherwise` method is undefined,
// as $promise2 is an instance of `PromiseInterface`
$promise2->otherwise(...);
}In this example I assigned result of function test(ExtendedPromiseInterface $promise) {
// neither `otherwise` nor `done` are recognized during static type check
$promise->then(...)->otherwise(...)->done(...);
} |
|
Ah yes that makes sense, wouldnt't changing the return type to |
|
That was the first thing I did. Unfortunately it didn't fix the problem for PhpStorm, so I went with this solution. It will be understandable if this PR will be rejected, but at least |
In it's current state yes, but I rather focus on finding a solution first and preferably update this PR 😄 . Let me have a look at it as well |
|
PR is updated. |
|
@psafarov Thanks for reporting, that's an interesting issue and I can see where you're coming from! 👍 That being said, while I do agree that the current type definition is inaccurate, I'm not sure this is something we can address in a minor release without a BC break. The updated type definition is technically a BC break that consumers of this package could possibly miss when using custom implementations of said interfaces. This has been addressed via #75 for the upcoming v3.0 release, so we may as well document this as a known limitation for the current version. What do you think? 👍 |
|
@clue isn't |
|
@psafarov It's my understanding |
|
I see, that means my change doesn't help in any way. And using |
Fixes return type for
thenmethod in ExtendedPromiseInterface