-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from php-http/phpdoc-revert
revert generic annotations
- Loading branch information
Showing
5 changed files
with
22 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,6 +69,9 @@ jobs: | |
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Remove phpspec | ||
run: composer remove --dev friends-of-phpspec/phpspec-code-coverage phpspec/phpspec | ||
|
||
- name: PHPStan | ||
uses: OskarStark/[email protected] | ||
env: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,29 +6,22 @@ | |
* A promise already fulfilled. | ||
* | ||
* @author Joel Wurtz <[email protected]> | ||
* | ||
* @template-covariant T | ||
* | ||
* @implements Promise<T> | ||
*/ | ||
final class FulfilledPromise implements Promise | ||
{ | ||
/** | ||
* @var T | ||
* @var mixed | ||
*/ | ||
private $result; | ||
|
||
/** | ||
* @param T $result | ||
* @param mixed $result | ||
*/ | ||
public function __construct($result) | ||
{ | ||
$this->result = $result; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function then(callable $onFulfilled = null, callable $onRejected = null) | ||
{ | ||
if (null === $onFulfilled) { | ||
|
@@ -42,23 +35,17 @@ public function then(callable $onFulfilled = null, callable $onRejected = null) | |
} | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getState() | ||
{ | ||
return Promise::FULFILLED; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function wait($unwrap = true) | ||
{ | ||
if ($unwrap) { | ||
return $this->result; | ||
} | ||
|
||
return; | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,6 @@ | |
* | ||
* @author Joel Wurtz <[email protected]> | ||
* @author Márk Sági-Kazár <[email protected]> | ||
* | ||
* @template-covariant T | ||
*/ | ||
interface Promise | ||
{ | ||
|
@@ -38,12 +36,10 @@ interface Promise | |
* If you do not care about one of the cases, you can set the corresponding callable to null | ||
* The callback will be called when the value arrived and never more than once. | ||
* | ||
* @param callable(T): V|null $onFulfilled called when a response will be available | ||
* @param callable(\Throwable): V|null $onRejected called when an exception occurs | ||
* | ||
* @return Promise<V> a new resolved promise with value of the executed callback (onFulfilled / onRejected) | ||
* @param callable|null $onFulfilled called when a response will be available | ||
* @param callable|null $onRejected called when an exception occurs | ||
* | ||
* @template V | ||
* @return Promise a new resolved promise with value of the executed callback (onFulfilled / onRejected) | ||
*/ | ||
public function then(callable $onFulfilled = null, callable $onRejected = null); | ||
|
||
|
@@ -65,9 +61,9 @@ public function getState(); | |
* | ||
* @param bool $unwrap Whether to return resolved value / throw reason or not | ||
* | ||
* @return ($unwrap is true ? T : null) Resolved value, null if $unwrap is set to false | ||
* @return ($unwrap is true ? mixed : null) Resolved value, null if $unwrap is set to false | ||
* | ||
* @throws \Exception the rejection reason if $unwrap is set to true and the request failed | ||
* @throws \Throwable the rejection reason if $unwrap is set to true and the request failed | ||
*/ | ||
public function wait($unwrap = true); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,26 +6,19 @@ | |
* A rejected promise. | ||
* | ||
* @author Joel Wurtz <[email protected]> | ||
* | ||
* @template-covariant T | ||
* | ||
* @implements Promise<T> | ||
*/ | ||
final class RejectedPromise implements Promise | ||
{ | ||
/** | ||
* @var \Exception | ||
* @var \Throwable | ||
*/ | ||
private $exception; | ||
|
||
public function __construct(\Exception $exception) | ||
public function __construct(\Throwable $exception) | ||
{ | ||
$this->exception = $exception; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function then(callable $onFulfilled = null, callable $onRejected = null) | ||
{ | ||
if (null === $onRejected) { | ||
|
@@ -39,23 +32,17 @@ public function then(callable $onFulfilled = null, callable $onRejected = null) | |
} | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getState() | ||
{ | ||
return Promise::REJECTED; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function wait($unwrap = true) | ||
{ | ||
if ($unwrap) { | ||
throw $this->exception; | ||
} | ||
|
||
return; | ||
return null; | ||
} | ||
} |