Prechádzať zdrojové kódy

Minor fixes and adjustments to pipeline executors.

Daniele Alessandri 14 rokov pred
rodič
commit
595692d50f

+ 5 - 3
lib/Predis/Pipeline/SafeClusterExecutor.php

@@ -2,6 +2,8 @@
 
 namespace Predis\Pipeline;
 
+use Predis\ServerException;
+use Predis\CommunicationException;
 use Predis\Network\IConnection;
 
 class SafeClusterExecutor implements IPipelineExecutor {
@@ -18,7 +20,7 @@ class SafeClusterExecutor implements IPipelineExecutor {
             try {
                 $cmdConnection->writeCommand($command);
             }
-            catch (\Predis\CommunicationException $exception) {
+            catch (CommunicationException $exception) {
                 $connectionExceptions[spl_object_hash($cmdConnection)] = $exception;
             }
         }
@@ -42,10 +44,10 @@ class SafeClusterExecutor implements IPipelineExecutor {
                     : $response
                 );
             }
-            catch (\Predis\ServerException $exception) {
+            catch (ServerException $exception) {
                 $values[] = $exception->toResponseError();
             }
-            catch (\Predis\CommunicationException $exception) {
+            catch (CommunicationException $exception) {
                 $values[] = $exception;
                 $connectionExceptions[$connectionObjectHash] = $exception;
             }

+ 5 - 3
lib/Predis/Pipeline/SafeExecutor.php

@@ -2,6 +2,8 @@
 
 namespace Predis\Pipeline;
 
+use Predis\ServerException;
+use Predis\CommunicationException;
 use Predis\Network\IConnection;
 
 class SafeExecutor implements IPipelineExecutor {
@@ -13,7 +15,7 @@ class SafeExecutor implements IPipelineExecutor {
             try {
                 $connection->writeCommand($command);
             }
-            catch (\Predis\CommunicationException $exception) {
+            catch (CommunicationException $exception) {
                 return array_fill(0, $sizeofPipe, $exception);
             }
         }
@@ -28,10 +30,10 @@ class SafeExecutor implements IPipelineExecutor {
                     : $response
                 );
             }
-            catch (\Predis\ServerException $exception) {
+            catch (ServerException $exception) {
                 $values[] = $exception->toResponseError();
             }
-            catch (\Predis\CommunicationException $exception) {
+            catch (CommunicationException $exception) {
                 $toAdd  = count($commands) - count($values);
                 $values = array_merge($values, array_fill(0, $toAdd, $exception));
                 break;

+ 3 - 2
lib/Predis/Pipeline/StandardExecutor.php

@@ -2,6 +2,7 @@
 
 namespace Predis\Pipeline;
 
+use Predis\ServerException;
 use Predis\Network\IConnection;
 
 class StandardExecutor implements IPipelineExecutor {
@@ -15,13 +16,13 @@ class StandardExecutor implements IPipelineExecutor {
         try {
             for ($i = 0; $i < $sizeofPipe; $i++) {
                 $response = $connection->readResponse($commands[$i]);
-                $values[] = $response instanceof Iterator
+                $values[] = $response instanceof \Iterator
                     ? iterator_to_array($response)
                     : $response;
                 unset($commands[$i]);
             }
         }
-        catch (\Predis\ServerException $exception) {
+        catch (ServerException $exception) {
             // Force disconnection to prevent protocol desynchronization.
             $connection->disconnect();
             throw $exception;