This commit is contained in:
2025-03-21 20:24:43 +01:00
parent 224398df90
commit f34c9162d4
12427 changed files with 5329941 additions and 373384 deletions

View File

@@ -6,16 +6,20 @@ namespace Http\Promise;
* A promise already fulfilled.
*
* @author Joel Wurtz <joel.wurtz@gmail.com>
*
* @template-covariant T
*
* @implements Promise<T>
*/
final class FulfilledPromise implements Promise
{
/**
* @var mixed
* @var T
*/
private $result;
/**
* @param $result
* @param T $result
*/
public function __construct($result)
{

View File

@@ -12,6 +12,8 @@ namespace Http\Promise;
*
* @author Joel Wurtz <joel.wurtz@gmail.com>
* @author Márk Sági-Kazár <mark.sagikazar@gmail.com>
*
* @template-covariant T
*/
interface Promise
{
@@ -36,10 +38,12 @@ 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|null $onFulfilled called when a response will be available
* @param callable|null $onRejected called when an exception occurs
* @param callable(T): V|null $onFulfilled called when a response will be available
* @param callable(\Exception): V|null $onRejected called when an exception occurs
*
* @return Promise a new resolved promise with value of the executed callback (onFulfilled / onRejected)
* @return Promise<V> a new resolved promise with value of the executed callback (onFulfilled / onRejected)
*
* @template V
*/
public function then(callable $onFulfilled = null, callable $onRejected = null);
@@ -61,7 +65,7 @@ interface Promise
*
* @param bool $unwrap Whether to return resolved value / throw reason or not
*
* @return mixed Resolved value, null if $unwrap is set to false
* @return T Resolved value, null if $unwrap is set to false
*
* @throws \Exception the rejection reason if $unwrap is set to true and the request failed
*/

View File

@@ -6,6 +6,10 @@ namespace Http\Promise;
* A rejected promise.
*
* @author Joel Wurtz <joel.wurtz@gmail.com>
*
* @template-covariant T
*
* @implements Promise<T>
*/
final class RejectedPromise implements Promise
{
@@ -14,9 +18,6 @@ final class RejectedPromise implements Promise
*/
private $exception;
/**
* @param \Exception $exception
*/
public function __construct(\Exception $exception)
{
$this->exception = $exception;