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

Add generics for Promise. #1170

Closed
wants to merge 39 commits into from
Closed
Changes from 2 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
32b4f1d
Add generics
Warxcell Nov 29, 2022
0b65301
Apply php-cs-fixer changes
Warxcell Nov 29, 2022
d15eea5
Update src/Executor/Promise/Promise.php
Warxcell Nov 29, 2022
d5fa644
Add generics
Warxcell Nov 30, 2022
77b7e84
Prettify docs
Warxcell Nov 30, 2022
2b6c898
Add generics
Warxcell Nov 30, 2022
1121827
Apply php-cs-fixer changes
Warxcell Nov 30, 2022
abd57fe
Add generics
Warxcell Nov 30, 2022
032ed9f
Prettify docs
Warxcell Nov 30, 2022
9c9323b
Add generics
Warxcell Nov 30, 2022
9e26ed2
Prettify docs
Warxcell Nov 30, 2022
ca0812a
Add generics
Warxcell Dec 2, 2022
78a442f
Apply php-cs-fixer changes
Warxcell Dec 2, 2022
f0f32c5
Update src/Executor/Promise/PromiseAdapter.php
Warxcell Dec 14, 2022
7aa1041
Prettify docs
Warxcell Dec 14, 2022
923bfc8
Update src/Executor/Promise/Adapter/SyncPromiseAdapter.php
Warxcell Dec 14, 2022
85e0377
Add generics
Warxcell Dec 14, 2022
dddbb7f
Prettify docs
Warxcell Dec 14, 2022
af10463
Add generics
Warxcell Dec 14, 2022
1b31ae6
Apply php-cs-fixer changes
Warxcell Dec 14, 2022
b560281
Add generics
Warxcell Dec 14, 2022
4e03770
Prettify docs
Warxcell Dec 14, 2022
9e2f954
Add generics
Warxcell Dec 14, 2022
d8f5830
Apply php-cs-fixer changes
Warxcell Dec 14, 2022
70e342b
Merge branch 'master' into generics-for-promise
spawnia Dec 19, 2022
61561a3
restore iterable interface
spawnia Dec 19, 2022
820d73c
improve ReactPromiseAdapterTest.php
spawnia Dec 19, 2022
506834b
minimize diff in SyncPromise
spawnia Dec 19, 2022
0f34cf3
improve phpdoc in PromiseAdapter.php
spawnia Dec 19, 2022
50a6a8f
improve whitespace in Helper.php
spawnia Dec 19, 2022
5382360
Merge branch 'master' into generics-for-promise
spawnia Dec 19, 2022
2a1e365
fully qualified throwable
spawnia Dec 19, 2022
d796e4a
Prettify docs
spawnia Dec 19, 2022
c7fdf5c
remove unnecessary generic
spawnia Dec 19, 2022
1b42a7b
Merge remote-tracking branch 'upstream/master'
Warxcell Dec 19, 2022
a6212de
Add generics
Warxcell Dec 20, 2022
fecb03e
Apply php-cs-fixer changes
Warxcell Dec 20, 2022
531e03b
...
Warxcell Jan 4, 2023
56796ea
Apply php-cs-fixer changes
Warxcell Jan 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/Executor/Promise/Promise.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

/**
* Convenience wrapper for promises represented by Promise Adapter.
*
* @template T
Warxcell marked this conversation as resolved.
Show resolved Hide resolved
*/
class Promise
{
Expand All @@ -30,6 +32,19 @@ public function __construct($adoptedPromise, PromiseAdapter $adapter)
$this->adapter = $adapter;
}

/**
* @template TFulfilled of mixed
* @template TRejected of mixed
Warxcell marked this conversation as resolved.
Show resolved Hide resolved
*
* @param (callable(T): (Promise<TFulfilled>|TFulfilled))|null $onFulfilled
* @param (callable(mixed): (Promise<TRejected>|TRejected))|null $onRejected
*
* @return Promise<(
* $onFulfilled is not null
* ? ($onRejected is not null ? TFulfilled|TRejected : TFulfilled)
* : ($onRejected is not null ? TRejected : T)
* )>
*/
public function then(?callable $onFulfilled = null, ?callable $onRejected = null): Promise
{
return $this->adapter->then($this, $onFulfilled, $onRejected);
Expand Down