diff --git a/lib/Emitter.php b/lib/Emitter.php index b2a60ce..5e07407 100644 --- a/lib/Emitter.php +++ b/lib/Emitter.php @@ -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); diff --git a/lib/Internal/Producer.php b/lib/Internal/Producer.php index e46ab68..f56cccd 100644 --- a/lib/Internal/Producer.php +++ b/lib/Internal/Producer.php @@ -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); + }; + } } /**