2016-12-29 14:09:49 -06:00
|
|
|
<?php
|
2016-08-15 23:46:26 -05:00
|
|
|
|
2016-05-23 22:48:28 -05:00
|
|
|
namespace Amp\Internal;
|
2016-05-21 09:44:52 -05:00
|
|
|
|
2017-01-07 12:24:40 -06:00
|
|
|
use Amp\CallableMaker;
|
2017-03-10 21:58:46 +01:00
|
|
|
use Amp\Promise;
|
2016-05-21 09:44:52 -05:00
|
|
|
|
|
|
|
/**
|
2017-03-12 17:05:52 +01:00
|
|
|
* A promise that cannot be externally resolved. Used by Deferred in development mode.
|
2016-06-01 12:18:11 -05:00
|
|
|
*
|
|
|
|
* @internal
|
2016-05-21 09:44:52 -05:00
|
|
|
*/
|
2016-11-14 13:59:21 -06:00
|
|
|
final class PrivatePromise implements Promise {
|
2017-01-07 12:24:40 -06:00
|
|
|
use CallableMaker, Placeholder;
|
2016-05-21 09:44:52 -05:00
|
|
|
|
|
|
|
/**
|
2017-03-10 21:58:46 +01:00
|
|
|
* @param callable (callable $resolve, callable $reject): void $resolver
|
2016-05-21 09:44:52 -05:00
|
|
|
*/
|
|
|
|
public function __construct(callable $resolver) {
|
2017-01-07 12:24:40 -06:00
|
|
|
$resolver(
|
|
|
|
$this->callableFromInstanceMethod("resolve"),
|
|
|
|
$this->callableFromInstanceMethod("fail")
|
|
|
|
);
|
2016-05-21 09:44:52 -05:00
|
|
|
}
|
|
|
|
}
|