diff --git a/src/Common/Promises.php b/src/Common/Promises.php index b896627..2b93290 100644 --- a/src/Common/Promises.php +++ b/src/Common/Promises.php @@ -30,8 +30,8 @@ trait Promises */ protected function addPromise(UuidInterface $uuid, PromiseInterface $promise): self { - if (! $this->promises->contains($uuid)) { - $this->promises->attach($uuid, new ArrayObject()); + if (! $this->promises->offsetExists($uuid)) { + $this->promises->offsetSet($uuid, new ArrayObject()); } $this->promises[$uuid][] = $promise; @@ -60,7 +60,7 @@ protected function addPromise(UuidInterface $uuid, PromiseInterface $promise): s */ protected function removePromise(UuidInterface $uuid, PromiseInterface $promise): self { - if (! $this->promises->contains($uuid)) { + if (! $this->promises->offsetExists($uuid)) { throw new InvalidArgumentException( sprintf('There are no registered promises for UUID %s', $uuid->toString()) ); @@ -96,12 +96,12 @@ protected function removePromise(UuidInterface $uuid, PromiseInterface $promise) */ protected function detachPromises(UuidInterface $uuid): array { - if (! $this->promises->contains($uuid)) { + if (! $this->promises->offsetExists($uuid)) { return []; } $promises = $this->promises[$uuid]; - $this->promises->detach($uuid); + $this->promises->offsetUnset($uuid); return $promises->getArrayCopy(); } diff --git a/src/Common/Timers.php b/src/Common/Timers.php index 2d0641f..325919b 100644 --- a/src/Common/Timers.php +++ b/src/Common/Timers.php @@ -27,7 +27,7 @@ trait Timers */ protected function attachTimer(UuidInterface $uuid, TimerInterface $timer): self { - $this->timers->attach($uuid, $timer); + $this->timers->offsetSet($uuid, $timer); return $this; } @@ -47,13 +47,13 @@ protected function attachTimer(UuidInterface $uuid, TimerInterface $timer): self */ protected function detachTimer(UuidInterface $uuid): ?TimerInterface { - if (! $this->timers->contains($uuid)) { + if (! $this->timers->offsetExists($uuid)) { return null; } $timer = $this->timers->offsetGet($uuid); - $this->timers->detach($uuid); + $this->timers->offsetUnset($uuid); return $timer; } diff --git a/src/Scheduler.php b/src/Scheduler.php index 25ad3a1..d32d25e 100644 --- a/src/Scheduler.php +++ b/src/Scheduler.php @@ -161,7 +161,7 @@ public function remove(Task $task): self $this->cancelTask($task); - $this->tasks->detach($task); + $this->tasks->offsetUnset($task); return $this; } @@ -191,7 +191,7 @@ public function removeTasks(): self */ public function hasTask(Task $task): bool { - return $this->tasks->contains($task); + return $this->tasks->offsetExists($task); } /** @@ -233,7 +233,7 @@ public function schedule(Task $task, Frequency $frequency): self $this->emit(static::ON_TASK_EXPIRED, [$task, $nextDue]); }; - if ($this->promises->contains($task->getUuid())) { + if ($this->promises->offsetExists($task->getUuid())) { $pendingPromises = (array) $this->promises->offsetGet($task->getUuid()); Promise\all($pendingPromises)->always($removeTask); } else { @@ -257,7 +257,7 @@ public function schedule(Task $task, Frequency $frequency): self ); $this->emit(static::ON_TASK_SCHEDULED, [$task, $nextDue]); - $this->tasks->attach($task); + $this->tasks->offsetSet($task); return $this; } diff --git a/tests/Lib/CountableScheduler.php b/tests/Lib/CountableScheduler.php index 52c3929..ae41c78 100644 --- a/tests/Lib/CountableScheduler.php +++ b/tests/Lib/CountableScheduler.php @@ -15,7 +15,7 @@ public function count(): int public function countPromises(UuidInterface $uuid): int { - if (! $this->promises->contains($uuid)) { + if (! $this->promises->offsetExists($uuid)) { return 0; }