1
0
mirror of https://github.com/danog/amp.git synced 2024-11-27 04:24:42 +01:00

Use Closure::fromCallable() in 7.1

This commit is contained in:
Aaron Piotrowski 2016-08-11 13:33:51 -05:00
parent aa7b76e842
commit 658edf33f7
2 changed files with 15 additions and 11 deletions

View File

@ -11,14 +11,13 @@ final class Emitter implements Observable {
public function __construct(callable $emitter) { public function __construct(callable $emitter) {
$this->init(); $this->init();
/** if (PHP_VERSION_ID >= 70100) {
* @param mixed $value $emit = \Closure::fromCallable([$this, 'emit']);
* } else {
* @return \Interop\Async\Awaitable $emit = function ($value) {
*/ return $this->emit($value);
$emit = function ($value) { };
return $this->emit($value); }
};
$result = $emitter($emit); $result = $emitter($emit);

View File

@ -50,9 +50,14 @@ trait Producer {
*/ */
private function init() { private function init() {
$this->waiting = new Future; $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);
};
}
} }
/** /**