From 7cb09edf292ebc3f7d910f49914099bd5addb80d Mon Sep 17 00:00:00 2001 From: Daniel Lowrey Date: Mon, 27 Apr 2015 14:33:17 -0400 Subject: [PATCH] Use anonymous classes --- lib/NativeReactor.php | 13 ------------- lib/UvReactor.php | 20 -------------------- lib/functions.php | 4 ---- 3 files changed, 37 deletions(-) diff --git a/lib/NativeReactor.php b/lib/NativeReactor.php index b1d40af..659f0cd 100644 --- a/lib/NativeReactor.php +++ b/lib/NativeReactor.php @@ -256,9 +256,6 @@ class NativeReactor implements Reactor { public function once(callable $callback, int $msDelay, array $options = []): string { assert(($msDelay >= 0), "\$msDelay at Argument 2 expects integer >= 0"); - // @TODO Replace stdclass with anon class once merged into php-src/master - $watcher = new \StdClass; - /* $watcher = new class extends Watcher { // Inherited: // public $id; @@ -269,7 +266,6 @@ class NativeReactor implements Reactor { public $msDelay; public $nextExecutionAt; } - */ $watcher->id = $watcherId = $this->lastWatcherId++; $watcher->type = Watcher::TIMER_ONCE; @@ -301,9 +297,6 @@ class NativeReactor implements Reactor { $msDelay = $options["msDelay"] ?? $msInterval; assert(($msDelay >= 0), "msDelay option expects integer >= 0"); - // @TODO Replace stdclass with anon class once merged into php-src/master - $watcher = new \StdClass; - /* $watcher = new class extends Watcher { // Inherited: // public $id; @@ -315,7 +308,6 @@ class NativeReactor implements Reactor { public $msInterval; public $nextExecutionAt; } - */ $watcher->id = $watcherId = $this->lastWatcherId++; $watcher->type = Watcher::TIMER_REPEAT; @@ -355,9 +347,6 @@ class NativeReactor implements Reactor { } private function registerIoWatcher($stream, $callback, $options, $type): string { - // @TODO Replace stdclass with anon class once merged into php-src/master - $watcher = new \StdClass; - /* $watcher = new class extends Watcher { // Inherited: // public $id; @@ -368,7 +357,6 @@ class NativeReactor implements Reactor { public $streamId; public $stream; } - */ $watcher->id = $watcherId = $this->lastWatcherId++; $watcher->type = $type; @@ -405,7 +393,6 @@ class NativeReactor implements Reactor { * {@inheritDoc} */ public function enable(string $watcherId) { - // @TODO should this throw? if (!isset($this->watchers[$watcherId])) { return; } diff --git a/lib/UvReactor.php b/lib/UvReactor.php index 97a13ee..c3a6911 100644 --- a/lib/UvReactor.php +++ b/lib/UvReactor.php @@ -130,9 +130,6 @@ class UvReactor implements SignalReactor { * {@inheritDoc} */ public function immediately(callable $callback, array $options = []): string { - // @TODO Replace stdclass with anon class once merged into php-src/master - $watcher = new \StdClass; - /* $watcher = new class extends Watcher { // Inherited: // public $id; @@ -143,7 +140,6 @@ class UvReactor implements SignalReactor { public $msDelay; public $nextExecutionAt; } - */ $watcher->id = $watcherId = $this->lastWatcherId++; $watcher->type = Watcher::IMMEDIATE; @@ -189,9 +185,6 @@ class UvReactor implements SignalReactor { private function registerTimer(callable $callback, int $msDelay, int $msInterval, array $options): string { $this->enabledWatcherCount++; - // @TODO Replace stdclass with anon class once merged into php-src/master - $watcher = new \StdClass; - /* $watcher = new class extends Watcher { // Inherited: // public $id; @@ -203,7 +196,6 @@ class UvReactor implements SignalReactor { public $msDelay; public $msInterval; }; - */ $isRepeating = ($msInterval !== -1); @@ -273,9 +265,6 @@ class UvReactor implements SignalReactor { } private function watchStream($stream, callable $callback, int $type, array $options): string { - // @TODO Replace stdclass with anon class once merged into php-src/master - $watcher = new \StdClass; - /* $watcher = new class extends Watcher { // Inherited: // public $id; @@ -288,7 +277,6 @@ class UvReactor implements SignalReactor { public $streamId; }; - */ $this->watchers[$watcherId] = $watcher; @@ -341,9 +329,6 @@ class UvReactor implements SignalReactor { $streamId = (int) $stream; - // @TODO Replace stdclass with anon class once merged into php-src/master - $poll = new \StdClass; - /* $poll = new class { use Struct; public $flags; @@ -353,7 +338,6 @@ class UvReactor implements SignalReactor { public $writers = []; public $disable = []; }; - */ $this->streamIdPollMap[$streamId] = $poll; $poll->flags = 0; @@ -397,9 +381,6 @@ class UvReactor implements SignalReactor { * {@inheritDoc} */ public function onSignal(int $signo, callable $func, array $options = []): string { - // @TODO Replace stdclass with anon class once merged into php-src/master - $watcher = new \StdClass; - /* $watcher = new class extends Watcher { // Inherited: // public $id; @@ -410,7 +391,6 @@ class UvReactor implements SignalReactor { public $signo; public $uvHandle; }; - */ $watcher->id = $watcherId = $this->lastWatcherId++; $watcher->type = Watcher::SIGNAL; $watcher->callback = $this->wrapSignalCallback($watcher, $func); diff --git a/lib/functions.php b/lib/functions.php index e1cd50a..2262752 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -479,9 +479,6 @@ function coroutine(callable $func, Reactor $reactor = null, callable $promisifie * error occurs during coroutine resolution the promise fails. */ function resolve(\Generator $generator, Reactor $reactor = null, callable $promisifier = null): Promise { - // @TODO Replace stdclass with anon class once merged into php-src - $cs = new \StdClass; - /* $cs = new class { use Struct; public $reactor; @@ -489,7 +486,6 @@ function resolve(\Generator $generator, Reactor $reactor = null, callable $promi public $generator; public $promisifier; }; - */ $cs->reactor = $reactor ?: getReactor(); $cs->promisor = new Future; $cs->generator = $generator;