Skip to content

Commit 2916a60

Browse files
committed
revert generic annotations
1 parent 44a67cb commit 2916a60

File tree

5 files changed

+22
-43
lines changed

5 files changed

+22
-43
lines changed

Diff for: .github/workflows/tests.yml

+3
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ jobs:
6969
- name: Checkout code
7070
uses: actions/checkout@v3
7171

72+
- name: Remove phpspec
73+
run: composer remove --dev friends-of-phpspec/phpspec-code-coverage phpspec/phpspec
74+
7275
- name: PHPStan
7376
uses: OskarStark/[email protected]
7477
env:

Diff for: CHANGELOG.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
# Change Log
22

3-
## 1.2.1
3+
## 1.3.0 - 2024-01-04
44

5-
### Added - 2023-11-08
5+
### Fixed
6+
7+
- Reverted generic annotations on promise - as `then` returns another promise, there seems no way to properly document this.
8+
9+
## 1.2.1 - 2023-11-08
10+
11+
### Added
612

713
- Fixed PHPDoc for `wait()` and `then()`'s `onRejected` callable
814

Diff for: src/FulfilledPromise.php

+3-16
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,22 @@
66
* A promise already fulfilled.
77
*
88
* @author Joel Wurtz <[email protected]>
9-
*
10-
* @template-covariant T
11-
*
12-
* @implements Promise<T>
139
*/
1410
final class FulfilledPromise implements Promise
1511
{
1612
/**
17-
* @var T
13+
* @var mixed
1814
*/
1915
private $result;
2016

2117
/**
22-
* @param T $result
18+
* @param mixed $result
2319
*/
2420
public function __construct($result)
2521
{
2622
$this->result = $result;
2723
}
2824

29-
/**
30-
* {@inheritdoc}
31-
*/
3225
public function then(callable $onFulfilled = null, callable $onRejected = null)
3326
{
3427
if (null === $onFulfilled) {
@@ -42,23 +35,17 @@ public function then(callable $onFulfilled = null, callable $onRejected = null)
4235
}
4336
}
4437

45-
/**
46-
* {@inheritdoc}
47-
*/
4838
public function getState()
4939
{
5040
return Promise::FULFILLED;
5141
}
5242

53-
/**
54-
* {@inheritdoc}
55-
*/
5643
public function wait($unwrap = true)
5744
{
5845
if ($unwrap) {
5946
return $this->result;
6047
}
6148

62-
return;
49+
return null;
6350
}
6451
}

Diff for: src/Promise.php

+5-9
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
*
1313
* @author Joel Wurtz <[email protected]>
1414
* @author Márk Sági-Kazár <[email protected]>
15-
*
16-
* @template-covariant T
1715
*/
1816
interface Promise
1917
{
@@ -38,12 +36,10 @@ interface Promise
3836
* If you do not care about one of the cases, you can set the corresponding callable to null
3937
* The callback will be called when the value arrived and never more than once.
4038
*
41-
* @param callable(T): V|null $onFulfilled called when a response will be available
42-
* @param callable(\Throwable): V|null $onRejected called when an exception occurs
43-
*
44-
* @return Promise<V> a new resolved promise with value of the executed callback (onFulfilled / onRejected)
39+
* @param callable|null $onFulfilled called when a response will be available
40+
* @param callable|null $onRejected called when an exception occurs
4541
*
46-
* @template V
42+
* @return Promise a new resolved promise with value of the executed callback (onFulfilled / onRejected)
4743
*/
4844
public function then(callable $onFulfilled = null, callable $onRejected = null);
4945

@@ -65,9 +61,9 @@ public function getState();
6561
*
6662
* @param bool $unwrap Whether to return resolved value / throw reason or not
6763
*
68-
* @return ($unwrap is true ? T : null) Resolved value, null if $unwrap is set to false
64+
* @return ($unwrap is true ? mixed : null) Resolved value, null if $unwrap is set to false
6965
*
70-
* @throws \Exception the rejection reason if $unwrap is set to true and the request failed
66+
* @throws \Throwable the rejection reason if $unwrap is set to true and the request failed
7167
*/
7268
public function wait($unwrap = true);
7369
}

Diff for: src/RejectedPromise.php

+3-16
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,19 @@
66
* A rejected promise.
77
*
88
* @author Joel Wurtz <[email protected]>
9-
*
10-
* @template-covariant T
11-
*
12-
* @implements Promise<T>
139
*/
1410
final class RejectedPromise implements Promise
1511
{
1612
/**
17-
* @var \Exception
13+
* @var \Throwable
1814
*/
1915
private $exception;
2016

21-
public function __construct(\Exception $exception)
17+
public function __construct(\Throwable $exception)
2218
{
2319
$this->exception = $exception;
2420
}
2521

26-
/**
27-
* {@inheritdoc}
28-
*/
2922
public function then(callable $onFulfilled = null, callable $onRejected = null)
3023
{
3124
if (null === $onRejected) {
@@ -39,23 +32,17 @@ public function then(callable $onFulfilled = null, callable $onRejected = null)
3932
}
4033
}
4134

42-
/**
43-
* {@inheritdoc}
44-
*/
4535
public function getState()
4636
{
4737
return Promise::REJECTED;
4838
}
4939

50-
/**
51-
* {@inheritdoc}
52-
*/
5340
public function wait($unwrap = true)
5441
{
5542
if ($unwrap) {
5643
throw $this->exception;
5744
}
5845

59-
return;
46+
return null;
6047
}
6148
}

0 commit comments

Comments
 (0)