Skip to content

Commit e13252e

Browse files
committed
[Bug] Fixed fatal error on PHP5.3 using timer
PHP5.3 does not support calling $this within a closure
1 parent dc3727b commit e13252e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/React/EventLoop/LibEventLoop.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ protected function addTimerInternal($interval, $callback, $periodic = false)
172172

173173
$timer->signature = spl_object_hash($timer);
174174
$timersGc = $this->timersGc;
175-
$callback = function () use ($timer, $timersGc) {
175+
176+
$self = $this;
177+
$callback = function () use ($timer, $timersGc, $self) {
176178
foreach ($timersGc as $resource) {
177179
event_free($resource);
178180
}
@@ -183,7 +185,7 @@ protected function addTimerInternal($interval, $callback, $periodic = false)
183185
if ($timer->periodic === true) {
184186
event_add($timer->resource, $timer->interval);
185187
} else {
186-
$this->cancelTimer($timer->signature);
188+
$self->cancelTimer($timer->signature);
187189
}
188190
}
189191
};

0 commit comments

Comments
 (0)