Skip to content

Commit 88bfb66

Browse files
committed
Fix HHVM build error because default_socket_timeout should be an int
1 parent 03907ca commit 88bfb66

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/Factory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function ($error) use ($client) {
116116
$promise->then(array($deferred, 'resolve'), array($deferred, 'reject'));
117117

118118
// use timeout from explicit ?timeout=x parameter or default to PHP's default_socket_timeout (60)
119-
$timeout = (float) isset($parts['timeout']) ? $parts['timeout'] : ini_get("default_socket_timeout");
119+
$timeout = isset($parts['timeout']) ? $parts['timeout'] : (int) ini_get("default_socket_timeout");
120120
if ($timeout < 0) {
121121
return $deferred->promise();
122122
}
@@ -194,7 +194,7 @@ private function parseUrl($target)
194194
}
195195

196196
if (isset($args['timeout'])) {
197-
$ret['timeout'] = $args['timeout'];
197+
$ret['timeout'] = (float) $args['timeout'];
198198
}
199199
}
200200

tests/FactoryStreamingClientTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,13 +324,13 @@ public function testCreateClientWithNegativeTimeoutParameterWillNotStartTimer()
324324

325325
public function testCreateClientWithoutTimeoutParameterWillStartTimerWithDefaultTimeoutFromIni()
326326
{
327-
$this->loop->expects($this->once())->method('addTimer')->with(1.5, $this->anything());
327+
$this->loop->expects($this->once())->method('addTimer')->with(42, $this->anything());
328328

329329
$deferred = new Deferred();
330330
$this->connector->expects($this->once())->method('connect')->with('127.0.0.1:2')->willReturn($deferred->promise());
331331

332332
$old = ini_get('default_socket_timeout');
333-
ini_set('default_socket_timeout', '1.5');
333+
ini_set('default_socket_timeout', '42');
334334
$this->factory->createClient('redis://127.0.0.1:2');
335335
ini_set('default_socket_timeout', $old);
336336
}

0 commit comments

Comments
 (0)