Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/Common/Promises.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())
);
Expand Down Expand Up @@ -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();
}
Expand Down
6 changes: 3 additions & 3 deletions src/Common/Timers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Scheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function remove(Task $task): self

$this->cancelTask($task);

$this->tasks->detach($task);
$this->tasks->offsetUnset($task);

return $this;
}
Expand Down Expand Up @@ -191,7 +191,7 @@ public function removeTasks(): self
*/
public function hasTask(Task $task): bool
{
return $this->tasks->contains($task);
return $this->tasks->offsetExists($task);
}

/**
Expand Down Expand Up @@ -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 {
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Lib/CountableScheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Loading