Test Setup Failed
Push — master ( f2b9b8...38e491 )
by Nikita
02:19
created
src/Binn.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
      * @var int
26 26
      * @access protected
27 27
      */
28
-    protected $size         = 0;
28
+    protected $size = 0;
29 29
 
30 30
     /**
31 31
      * Bin string
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      * @var string
34 34
      * @access protected
35 35
      */
36
-    protected $binnString     = "";
36
+    protected $binnString = "";
37 37
 
38 38
     /**
39 39
      * Binn constructor
Please login to merge, or discard this patch.
src/BinnList.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
      */
145 145
     public static function validArray($array)
146 146
     {
147
-        $array = (array)$array;
147
+        $array = (array) $array;
148 148
         if (self::isArrayAssoc($array)) {
149 149
             return false;
150 150
         }
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
     {
215 215
         if (in_array($type,
216 216
             [self::BINN_INT64, self::BINN_INT32, self::BINN_INT16,
217
-                self::BINN_UINT64,self::BINN_UINT32, self::BINN_UINT16])
217
+                self::BINN_UINT64, self::BINN_UINT32, self::BINN_UINT16])
218 218
         ) {
219 219
             $type = $this->compressInt($type, $value);
220 220
         }
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
         // Size
245 245
         if ($sizeBytes & 1 << 7) {
246 246
             $sizeBytes = $this->unpack(self::BINN_UINT32, substr($binnString, $pos, 4));
247
-            $this->size = ($sizeBytes &~ (1 << 31)); // Cut bit
247
+            $this->size = ($sizeBytes & ~ (1 << 31)); // Cut bit
248 248
             $pos += 4;
249 249
         } else {
250 250
             $this->size = $sizeBytes;
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
         // Size
259 259
         if ($countBytes & 1 << 7) {
260 260
             $countBytes = $this->unpack(self::BINN_UINT32, substr($binnString, $pos, 4));
261
-            $this->count = ($countBytes &~ (1 << 31)); // Cut bit
261
+            $this->count = ($countBytes & ~ (1 << 31)); // Cut bit
262 262
             $pos += 4;
263 263
         } else {
264 264
             $this->count = $countBytes;
@@ -285,13 +285,13 @@  discard block
 block discarded – undo
285 285
                 $this->_addVal($varType, $val);
286 286
                 $pos += $varSize['data'];
287 287
 
288
-            } else if ($varStorageType === self::BINN_STRING ) {
288
+            } else if ($varStorageType === self::BINN_STRING) {
289 289
                 $stringSize = $this->unpack(self::BINN_UINT8, $binnString[$pos]);
290 290
 
291 291
                 // Size
292 292
                 if ($stringSize & 1 << 7) {
293 293
                     $stringSize = $this->unpack(self::BINN_UINT32, substr($binnString, $pos, 4));
294
-                    $stringSize = ($stringSize &~ (1 << 31)); // Cut bit
294
+                    $stringSize = ($stringSize & ~ (1 << 31)); // Cut bit
295 295
                     $pos += 4;
296 296
                 } else {
297 297
                     $pos += 1;
@@ -305,15 +305,15 @@  discard block
 block discarded – undo
305 305
                 $pos += $stringSize;
306 306
                 $pos += 1; // Null byte
307 307
             } else if ($varStorageType === self::BINN_STORAGE_CONTAINER) {
308
-                $list_size = $this->unpack(self::BINN_UINT8, $binnString[$pos]);;
308
+                $list_size = $this->unpack(self::BINN_UINT8, $binnString[$pos]); ;
309 309
 
310 310
                 // Size
311 311
                 if ($list_size & 1 << 7) {
312 312
                     $list_size = $this->unpack(self::BINN_UINT32, substr($binnString, $pos, 4));
313
-                    $list_size = ($list_size &~ (1 << 31)); // Cut bit
313
+                    $list_size = ($list_size & ~ (1 << 31)); // Cut bit
314 314
                 }
315 315
 
316
-                $substring = substr($binnString, $pos-1, $list_size);
316
+                $substring = substr($binnString, $pos - 1, $list_size);
317 317
 
318 318
                 foreach ($this->containersClasses as $containerType => $containersClass) {
319 319
                     if ($containerType === $varType) {
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
                     }
324 324
                 }
325 325
 
326
-                $pos += ($list_size-1);
326
+                $pos += ($list_size - 1);
327 327
             } else {
328 328
                 $stop_while = true;
329 329
             }
Please login to merge, or discard this patch.
src/BinnObject.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
         // Size
31 31
         if ($sizeBytes & 1 << 7) {
32 32
             $sizeBytes = $this->unpack(self::BINN_UINT32, substr($binnString, $pos, 4));
33
-            $this->size = ($sizeBytes &~ (1 << 31)); // Cut bit
33
+            $this->size = ($sizeBytes & ~ (1 << 31)); // Cut bit
34 34
             $pos += 4;
35 35
         } else {
36 36
             $this->size = $sizeBytes;
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
         // Size
45 45
         if ($countBytes & 1 << 7) {
46 46
             $countBytes = $this->unpack(self::BINN_UINT32, substr($binnString, $pos, 4));
47
-            $this->count = ($countBytes &~ (1 << 31)); // Cut bit
47
+            $this->count = ($countBytes & ~ (1 << 31)); // Cut bit
48 48
             $pos += 4;
49 49
         } else {
50 50
             $this->count = $countBytes;
@@ -78,19 +78,19 @@  discard block
 block discarded – undo
78 78
                 $this->_addVal($varKey, $varType, $val);
79 79
                 $pos += $varSize['data'];
80 80
 
81
-            } else if ($varStorageType === self::BINN_STRING ) {
81
+            } else if ($varStorageType === self::BINN_STRING) {
82 82
                 $stringSize = $this->unpack(self::BINN_UINT8, $binnString[$pos]);
83 83
 
84 84
                 // Size
85 85
                 if ($stringSize & 1 << 7) {
86 86
                     $stringSize = $this->unpack(self::BINN_UINT32, substr($binnString, $pos, 4));
87
-                    $stringSize = ($stringSize &~ (1 << 31)); // Cut bit
87
+                    $stringSize = ($stringSize & ~ (1 << 31)); // Cut bit
88 88
                     $pos += 4;
89 89
                 } else {
90 90
                     $pos += 1;
91 91
                 }
92 92
 
93
-                $this->_addVal($varKey,self::BINN_STRING, $this->unpack(
93
+                $this->_addVal($varKey, self::BINN_STRING, $this->unpack(
94 94
                     self::BINN_STRING,
95 95
                     substr($binnString, $pos, $stringSize)
96 96
                 ));
@@ -98,15 +98,15 @@  discard block
 block discarded – undo
98 98
                 $pos += $stringSize;
99 99
                 $pos += 1; // Null byte
100 100
             } else if ($varStorageType === self::BINN_STORAGE_CONTAINER) {
101
-                $list_size = $this->unpack(self::BINN_UINT8, $binnString[$pos]);;
101
+                $list_size = $this->unpack(self::BINN_UINT8, $binnString[$pos]); ;
102 102
 
103 103
                 // Size
104 104
                 if ($list_size & 1 << 7) {
105 105
                     $list_size = $this->unpack(self::BINN_UINT32, substr($binnString, $pos, 4));
106
-                    $list_size = ($list_size &~ (1 << 31)); // Cut bit
106
+                    $list_size = ($list_size & ~ (1 << 31)); // Cut bit
107 107
                 }
108 108
 
109
-                $substring = substr($binnString, $pos-1, $list_size);
109
+                $substring = substr($binnString, $pos - 1, $list_size);
110 110
 
111 111
                 foreach ($this->containersClasses as $containerType => $containersClass) {
112 112
                     if ($containerType === $varType) {
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
                     }
117 117
                 }
118 118
 
119
-                $pos += ($list_size-1);
119
+                $pos += ($list_size - 1);
120 120
             } else {
121 121
                 $stopWhile = true;
122 122
             }
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
     {
198 198
         if (in_array($type,
199 199
             [self::BINN_INT64, self::BINN_INT32, self::BINN_INT16,
200
-                self::BINN_UINT64,self::BINN_UINT32, self::BINN_UINT16])
200
+                self::BINN_UINT64, self::BINN_UINT32, self::BINN_UINT16])
201 201
         ) {
202 202
             $type = $this->compressInt($type, $value);
203 203
         }
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
      */
229 229
     public static function validArray($array)
230 230
     {
231
-        $array = (array)$array;
231
+        $array = (array) $array;
232 232
 
233 233
         /*
234 234
         if (count(array_filter(array_keys($array), 'is_string')) > 0) {
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 
256 256
         $this->binnFree();
257 257
 
258
-        if (! $this->isArrayAssoc($array)) {
258
+        if (!$this->isArrayAssoc($array)) {
259 259
             throw new InvalidArrayException('Array should be associative');
260 260
         }
261 261
 
Please login to merge, or discard this patch.
src/BinnAbstract.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -19,18 +19,18 @@  discard block
 block discarded – undo
19 19
     const BINN_INT64        = 0x81;
20 20
     const BINN_STRING       = 0xA0;
21 21
 
22
-    const BINN_FLOAT32      = 0x62;  // (DWORD)
23
-    const BINN_FLOAT64      = 0x82;  // (QWORD)
22
+    const BINN_FLOAT32      = 0x62; // (DWORD)
23
+    const BINN_FLOAT64      = 0x82; // (QWORD)
24 24
     const BINN_FLOAT        = self::BINN_FLOAT32;
25 25
 
26 26
     const BINN_BOOL         = 0x80061;
27 27
 
28 28
     const BINN_STORAGE_NOBYTES      = 0x00;
29
-    const BINN_STORAGE_BYTE         = 0x20;  //  8 bits
30
-    const BINN_STORAGE_WORD         = 0x40;  // 16 bits -- the endianess (byte order) is automatically corrected
31
-    const BINN_STORAGE_DWORD        = 0x60;  // 32 bits -- the endianess (byte order) is automatically corrected
32
-    const BINN_STORAGE_QWORD        = 0x80;  // 64 bits -- the endianess (byte order) is automatically corrected
33
-    const BINN_STORAGE_STRING       = 0xA0;  // Are stored with null termination
29
+    const BINN_STORAGE_BYTE         = 0x20; //  8 bits
30
+    const BINN_STORAGE_WORD         = 0x40; // 16 bits -- the endianess (byte order) is automatically corrected
31
+    const BINN_STORAGE_DWORD        = 0x60; // 32 bits -- the endianess (byte order) is automatically corrected
32
+    const BINN_STORAGE_QWORD        = 0x80; // 64 bits -- the endianess (byte order) is automatically corrected
33
+    const BINN_STORAGE_STRING       = 0xA0; // Are stored with null termination
34 34
     const BINN_STORAGE_BLOB         = 0xC0;
35 35
     const BINN_STORAGE_CONTAINER    = 0xE0;
36 36
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
      * @var int
83 83
      * @access protected
84 84
      */
85
-    protected $count        = 0;
85
+    protected $count = 0;
86 86
 
87 87
     /**
88 88
      * Data size in bytes
@@ -90,14 +90,14 @@  discard block
 block discarded – undo
90 90
      * @var int
91 91
      * @access protected
92 92
      */
93
-    protected $dataSize    = 0;
93
+    protected $dataSize = 0;
94 94
 
95 95
     /**
96 96
      * Meta size in bytes
97 97
      *
98 98
      * @var int
99 99
      */
100
-    protected $metaSize    = self::MIN_BINN_SIZE;
100
+    protected $metaSize = self::MIN_BINN_SIZE;
101 101
 
102 102
     /**
103 103
      * Size bin string in bytes
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
      * @var int
106 106
      * @access protected
107 107
      */
108
-    protected $size         = 0;
108
+    protected $size = 0;
109 109
 
110 110
     /**
111 111
      * Bin string
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
      * @var string
114 114
      * @access protected
115 115
      */
116
-    protected $binnString     = "";
116
+    protected $binnString = "";
117 117
 
118 118
     /**
119 119
      * Object elements
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
      */
243 243
     protected static function isArrayAssoc($arr)
244 244
     {
245
-        $arr = (array)$arr;
245
+        $arr = (array) $arr;
246 246
         if (array() === $arr) return false;
247 247
         return array_keys($arr) !== range(0, count($arr) - 1);
248 248
     }
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
      */
254 254
     protected static function isArrayObject($arr)
255 255
     {
256
-        foreach(array_keys($arr) as $key) {
256
+        foreach (array_keys($arr) as $key) {
257 257
             if (!is_int($key)) {
258 258
                 return true;
259 259
             }
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 
393 393
         // Initial meta size 3 bytes
394 394
         // Type byte + Size byte + Item counts byte
395
-        $this->metaSize    = self::MIN_BINN_SIZE;
395
+        $this->metaSize = self::MIN_BINN_SIZE;
396 396
 
397 397
         $this->size         = 0;
398 398
         $this->binnString   = "";
Please login to merge, or discard this patch.
Braces   +7 added lines, -9 removed lines patch added patch discarded remove patch
@@ -243,7 +243,9 @@  discard block
 block discarded – undo
243 243
     protected static function isArrayAssoc($arr)
244 244
     {
245 245
         $arr = (array)$arr;
246
-        if (array() === $arr) return false;
246
+        if (array() === $arr) {
247
+            return false;
248
+        }
247 249
         return array_keys($arr) !== range(0, count($arr) - 1);
248 250
     }
249 251
 
@@ -357,11 +359,9 @@  discard block
 block discarded – undo
357 359
             // Signed
358 360
             if ($val >= self::INT8_MIN) {
359 361
                 $newType = self::BINN_INT8;
360
-            }
361
-            elseif ($val >= self::INT16_MIN) {
362
+            } elseif ($val >= self::INT16_MIN) {
362 363
                 $newType = self::BINN_INT16;
363
-            }
364
-            elseif ($val >= self::INT32_MIN) {
364
+            } elseif ($val >= self::INT32_MIN) {
365 365
                 $newType = self::BINN_INT32;
366 366
             }
367 367
         }
@@ -371,11 +371,9 @@  discard block
 block discarded – undo
371 371
 
372 372
             if ($val <= self::UINT8_MAX) {
373 373
                 $newType = self::BINN_UINT8;
374
-            }
375
-            elseif ($val <= self::UINT16_MAX) {
374
+            } elseif ($val <= self::UINT16_MAX) {
376 375
                 $newType = self::BINN_UINT16;
377
-            }
378
-            elseif ($val <= self::UINT32_MAX) {
376
+            } elseif ($val <= self::UINT32_MAX) {
379 377
                 $newType = self::BINN_UINT32;
380 378
             }
381 379
         }
Please login to merge, or discard this patch.
src/BinnMap.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
     {
40 40
         if (in_array($type,
41 41
             [self::BINN_INT64, self::BINN_INT32, self::BINN_INT16,
42
-                self::BINN_UINT64,self::BINN_UINT32, self::BINN_UINT16])
42
+                self::BINN_UINT64, self::BINN_UINT32, self::BINN_UINT16])
43 43
         ) {
44 44
             $type = $this->compressInt($type, $value);
45 45
         }
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         // Size
74 74
         if ($sizeBytes & 1 << 7) {
75 75
             $sizeBytes = $this->unpack(self::BINN_UINT32, substr($binnString, $pos, 4));
76
-            $this->size = ($sizeBytes &~ (1 << 31)); // Cut bit
76
+            $this->size = ($sizeBytes & ~ (1 << 31)); // Cut bit
77 77
             $pos += 4;
78 78
         } else {
79 79
             $this->size = $sizeBytes;
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         // Size
88 88
         if ($countBytes & 1 << 7) {
89 89
             $countBytes = $this->unpack(self::BINN_UINT32, substr($binnString, $pos, 4));
90
-            $this->count = ($countBytes &~ (1 << 31)); // Cut bit
90
+            $this->count = ($countBytes & ~ (1 << 31)); // Cut bit
91 91
             $pos += 4;
92 92
         } else {
93 93
             $this->count = $countBytes;
@@ -117,19 +117,19 @@  discard block
 block discarded – undo
117 117
                 $this->_addVal($varKey, $varType, $val);
118 118
                 $pos += $varSize['data'];
119 119
 
120
-            } else if ($varStorageType === self::BINN_STRING ) {
120
+            } else if ($varStorageType === self::BINN_STRING) {
121 121
                 $stringSize = $this->unpack(self::BINN_UINT8, $binnString[$pos]);
122 122
 
123 123
                 // Size
124 124
                 if ($stringSize & 1 << 7) {
125 125
                     $stringSize = $this->unpack(self::BINN_UINT32, substr($binnString, $pos, 4));
126
-                    $stringSize = ($stringSize &~ (1 << 31)); // Cut bit
126
+                    $stringSize = ($stringSize & ~ (1 << 31)); // Cut bit
127 127
                     $pos += 4;
128 128
                 } else {
129 129
                     $pos += 1;
130 130
                 }
131 131
 
132
-                $this->_addVal($varKey,self::BINN_STRING, $this->unpack(
132
+                $this->_addVal($varKey, self::BINN_STRING, $this->unpack(
133 133
                     self::BINN_STRING,
134 134
                     substr($binnString, $pos, $stringSize)
135 135
                 ));
@@ -137,15 +137,15 @@  discard block
 block discarded – undo
137 137
                 $pos += $stringSize;
138 138
                 $pos += 1; // Null byte
139 139
             } else if ($varStorageType === self::BINN_STORAGE_CONTAINER) {
140
-                $list_size = $this->unpack(self::BINN_UINT8, $binnString[$pos]);;
140
+                $list_size = $this->unpack(self::BINN_UINT8, $binnString[$pos]); ;
141 141
 
142 142
                 // Size
143 143
                 if ($list_size & 1 << 7) {
144 144
                     $list_size = $this->unpack(self::BINN_UINT32, substr($binnString, $pos, 4));
145
-                    $list_size = ($list_size &~ (1 << 31)); // Cut bit
145
+                    $list_size = ($list_size & ~ (1 << 31)); // Cut bit
146 146
                 }
147 147
 
148
-                $substring = substr($binnString, $pos-1, $list_size);
148
+                $substring = substr($binnString, $pos - 1, $list_size);
149 149
 
150 150
                 foreach ($this->containersClasses as $containerType => $containersClass) {
151 151
                     if ($containerType === $varType) {
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
                     }
156 156
                 }
157 157
 
158
-                $pos += ($list_size-1);
158
+                $pos += ($list_size - 1);
159 159
             } else {
160 160
                 $stopWhile = true;
161 161
             }
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
      */
225 225
     public static function validArray($array)
226 226
     {
227
-        $array = (array)$array;
227
+        $array = (array) $array;
228 228
         if (!self::isArrayAssoc($array)) {
229 229
             return false;
230 230
         }
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 
249 249
         $this->binnFree();
250 250
 
251
-        if (! $this->isArrayAssoc($array)) {
251
+        if (!$this->isArrayAssoc($array)) {
252 252
             throw new InvalidArrayException('Array should be associative');
253 253
         }
254 254
 
Please login to merge, or discard this patch.