Skip to content

Commit 695b669

Browse files
committed
[Performance] Use spl_object_id() when possible
1 parent f665998 commit 695b669

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Timer/Timers.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function getTime()
3838

3939
public function add(TimerInterface $timer)
4040
{
41-
$id = \spl_object_hash($timer);
41+
$id = \PHP_VERSION_ID < 70200 ? \spl_object_hash($timer) : \spl_object_id($timer);
4242
$this->timers[$id] = $timer;
4343
$this->schedule[$id] = $timer->getInterval() + $this->updateTime();
4444
$this->sorted = false;
@@ -51,7 +51,7 @@ public function contains(TimerInterface $timer)
5151

5252
public function cancel(TimerInterface $timer)
5353
{
54-
$id = \spl_object_hash($timer);
54+
$id = \PHP_VERSION_ID < 70200 ? \spl_object_hash($timer) : \spl_object_id($timer);
5555
unset($this->timers[$id], $this->schedule[$id]);
5656
}
5757

0 commit comments

Comments
 (0)