Skip to content

Commit 0372a27

Browse files
author
chris.boulton
committed
Remove lambda and namespaces causing PHP 5.2 incompatibility
1 parent d2f804b commit 0372a27

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/Redisent/Redisent.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function __construct($host, $port = 6379) {
5151
$this->port = $port;
5252
$this->__sock = fsockopen($this->host, $this->port, $errno, $errstr);
5353
if (!$this->__sock) {
54-
throw new \Exception("{$errno} - {$errstr}");
54+
throw new Exception("{$errno} - {$errstr}");
5555
}
5656
}
5757

@@ -63,15 +63,13 @@ function __call($name, $args) {
6363

6464
/* Build the Redis unified protocol command */
6565
array_unshift($args, strtoupper($name));
66-
$command = sprintf('*%d%s%s%s', count($args), CRLF, implode(array_map(function($arg) {
67-
return sprintf('$%d%s%s', strlen($arg), CRLF, $arg);
68-
}, $args), CRLF), CRLF);
66+
$command = sprintf('*%d%s%s%s', count($args), CRLF, implode(array_map(array($this, 'formatArgument'), $args), CRLF), CRLF);
6967

7068
/* Open a Redis connection and execute the command */
7169
for ($written = 0; $written < strlen($command); $written += $fwrite) {
7270
$fwrite = fwrite($this->__sock, substr($command, $written));
7371
if ($fwrite === FALSE) {
74-
throw new \Exception('Failed to write entire command to stream');
72+
throw new Exception('Failed to write entire command to stream');
7573
}
7674
}
7775

@@ -139,4 +137,7 @@ function __call($name, $args) {
139137
return $response;
140138
}
141139

140+
private function formatArgument($arg) {
141+
return sprintf('$%d%s%s', strlen($arg), CRLF, $arg);
142+
}
142143
}

0 commit comments

Comments
 (0)