Bladeren bron

Fix internal flags for MULTI / EXEC and PUB/SUB contexts.

Do not ask me why I was using 0x (the prefix for hexadecimal notation)
when what we really need here is 0b (the prefix for binary notation).
Really, everything was working by sheer coincidence.

Since 0b has been added in PHP 5.4, we rely on plain decimal numbers
to define our constants for now.
Daniele Alessandri 13 jaren geleden
bovenliggende
commit
9f51263136
2 gewijzigde bestanden met toevoegingen van 10 en 10 verwijderingen
  1. 4 4
      lib/Predis/PubSub/PubSubContext.php
  2. 6 6
      lib/Predis/Transaction/MultiExecContext.php

+ 4 - 4
lib/Predis/PubSub/PubSubContext.php

@@ -30,9 +30,9 @@ class PubSubContext implements \Iterator
     const MESSAGE      = 'message';
     const PMESSAGE     = 'pmessage';
 
-    const STATUS_VALID       = 0x0001;
-    const STATUS_SUBSCRIBED  = 0x0010;
-    const STATUS_PSUBSCRIBED = 0x0100;
+    const STATUS_VALID       = 1;	// 0b0001
+    const STATUS_SUBSCRIBED  = 2;	// 0b0010
+    const STATUS_PSUBSCRIBED = 4;	// 0b0100
 
     private $client;
     private $position;
@@ -245,7 +245,7 @@ class PubSubContext implements \Iterator
      */
     private function invalidate()
     {
-        $this->statusFlags = 0x0000;
+        $this->statusFlags = 0;	// 0b0000;
     }
 
     /**

+ 6 - 6
lib/Predis/Transaction/MultiExecContext.php

@@ -32,12 +32,12 @@ use Predis\Protocol\ProtocolException;
  */
 class MultiExecContext implements BasicClientInterface, ExecutableContextInterface
 {
-    const STATE_RESET       = 0x00000;
-    const STATE_INITIALIZED = 0x00001;
-    const STATE_INSIDEBLOCK = 0x00010;
-    const STATE_DISCARDED   = 0x00100;
-    const STATE_CAS         = 0x01000;
-    const STATE_WATCH       = 0x10000;
+    const STATE_RESET       = 0;	// 0b00000
+    const STATE_INITIALIZED = 1;	// 0b00001
+    const STATE_INSIDEBLOCK = 2;	// 0b00010
+    const STATE_DISCARDED   = 4;	// 0b00100
+    const STATE_CAS         = 8;	// 0b01000
+    const STATE_WATCH       = 16;	// 0b10000
 
     private $state;
     private $canWatch;