mirror of
https://github.com/danog/amp.git
synced 2024-11-26 20:15:00 +01:00
Use Closure::fromCallable() in 7.1
This commit is contained in:
parent
aa7b76e842
commit
658edf33f7
@ -11,14 +11,13 @@ final class Emitter implements Observable {
|
||||
public function __construct(callable $emitter) {
|
||||
$this->init();
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return \Interop\Async\Awaitable
|
||||
*/
|
||||
$emit = function ($value) {
|
||||
return $this->emit($value);
|
||||
};
|
||||
if (PHP_VERSION_ID >= 70100) {
|
||||
$emit = \Closure::fromCallable([$this, 'emit']);
|
||||
} else {
|
||||
$emit = function ($value) {
|
||||
return $this->emit($value);
|
||||
};
|
||||
}
|
||||
|
||||
$result = $emitter($emit);
|
||||
|
||||
|
@ -50,9 +50,14 @@ trait Producer {
|
||||
*/
|
||||
private function init() {
|
||||
$this->waiting = new Future;
|
||||
$this->unsubscribe = function ($id) {
|
||||
$this->unsubscribe($id);
|
||||
};
|
||||
|
||||
if (PHP_VERSION_ID >= 70100) {
|
||||
$this->unsubscribe = \Closure::fromCallable([$this, 'unsubscribe']);
|
||||
} else {
|
||||
$this->unsubscribe = function ($id) {
|
||||
$this->unsubscribe($id);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user