Completed
Push — master ( 8a6897...15c40a )
by kacper
01:57
created
src/MySQLReplication/BinLog/BinLogConnect.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 
141 141
     /**
142 142
      * @param $length
143
-     * @return mixed
143
+     * @return string
144 144
      * @throws BinLogException
145 145
      */
146 146
     private function readFromSocket($length)
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
     }
162 162
 
163 163
     /**
164
-     * @param $packet
164
+     * @param string $packet
165 165
      * @return array
166 166
      * @throws BinLogException
167 167
      */
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
     }
204 204
 
205 205
     /**
206
-     * @param $data
206
+     * @param string $data
207 207
      * @throws BinLogException
208 208
      */
209 209
     private function writeToSocket($data)
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -171,8 +171,7 @@  discard block
 block discarded – undo
171 171
         if (in_array($head, $this->packageOkHeader, true))
172 172
         {
173 173
             return ['status' => true, 'code' => 0, 'msg' => ''];
174
-        }
175
-        else
174
+        } else
176 175
         {
177 176
             $error_code = unpack('v', $packet[1] . $packet[2])[1];
178 177
             $error_msg = '';
@@ -230,8 +229,7 @@  discard block
 block discarded – undo
230 229
         if ('' !== $this->config->getGtid())
231 230
         {
232 231
             $this->setBinLogDumpGtid();
233
-        }
234
-        else
232
+        } else
235 233
         {
236 234
             $this->setBinLogDump();
237 235
         }
Please login to merge, or discard this patch.
src/MySQLReplication/BinLog/BinLogServerInfo.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -35,8 +35,7 @@  discard block
 block discarded – undo
35 35
             {
36 36
                 $i++;
37 37
                 break;
38
-            }
39
-            else
38
+            } else
40 39
             {
41 40
                 self::$serverInfo['server_version'] .= $pack[$i];
42 41
             }
@@ -116,8 +115,7 @@  discard block
 block discarded – undo
116 115
             if (false !== strpos($version, self::MYSQL_VERSION_MARIADB))
117 116
             {
118 117
                 self::$serverInfo['version_name'] = self::MYSQL_VERSION_MARIADB;
119
-            }
120
-            else if (false !== strpos($version, self::MYSQL_VERSION_PERCONA))
118
+            } else if (false !== strpos($version, self::MYSQL_VERSION_PERCONA))
121 119
             {
122 120
                 self::$serverInfo['version_name'] = self::MYSQL_VERSION_PERCONA;
123 121
             }
Please login to merge, or discard this patch.
src/MySQLReplication/Gtid/Gtid.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -53,8 +53,7 @@
 block discarded – undo
53 53
             {
54 54
                 $buffer .= BinaryDataReader::pack64bit($interval[0]);
55 55
                 $buffer .= BinaryDataReader::pack64bit($interval[1]);
56
-            }
57
-            else
56
+            } else
58 57
             {
59 58
                 $buffer .= BinaryDataReader::pack64bit($interval[0]);
60 59
                 $buffer .= BinaryDataReader::pack64bit($interval[0] + 1);
Please login to merge, or discard this patch.
src/MySQLReplication/BinaryDataReader/BinaryDataReader.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -425,8 +425,8 @@
 block discarded – undo
425 425
     public static function pack64bit($value)
426 426
     {
427 427
         return pack('C8',
428
-            ($value >>  0) & 0xFF,
429
-            ($value >>  8) & 0xFF,
428
+            ($value >> 0) & 0xFF,
429
+            ($value >> 8) & 0xFF,
430 430
             ($value >> 16) & 0xFF,
431 431
             ($value >> 24) & 0xFF,
432 432
             ($value >> 32) & 0xFF,
Please login to merge, or discard this patch.
Braces   +14 added lines, -28 removed lines patch added patch discarded remove patch
@@ -109,17 +109,14 @@  discard block
 block discarded – undo
109 109
         if ($c < self::UNSIGNED_CHAR_COLUMN)
110 110
         {
111 111
             return $c;
112
-        }
113
-        elseif ($c == self::UNSIGNED_SHORT_COLUMN)
112
+        } elseif ($c == self::UNSIGNED_SHORT_COLUMN)
114 113
         {
115 114
             return $this->readUInt16();
116 115
 
117
-        }
118
-        elseif ($c == self::UNSIGNED_INT24_COLUMN)
116
+        } elseif ($c == self::UNSIGNED_INT24_COLUMN)
119 117
         {
120 118
             return $this->readUInt24();
121
-        }
122
-        elseif ($c == self::UNSIGNED_INT64_COLUMN)
119
+        } elseif ($c == self::UNSIGNED_INT64_COLUMN)
123 120
         {
124 121
             return $this->readUInt64();
125 122
         }
@@ -208,32 +205,25 @@  discard block
 block discarded – undo
208 205
         if ($size == self::UNSIGNED_CHAR_LENGTH)
209 206
         {
210 207
             return $this->readUInt8();
211
-        }
212
-        elseif ($size == self::UNSIGNED_SHORT_LENGTH)
208
+        } elseif ($size == self::UNSIGNED_SHORT_LENGTH)
213 209
         {
214 210
             return $this->readUInt16();
215
-        }
216
-        elseif ($size == self::UNSIGNED_INT24_LENGTH)
211
+        } elseif ($size == self::UNSIGNED_INT24_LENGTH)
217 212
         {
218 213
             return $this->readUInt24();
219
-        }
220
-        elseif ($size == self::UNSIGNED_INT32_LENGTH)
214
+        } elseif ($size == self::UNSIGNED_INT32_LENGTH)
221 215
         {
222 216
             return $this->readUInt32();
223
-        }
224
-        elseif ($size == self::UNSIGNED_INT40_LENGTH)
217
+        } elseif ($size == self::UNSIGNED_INT40_LENGTH)
225 218
         {
226 219
             return $this->readUInt40();
227
-        }
228
-        elseif ($size == self::UNSIGNED_INT48_LENGTH)
220
+        } elseif ($size == self::UNSIGNED_INT48_LENGTH)
229 221
         {
230 222
             return $this->readUInt48();
231
-        }
232
-        elseif ($size == self::UNSIGNED_INT56_LENGTH)
223
+        } elseif ($size == self::UNSIGNED_INT56_LENGTH)
233 224
         {
234 225
             return $this->readUInt56();
235
-        }
236
-        elseif ($size == self::UNSIGNED_INT64_LENGTH)
226
+        } elseif ($size == self::UNSIGNED_INT64_LENGTH)
237 227
         {
238 228
             return $this->readUInt64();
239 229
         }
@@ -302,20 +292,16 @@  discard block
 block discarded – undo
302 292
         if ($size == self::UNSIGNED_CHAR_LENGTH)
303 293
         {
304 294
             return $this->readInt8();
305
-        }
306
-        elseif ($size == self::UNSIGNED_SHORT_LENGTH)
295
+        } elseif ($size == self::UNSIGNED_SHORT_LENGTH)
307 296
         {
308 297
             return $this->readInt16Be();
309
-        }
310
-        elseif ($size == self::UNSIGNED_INT24_LENGTH)
298
+        } elseif ($size == self::UNSIGNED_INT24_LENGTH)
311 299
         {
312 300
             return $this->readInt24Be();
313
-        }
314
-        elseif ($size == self::UNSIGNED_INT32_LENGTH)
301
+        } elseif ($size == self::UNSIGNED_INT32_LENGTH)
315 302
         {
316 303
             return $this->readInt32Be();
317
-        }
318
-        elseif ($size == self::UNSIGNED_INT40_LENGTH)
304
+        } elseif ($size == self::UNSIGNED_INT40_LENGTH)
319 305
         {
320 306
             return $this->readInt40Be();
321 307
         }
Please login to merge, or discard this patch.
src/MySQLReplication/Event/Event.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
         );
87 87
 
88 88
         if (ConstEventType::TABLE_MAP_EVENT === $eventInfo->getType()) {
89
-			$event = $this->rowEventService->makeRowEvent($binaryDataReader, $eventInfo)->makeTableMapDTO();
90
-			if ($event !== null) {
91
-				$this->eventDispatcher->dispatch(ConstEventsNames::TABLE_MAP, $event);
92
-			}
89
+            $event = $this->rowEventService->makeRowEvent($binaryDataReader, $eventInfo)->makeTableMapDTO();
90
+            if ($event !== null) {
91
+                $this->eventDispatcher->dispatch(ConstEventsNames::TABLE_MAP, $event);
92
+            }
93 93
         } else {
94 94
             if ([] !== $this->config->getEventsOnly() && !in_array($eventInfo->getType(), $this->config->getEventsOnly(), true)) {
95 95
                 return;
@@ -100,20 +100,20 @@  discard block
 block discarded – undo
100 100
             }
101 101
 
102 102
             if (in_array($eventInfo->getType(), [ConstEventType::UPDATE_ROWS_EVENT_V1, ConstEventType::UPDATE_ROWS_EVENT_V2], true)) {
103
-				$event = $this->rowEventService->makeRowEvent($binaryDataReader, $eventInfo)->makeUpdateRowsDTO();
104
-				if ($event !== null) {
105
-					$this->eventDispatcher->dispatch(ConstEventsNames::UPDATE, $event);
106
-				}
103
+                $event = $this->rowEventService->makeRowEvent($binaryDataReader, $eventInfo)->makeUpdateRowsDTO();
104
+                if ($event !== null) {
105
+                    $this->eventDispatcher->dispatch(ConstEventsNames::UPDATE, $event);
106
+                }
107 107
             } elseif (in_array($eventInfo->getType(), [ConstEventType::WRITE_ROWS_EVENT_V1, ConstEventType::WRITE_ROWS_EVENT_V2], true)) {
108
-				$event = $this->rowEventService->makeRowEvent($binaryDataReader, $eventInfo)->makeWriteRowsDTO();
109
-				if ($event !== null) {
110
-					$this->eventDispatcher->dispatch(ConstEventsNames::WRITE, $event);
111
-				}
108
+                $event = $this->rowEventService->makeRowEvent($binaryDataReader, $eventInfo)->makeWriteRowsDTO();
109
+                if ($event !== null) {
110
+                    $this->eventDispatcher->dispatch(ConstEventsNames::WRITE, $event);
111
+                }
112 112
             } elseif (in_array($eventInfo->getType(), [ConstEventType::DELETE_ROWS_EVENT_V1, ConstEventType::DELETE_ROWS_EVENT_V2], true)) {
113
-            	$event = $this->rowEventService->makeRowEvent($binaryDataReader, $eventInfo)->makeDeleteRowsDTO();
114
-            	if ($event !== null) {
115
-					$this->eventDispatcher->dispatch(ConstEventsNames::DELETE, $event);
116
-				}
113
+                $event = $this->rowEventService->makeRowEvent($binaryDataReader, $eventInfo)->makeDeleteRowsDTO();
114
+                if ($event !== null) {
115
+                    $this->eventDispatcher->dispatch(ConstEventsNames::DELETE, $event);
116
+                }
117 117
             } elseif (ConstEventType::XID_EVENT === $eventInfo->getType()) {
118 118
                 $this->eventDispatcher->dispatch(ConstEventsNames::XID, (new XidEvent($eventInfo, $binaryDataReader))->makeXidDTO());
119 119
             } elseif (ConstEventType::ROTATE_EVENT === $eventInfo->getType()) {
Please login to merge, or discard this patch.
src/MySQLReplication/Event/RowEvent/RowEvent.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -352,9 +352,9 @@
 block discarded – undo
352 352
                 $values[$name] = $this->getDatetime2($column);
353 353
             }
354 354
             elseif ($column['type'] === ConstFieldType::TIMESTAMP)
355
-			{
356
-				$values[$name] = date('c', $this->binaryDataReader->readUInt32());
357
-			}
355
+            {
356
+                $values[$name] = date('c', $this->binaryDataReader->readUInt32());
357
+            }
358 358
             elseif ($column['type'] === ConstFieldType::TIME2)
359 359
             {
360 360
                 $values[$name] = $this->getTime2($column);
Please login to merge, or discard this patch.
Braces   +37 added lines, -74 removed lines patch added patch discarded remove patch
@@ -153,8 +153,7 @@  discard block
 block discarded – undo
153 153
                         'COLUMN_KEY' => '',
154 154
                     ];
155 155
                     $type = ConstFieldType::IGNORE;
156
-                }
157
-                else
156
+                } else
158 157
                 {
159 158
                     $type = ord($data['column_types'][$i]);
160 159
                 }
@@ -255,123 +254,98 @@  discard block
 block discarded – undo
255 254
             if ($this->checkNull($null_bitmap, $nullBitmapIndex))
256 255
             {
257 256
                 $values[$name] = null;
258
-            }
259
-            elseif ($column['type'] === ConstFieldType::IGNORE)
257
+            } elseif ($column['type'] === ConstFieldType::IGNORE)
260 258
             {
261 259
                 $values[$name] = null;
262
-            }
263
-            elseif ($column['type'] === ConstFieldType::TINY)
260
+            } elseif ($column['type'] === ConstFieldType::TINY)
264 261
             {
265 262
                 if (true === $column['unsigned'])
266 263
                 {
267 264
                     $values[$name] = $this->binaryDataReader->readUInt8();
268
-                }
269
-                else
265
+                } else
270 266
                 {
271 267
                     $values[$name] = $this->binaryDataReader->readInt8();
272 268
                 }
273
-            }
274
-            elseif ($column['type'] === ConstFieldType::SHORT)
269
+            } elseif ($column['type'] === ConstFieldType::SHORT)
275 270
             {
276 271
                 if (true === $column['unsigned'])
277 272
                 {
278 273
                     $values[$name] = $this->binaryDataReader->readUInt16();
279
-                }
280
-                else
274
+                } else
281 275
                 {
282 276
                     $values[$name] = $this->binaryDataReader->readInt16();
283 277
                 }
284
-            }
285
-            elseif ($column['type'] === ConstFieldType::LONG)
278
+            } elseif ($column['type'] === ConstFieldType::LONG)
286 279
             {
287 280
                 if (true === $column['unsigned'])
288 281
                 {
289 282
                     $values[$name] = $this->binaryDataReader->readUInt32();
290
-                }
291
-                else
283
+                } else
292 284
                 {
293 285
                     $values[$name] = $this->binaryDataReader->readInt32();
294 286
                 }
295
-            }
296
-            elseif ($column['type'] === ConstFieldType::LONGLONG)
287
+            } elseif ($column['type'] === ConstFieldType::LONGLONG)
297 288
             {
298 289
                 if (true === $column['unsigned'])
299 290
                 {
300 291
                     $values[$name] = $this->binaryDataReader->readUInt64();
301
-                }
302
-                else
292
+                } else
303 293
                 {
304 294
                     $values[$name] = $this->binaryDataReader->readInt64();
305 295
                 }
306
-            }
307
-            elseif ($column['type'] === ConstFieldType::INT24)
296
+            } elseif ($column['type'] === ConstFieldType::INT24)
308 297
             {
309 298
                 if (true === $column['unsigned'])
310 299
                 {
311 300
                     $values[$name] = $this->binaryDataReader->readUInt24();
312
-                }
313
-                else
301
+                } else
314 302
                 {
315 303
                     $values[$name] = $this->binaryDataReader->readInt24();
316 304
                 }
317
-            }
318
-            elseif ($column['type'] === ConstFieldType::FLOAT)
305
+            } elseif ($column['type'] === ConstFieldType::FLOAT)
319 306
             {
320 307
                 // http://dev.mysql.com/doc/refman/5.7/en/floating-point-types.html FLOAT(7,4)
321 308
                 $values[$name] = round($this->binaryDataReader->readFloat(), 4);
322
-            }
323
-            elseif ($column['type'] === ConstFieldType::DOUBLE)
309
+            } elseif ($column['type'] === ConstFieldType::DOUBLE)
324 310
             {
325 311
                 $values[$name] = $this->binaryDataReader->readDouble();
326
-            }
327
-            elseif ($column['type'] === ConstFieldType::VARCHAR || $column['type'] === ConstFieldType::STRING)
312
+            } elseif ($column['type'] === ConstFieldType::VARCHAR || $column['type'] === ConstFieldType::STRING)
328 313
             {
329 314
                 if ($column['max_length'] > 255)
330 315
                 {
331 316
                     $values[$name] = $this->getString(2, $column);
332
-                }
333
-                else
317
+                } else
334 318
                 {
335 319
                     $values[$name] = $this->getString(1, $column);
336 320
                 }
337
-            }
338
-            elseif ($column['type'] === ConstFieldType::NEWDECIMAL)
321
+            } elseif ($column['type'] === ConstFieldType::NEWDECIMAL)
339 322
             {
340 323
                 $values[$name] = $this->getDecimal($column);
341
-            }
342
-            elseif ($column['type'] === ConstFieldType::BLOB)
324
+            } elseif ($column['type'] === ConstFieldType::BLOB)
343 325
             {
344 326
                 $values[$name] = $this->getString($column['length_size'], $column);
345
-            }
346
-            elseif ($column['type'] === ConstFieldType::DATETIME)
327
+            } elseif ($column['type'] === ConstFieldType::DATETIME)
347 328
             {
348 329
                 $values[$name] = $this->getDatetime();
349
-            }
350
-            elseif ($column['type'] === ConstFieldType::DATETIME2)
330
+            } elseif ($column['type'] === ConstFieldType::DATETIME2)
351 331
             {
352 332
                 $values[$name] = $this->getDatetime2($column);
353
-            }
354
-            elseif ($column['type'] === ConstFieldType::TIMESTAMP)
333
+            } elseif ($column['type'] === ConstFieldType::TIMESTAMP)
355 334
 			{
356 335
 				$values[$name] = date('c', $this->binaryDataReader->readUInt32());
357
-			}
358
-            elseif ($column['type'] === ConstFieldType::TIME2)
336
+			} elseif ($column['type'] === ConstFieldType::TIME2)
359 337
             {
360 338
                 $values[$name] = $this->getTime2($column);
361
-            }
362
-            elseif ($column['type'] === ConstFieldType::TIMESTAMP2)
339
+            } elseif ($column['type'] === ConstFieldType::TIMESTAMP2)
363 340
             {
364 341
                 $values[$name] = $this->getTimestamp2($column);
365
-            }
366
-            elseif ($column['type'] === ConstFieldType::DATE)
342
+            } elseif ($column['type'] === ConstFieldType::DATE)
367 343
             {
368 344
                 $values[$name] = $this->getDate();
369
-            }
370
-            elseif ($column['type'] === ConstFieldType::YEAR)
345
+            } elseif ($column['type'] === ConstFieldType::YEAR)
371 346
             {
372 347
                 $values[$name] = $this->binaryDataReader->readUInt8() + 1900;
373
-            }
374
-            elseif ($column['type'] === ConstFieldType::ENUM)
348
+            } elseif ($column['type'] === ConstFieldType::ENUM)
375 349
             {
376 350
                 $value = $this->binaryDataReader->readUIntBySize($column['size']) - 1;
377 351
 
@@ -381,20 +355,16 @@  discard block
 block discarded – undo
381 355
                 {
382 356
                     $values[$name] = $column['enum_values'][$value];
383 357
                 }
384
-            }
385
-            elseif ($column['type'] === ConstFieldType::SET)
358
+            } elseif ($column['type'] === ConstFieldType::SET)
386 359
             {
387 360
                 $values[$name] = $this->getSet($column);
388
-            }
389
-            elseif ($column['type'] === ConstFieldType::BIT)
361
+            } elseif ($column['type'] === ConstFieldType::BIT)
390 362
             {
391 363
                 $values[$name] = $this->getBit($column);
392
-            }
393
-            elseif ($column['type'] === ConstFieldType::GEOMETRY)
364
+            } elseif ($column['type'] === ConstFieldType::GEOMETRY)
394 365
             {
395 366
                 $values[$name] = $this->binaryDataReader->readLengthCodedPascalString($column['length_size']);
396
-            }
397
-            else
367
+            } else
398 368
             {
399 369
                 throw new MySQLReplicationException('Unknown row type: ' . $column['type']);
400 370
             }
@@ -505,8 +475,7 @@  discard block
 block discarded – undo
505 475
         {
506 476
             $mask = 0;
507 477
             $res = '';
508
-        }
509
-        else
478
+        } else
510 479
         {
511 480
             $mask = -1;
512 481
             $res = '-';
@@ -641,12 +610,10 @@  discard block
 block discarded – undo
641 610
         if ($column['fsp'] == 1 || $column['fsp'] == 2)
642 611
         {
643 612
             $read = 1;
644
-        }
645
-        elseif ($column['fsp'] == 3 || $column['fsp'] == 4)
613
+        } elseif ($column['fsp'] == 3 || $column['fsp'] == 4)
646 614
         {
647 615
             $read = 2;
648
-        }
649
-        elseif ($column ['fsp'] == 5 || $column['fsp'] == 6)
616
+        } elseif ($column ['fsp'] == 5 || $column['fsp'] == 6)
650 617
         {
651 618
             $read = 3;
652 619
         }
@@ -656,8 +623,7 @@  discard block
 block discarded – undo
656 623
             if ($column['fsp'] % 2)
657 624
             {
658 625
                 $time = (int)($microsecond / 10);
659
-            }
660
-            else
626
+            } else
661 627
             {
662 628
                 $time = $microsecond;
663 629
             }
@@ -766,8 +732,7 @@  discard block
 block discarded – undo
766 732
                 if (1 === $column['bytes'])
767 733
                 {
768 734
                     $end = $column['bits'];
769
-                }
770
-                else
735
+                } else
771 736
                 {
772 737
                     $end = $column['bits'] % 8;
773 738
                     if (0 === $end)
@@ -775,8 +740,7 @@  discard block
 block discarded – undo
775 740
                         $end = 8;
776 741
                     }
777 742
                 }
778
-            }
779
-            else
743
+            } else
780 744
             {
781 745
                 $end = 8;
782 746
             }
@@ -786,8 +750,7 @@  discard block
 block discarded – undo
786 750
                 if ($data & (1 << $bit))
787 751
                 {
788 752
                     $current_byte .= '1';
789
-                }
790
-                else
753
+                } else
791 754
                 {
792 755
                     $current_byte .= '0';
793 756
                 }
Please login to merge, or discard this patch.
src/MySQLReplication/MySQLReplicationFactory.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@
 block discarded – undo
75 75
             'host' => $config->getIp(),
76 76
             'port' => $config->getPort(),
77 77
             'driver' => 'pdo_mysql',
78
-			'charset' => $config->getCharset()
78
+            'charset' => $config->getCharset()
79 79
         ]);
80 80
         $this->binLogAuth = new BinLogAuth();
81 81
         $this->MySQLRepository = new MySQLRepository($this->connection);
Please login to merge, or discard this patch.