Skip to content

Commit 6d36fa6

Browse files
Replace deprecated methods of SplObjectStorage
`SplObjectStorage::contains()` => `SplObjectStorage::offsetExists()` `SplObjectStorage::attach()` => `SplObjectStorage::offsetSet()` `SplObjectStorage::detach()` => `SplObjectStorage::offsetUnset()` ref: https://www.php.net/manual/en/migration85.deprecated.php#migration85.deprecated.spl
1 parent 0396c16 commit 6d36fa6

4 files changed

Lines changed: 13 additions & 13 deletions

File tree

src/Common/Promises.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ trait Promises
3030
*/
3131
protected function addPromise(UuidInterface $uuid, PromiseInterface $promise): self
3232
{
33-
if (! $this->promises->contains($uuid)) {
34-
$this->promises->attach($uuid, new ArrayObject());
33+
if (! $this->promises->offsetExists($uuid)) {
34+
$this->promises->offsetSet($uuid, new ArrayObject());
3535
}
3636

3737
$this->promises[$uuid][] = $promise;
@@ -60,7 +60,7 @@ protected function addPromise(UuidInterface $uuid, PromiseInterface $promise): s
6060
*/
6161
protected function removePromise(UuidInterface $uuid, PromiseInterface $promise): self
6262
{
63-
if (! $this->promises->contains($uuid)) {
63+
if (! $this->promises->offsetExists($uuid)) {
6464
throw new InvalidArgumentException(
6565
sprintf('There are no registered promises for UUID %s', $uuid->toString())
6666
);
@@ -96,12 +96,12 @@ protected function removePromise(UuidInterface $uuid, PromiseInterface $promise)
9696
*/
9797
protected function detachPromises(UuidInterface $uuid): array
9898
{
99-
if (! $this->promises->contains($uuid)) {
99+
if (! $this->promises->offsetExists($uuid)) {
100100
return [];
101101
}
102102

103103
$promises = $this->promises[$uuid];
104-
$this->promises->detach($uuid);
104+
$this->promises->offsetUnset($uuid);
105105

106106
return $promises->getArrayCopy();
107107
}

src/Common/Timers.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ trait Timers
2727
*/
2828
protected function attachTimer(UuidInterface $uuid, TimerInterface $timer): self
2929
{
30-
$this->timers->attach($uuid, $timer);
30+
$this->timers->offsetSet($uuid, $timer);
3131

3232
return $this;
3333
}
@@ -47,13 +47,13 @@ protected function attachTimer(UuidInterface $uuid, TimerInterface $timer): self
4747
*/
4848
protected function detachTimer(UuidInterface $uuid): ?TimerInterface
4949
{
50-
if (! $this->timers->contains($uuid)) {
50+
if (! $this->timers->offsetExists($uuid)) {
5151
return null;
5252
}
5353

5454
$timer = $this->timers->offsetGet($uuid);
5555

56-
$this->timers->detach($uuid);
56+
$this->timers->offsetUnset($uuid);
5757

5858
return $timer;
5959
}

src/Scheduler.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public function remove(Task $task): self
161161

162162
$this->cancelTask($task);
163163

164-
$this->tasks->detach($task);
164+
$this->tasks->offsetUnset($task);
165165

166166
return $this;
167167
}
@@ -191,7 +191,7 @@ public function removeTasks(): self
191191
*/
192192
public function hasTask(Task $task): bool
193193
{
194-
return $this->tasks->contains($task);
194+
return $this->tasks->offsetExists($task);
195195
}
196196

197197
/**
@@ -233,7 +233,7 @@ public function schedule(Task $task, Frequency $frequency): self
233233
$this->emit(static::ON_TASK_EXPIRED, [$task, $nextDue]);
234234
};
235235

236-
if ($this->promises->contains($task->getUuid())) {
236+
if ($this->promises->offsetExists($task->getUuid())) {
237237
$pendingPromises = (array) $this->promises->offsetGet($task->getUuid());
238238
Promise\all($pendingPromises)->always($removeTask);
239239
} else {
@@ -257,7 +257,7 @@ public function schedule(Task $task, Frequency $frequency): self
257257
);
258258
$this->emit(static::ON_TASK_SCHEDULED, [$task, $nextDue]);
259259

260-
$this->tasks->attach($task);
260+
$this->tasks->offsetSet($task);
261261

262262
return $this;
263263
}

tests/Lib/CountableScheduler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function count(): int
1515

1616
public function countPromises(UuidInterface $uuid): int
1717
{
18-
if (! $this->promises->contains($uuid)) {
18+
if (! $this->promises->offsetExists($uuid)) {
1919
return 0;
2020
}
2121

0 commit comments

Comments
 (0)