From 0372a27ab72f155cdc9d239d667e7a85b17115fc Mon Sep 17 00:00:00 2001 From: "chris.boulton" Date: Sun, 27 Mar 2011 15:02:06 +1100 Subject: [PATCH] Remove lambda and namespaces causing PHP 5.2 incompatibility --- lib/Redisent/Redisent.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/Redisent/Redisent.php b/lib/Redisent/Redisent.php index 8b1f03b..ac70c81 100644 --- a/lib/Redisent/Redisent.php +++ b/lib/Redisent/Redisent.php @@ -51,7 +51,7 @@ class Redisent { $this->port = $port; $this->__sock = fsockopen($this->host, $this->port, $errno, $errstr); if (!$this->__sock) { - throw new \Exception("{$errno} - {$errstr}"); + throw new Exception("{$errno} - {$errstr}"); } } @@ -63,15 +63,13 @@ class Redisent { /* Build the Redis unified protocol command */ array_unshift($args, strtoupper($name)); - $command = sprintf('*%d%s%s%s', count($args), CRLF, implode(array_map(function($arg) { - return sprintf('$%d%s%s', strlen($arg), CRLF, $arg); - }, $args), CRLF), CRLF); + $command = sprintf('*%d%s%s%s', count($args), CRLF, implode(array_map(array($this, 'formatArgument'), $args), CRLF), CRLF); /* Open a Redis connection and execute the command */ for ($written = 0; $written < strlen($command); $written += $fwrite) { $fwrite = fwrite($this->__sock, substr($command, $written)); if ($fwrite === FALSE) { - throw new \Exception('Failed to write entire command to stream'); + throw new Exception('Failed to write entire command to stream'); } } @@ -139,4 +137,7 @@ class Redisent { return $response; } + private function formatArgument($arg) { + return sprintf('$%d%s%s', strlen($arg), CRLF, $arg); + } } \ No newline at end of file