Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/updraftp.../vendor/guzzleht.../promises/src
File: RejectedPromise.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace GuzzleHttp\Promise;
[2] Fix | Delete
[3] Fix | Delete
/**
[4] Fix | Delete
* A promise that has been rejected.
[5] Fix | Delete
*
[6] Fix | Delete
* Thenning off of this promise will invoke the onRejected callback
[7] Fix | Delete
* immediately and ignore other callbacks.
[8] Fix | Delete
*/
[9] Fix | Delete
class RejectedPromise implements PromiseInterface
[10] Fix | Delete
{
[11] Fix | Delete
private $reason;
[12] Fix | Delete
[13] Fix | Delete
public function __construct($reason)
[14] Fix | Delete
{
[15] Fix | Delete
if (is_object($reason) && method_exists($reason, 'then')) {
[16] Fix | Delete
throw new \InvalidArgumentException(
[17] Fix | Delete
'You cannot create a RejectedPromise with a promise.'
[18] Fix | Delete
);
[19] Fix | Delete
}
[20] Fix | Delete
[21] Fix | Delete
$this->reason = $reason;
[22] Fix | Delete
}
[23] Fix | Delete
[24] Fix | Delete
public function then(
[25] Fix | Delete
callable $onFulfilled = null,
[26] Fix | Delete
callable $onRejected = null
[27] Fix | Delete
) {
[28] Fix | Delete
// If there's no onRejected callback then just return self.
[29] Fix | Delete
if (!$onRejected) {
[30] Fix | Delete
return $this;
[31] Fix | Delete
}
[32] Fix | Delete
[33] Fix | Delete
$queue = Utils::queue();
[34] Fix | Delete
$reason = $this->reason;
[35] Fix | Delete
$p = new Promise([$queue, 'run']);
[36] Fix | Delete
$queue->add(static function () use ($p, $reason, $onRejected) {
[37] Fix | Delete
if (Is::pending($p)) {
[38] Fix | Delete
try {
[39] Fix | Delete
// Return a resolved promise if onRejected does not throw.
[40] Fix | Delete
$p->resolve($onRejected($reason));
[41] Fix | Delete
} catch (\Throwable $e) {
[42] Fix | Delete
// onRejected threw, so return a rejected promise.
[43] Fix | Delete
$p->reject($e);
[44] Fix | Delete
} catch (\Exception $e) {
[45] Fix | Delete
// onRejected threw, so return a rejected promise.
[46] Fix | Delete
$p->reject($e);
[47] Fix | Delete
}
[48] Fix | Delete
}
[49] Fix | Delete
});
[50] Fix | Delete
[51] Fix | Delete
return $p;
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
public function otherwise(callable $onRejected)
[55] Fix | Delete
{
[56] Fix | Delete
return $this->then(null, $onRejected);
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
public function wait($unwrap = true, $defaultDelivery = null)
[60] Fix | Delete
{
[61] Fix | Delete
if ($unwrap) {
[62] Fix | Delete
throw Create::exceptionFor($this->reason);
[63] Fix | Delete
}
[64] Fix | Delete
[65] Fix | Delete
return null;
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
public function getState()
[69] Fix | Delete
{
[70] Fix | Delete
return self::REJECTED;
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
public function resolve($value)
[74] Fix | Delete
{
[75] Fix | Delete
throw new \LogicException("Cannot resolve a rejected promise");
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
public function reject($reason)
[79] Fix | Delete
{
[80] Fix | Delete
if ($reason !== $this->reason) {
[81] Fix | Delete
throw new \LogicException("Cannot reject a rejected promise");
[82] Fix | Delete
}
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
public function cancel()
[86] Fix | Delete
{
[87] Fix | Delete
// pass
[88] Fix | Delete
}
[89] Fix | Delete
}
[90] Fix | Delete
[91] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function