Passed
Push — master ( 5a27f9...28edde )
by Igor
02:52
created
src/Client.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -546,17 +546,17 @@  discard block
 block discarded – undo
546 546
       */
547 547
     public function prepareInsertAssocBulk(array $values)
548 548
     {
549
-        if (isset($values[0]) && is_array($values[0])){ //случай, когда много строк вставляется
549
+        if (isset($values[0]) && is_array($values[0])) { //случай, когда много строк вставляется
550 550
             $preparedFields = array_keys($values[0]);
551 551
             $preparedValues = [];
552
-            foreach ($values as $idx => $row){
552
+            foreach ($values as $idx => $row) {
553 553
                 $_fields = array_keys($row);
554
-                if ($_fields !== $preparedFields){
555
-                    throw new QueryException("Fields not match: ".implode(',',$_fields)." and ".implode(',', $preparedFields)." on element $idx");
554
+                if ($_fields !== $preparedFields) {
555
+                    throw new QueryException("Fields not match: " . implode(',', $_fields) . " and " . implode(',', $preparedFields) . " on element $idx");
556 556
                 }
557 557
                 $preparedValues[] = array_values($row);
558 558
             }
559
-        } else{ //одна строка
559
+        } else { //одна строка
560 560
             $preparedFields = array_keys($values);
561 561
             $preparedValues = [array_values($values)];
562 562
         }
@@ -621,16 +621,16 @@  discard block
 block discarded – undo
621 621
 
622 622
         foreach ($file_names as $fileName) {
623 623
             if (!is_file($fileName) || !is_readable($fileName)) {
624
-                throw  new QueryException('Cant read file: ' . $fileName.' '.(is_file($fileName)?'':' is not file'));
624
+                throw  new QueryException('Cant read file: ' . $fileName . ' ' . (is_file($fileName) ? '' : ' is not file'));
625 625
             }
626 626
 
627 627
             if (!$columns_array)
628 628
             {
629
-                $sql = 'INSERT INTO ' . $table_name . ' FORMAT '.$format;
629
+                $sql = 'INSERT INTO ' . $table_name . ' FORMAT ' . $format;
630 630
 
631 631
             } else
632 632
             {
633
-                $sql = 'INSERT INTO ' . $table_name . ' ( ' . implode(',', $columns_array) . ' ) FORMAT '.$format;
633
+                $sql = 'INSERT INTO ' . $table_name . ' ( ' . implode(',', $columns_array) . ' ) FORMAT ' . $format;
634 634
 
635 635
             }
636 636
             $result[$fileName] = $this->transport()->writeAsyncCSV($sql, $fileName);
@@ -657,24 +657,24 @@  discard block
 block discarded – undo
657 657
      * @param string $format ['TabSeparated','TabSeparatedWithNames','CSV','CSVWithNames']
658 658
      * @return Transport\CurlerRequest
659 659
      */
660
-    public function insertBatchStream($table_name, $columns_array,$format="CSV")
660
+    public function insertBatchStream($table_name, $columns_array, $format = "CSV")
661 661
     {
662 662
         if ($this->getCountPendingQueue() > 0) {
663 663
             throw new QueryException('Queue must be empty, before insertBatch, need executeAsync');
664 664
         }
665 665
 
666
-        if (!in_array($format,$this->_support_format))
666
+        if (!in_array($format, $this->_support_format))
667 667
         {
668 668
             throw new QueryException('Format not support in insertBatchFiles');
669 669
         }
670 670
 
671 671
         if (!$columns_array)
672 672
         {
673
-            $sql = 'INSERT INTO ' . $table_name . ' FORMAT '.$format;
673
+            $sql = 'INSERT INTO ' . $table_name . ' FORMAT ' . $format;
674 674
 
675 675
         } else
676 676
         {
677
-            $sql = 'INSERT INTO ' . $table_name . ' ( ' . implode(',', $columns_array) . ' ) FORMAT '.$format;
677
+            $sql = 'INSERT INTO ' . $table_name . ' ( ' . implode(',', $columns_array) . ' ) FORMAT ' . $format;
678 678
 
679 679
         }
680 680
 
Please login to merge, or discard this patch.
src/Transport/CurlerRequest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -363,9 +363,9 @@
 block discarded – undo
363 363
      */
364 364
     public function getHeaders()
365 365
     {
366
-        $head=[];
366
+        $head = [];
367 367
         foreach ($this->headers as $key=>$value) {
368
-                    $head[]= sprintf("%s: %s", $key, $value);
368
+                    $head[] = sprintf("%s: %s", $key, $value);
369 369
         }
370 370
         return $head;
371 371
     }
Please login to merge, or discard this patch.
src/Transport/Http.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
      */
114 114
     public function getUri()
115 115
     {
116
-        $proto='http';
116
+        $proto = 'http';
117 117
         if ($this->settings()->isHttps()) {
118
-            $proto='https';
118
+            $proto = 'https';
119 119
         }
120 120
 
121
-        return $proto.'://' . $this->_host . ':' . $this->_port;
121
+        return $proto . '://' . $this->_host . ':' . $this->_port;
122 122
     }
123 123
 
124 124
     /**
@@ -324,10 +324,10 @@  discard block
 block discarded – undo
324 324
 
325 325
     public function __findXClickHouseProgress($handle)
326 326
     {
327
-        $code=curl_getinfo($handle,CURLINFO_HTTP_CODE);
327
+        $code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
328 328
 
329 329
         // Search X-ClickHouse-Progress
330
-        if ($code==200) {
330
+        if ($code == 200) {
331 331
             $response = curl_multi_getcontent($handle);
332 332
             $header_size = curl_getinfo($handle, CURLINFO_HEADER_SIZE);
333 333
             if (!$header_size) {
@@ -338,21 +338,21 @@  discard block
 block discarded – undo
338 338
             if (!$header_size) {
339 339
                 return false;
340 340
             }
341
-            $pos=strrpos($header,'X-ClickHouse-Progress');
341
+            $pos = strrpos($header, 'X-ClickHouse-Progress');
342 342
 
343 343
             if (!$pos) {
344 344
                 return false;
345 345
             }
346 346
 
347
-            $last=substr($header,$pos);
348
-            $data=@json_decode(str_ireplace('X-ClickHouse-Progress:','',$last),true);
347
+            $last = substr($header, $pos);
348
+            $data = @json_decode(str_ireplace('X-ClickHouse-Progress:', '', $last), true);
349 349
 
350 350
             if ($data && is_callable($this->xClickHouseProgress)) {
351 351
 
352
-                if (is_array($this->xClickHouseProgress)){
353
-                    call_user_func_array($this->xClickHouseProgress,[$data]);
352
+                if (is_array($this->xClickHouseProgress)) {
353
+                    call_user_func_array($this->xClickHouseProgress, [$data]);
354 354
                 } else {
355
-                    call_user_func($this->xClickHouseProgress,$data);
355
+                    call_user_func($this->xClickHouseProgress, $data);
356 356
                 }
357 357
 
358 358
 
Please login to merge, or discard this patch.
src/Cluster.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -371,22 +371,22 @@  discard block
 block discarded – undo
371 371
      * @return Client
372 372
      * @throws Exception\TransportException
373 373
      */
374
-    public function clientLike($cluster,$ip_addr_like)
374
+    public function clientLike($cluster, $ip_addr_like)
375 375
     {
376
-        $nodes_check=$this->nodes;
377
-        $nodes=$this->getClusterNodes($cluster);
378
-        $list_ips_need=explode(';',$ip_addr_like);
379
-        $find=false;
380
-        foreach($list_ips_need as $like)
376
+        $nodes_check = $this->nodes;
377
+        $nodes = $this->getClusterNodes($cluster);
378
+        $list_ips_need = explode(';', $ip_addr_like);
379
+        $find = false;
380
+        foreach ($list_ips_need as $like)
381 381
         {
382 382
             foreach ($nodes as $node)
383 383
             {
384 384
 
385
-                if (stripos($node,$like)!==false)
385
+                if (stripos($node, $like) !== false)
386 386
                 {
387
-                    if (in_array($node,$nodes_check))
387
+                    if (in_array($node, $nodes_check))
388 388
                     {
389
-                        $find=$node;
389
+                        $find = $node;
390 390
                     } else
391 391
                     {
392 392
                         // node exists on cluster, but not check
@@ -495,10 +495,10 @@  discard block
 block discarded – undo
495 495
 
496 496
                 if ($resultDetail)
497 497
                 {
498
-                    $list[$db_name.'.'.$table_name]=$nodes;
498
+                    $list[$db_name . '.' . $table_name] = $nodes;
499 499
                 } else
500 500
                 {
501
-                    $list[$db_name.'.'.$table_name]=array_keys($nodes);
501
+                    $list[$db_name . '.' . $table_name] = array_keys($nodes);
502 502
                 }
503 503
             }
504 504
         }
@@ -515,23 +515,23 @@  discard block
 block discarded – undo
515 515
      */
516 516
     public function getSizeTable($database_table)
517 517
     {
518
-        $nodes=$this->getNodesByTable($database_table);
518
+        $nodes = $this->getNodesByTable($database_table);
519 519
         // scan need node`s
520 520
         foreach ($nodes as $node)
521 521
         {
522 522
             if (empty($this->_table_size_cache[$node]))
523 523
             {
524
-                $this->_table_size_cache[$node]=$this->client($node)->tablesSize(true);
524
+                $this->_table_size_cache[$node] = $this->client($node)->tablesSize(true);
525 525
             }
526 526
         }
527 527
 
528
-        $sizes=[];
528
+        $sizes = [];
529 529
         foreach ($this->_table_size_cache as $node=>$rows)
530 530
         {
531 531
             foreach ($rows as $row)
532 532
             {
533
-                $sizes[$row['database'].'.'.$row['table']][$node]=$row;
534
-                @$sizes[$row['database'].'.'.$row['table']]['total']['sizebytes']+=$row['sizebytes'];
533
+                $sizes[$row['database'] . '.' . $row['table']][$node] = $row;
534
+                @$sizes[$row['database'] . '.' . $row['table']]['total']['sizebytes'] += $row['sizebytes'];
535 535
 
536 536
 
537 537
 
@@ -578,18 +578,18 @@  discard block
 block discarded – undo
578 578
      */
579 579
     public function getMasterNodeForTable($database_table)
580 580
     {
581
-        $list=$this->getTables(true);
581
+        $list = $this->getTables(true);
582 582
 
583 583
         if (empty($list[$database_table])) {
584 584
             return [];
585 585
         }
586 586
 
587 587
 
588
-        $result=[];
588
+        $result = [];
589 589
         foreach ($list[$database_table] as $node=>$row)
590 590
         {
591 591
             if ($row['is_leader']) {
592
-                $result[]=$node;
592
+                $result[] = $node;
593 593
             }
594 594
         }
595 595
         return $result;
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
                     $tables[$row['database']][$row['table']][$node] = $row;
278 278
                 }
279 279
                 $result['replicas'][$node] = $r;
280
-            }catch (\Exception $E) {
280
+            } catch (\Exception $E) {
281 281
                 $result['replicas'][$node] = false;
282 282
                 $badNodes[$node] = $E->getMessage();
283 283
                 $this->error[] = 'statementsReplicas:' . $E->getMessage();
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
                         ];
300 300
                 }
301 301
 
302
-            }catch (\Exception $E) {
302
+            } catch (\Exception $E) {
303 303
                 $result['clusters'][$node] = false;
304 304
 
305 305
                 $this->error[] = 'clusters:' . $E->getMessage();
Please login to merge, or discard this patch.
src/Query/Query.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -52,17 +52,17 @@
 block discarded – undo
52 52
         if (null === $this->format) {
53 53
             return false;
54 54
         }
55
-        $supportFormats=
55
+        $supportFormats =
56 56
             "FORMAT\\s+TSV|FORMAT\\s+TSVRaw|FORMAT\\s+TSVWithNames|FORMAT\\s+TSVWithNamesAndTypes|FORMAT\\s+Vertical|FORMAT\\s+JSONCompact|FORMAT\\s+JSONEachRow|FORMAT\\s+TSKV|FORMAT\\s+TabSeparatedWithNames|FORMAT\\s+TabSeparatedWithNamesAndTypes|FORMAT\\s+TabSeparatedRaw|FORMAT\\s+BlockTabSeparated|FORMAT\\s+CSVWithNames|FORMAT\\s+CSV|FORMAT\\s+JSON|FORMAT\\s+TabSeparated";
57 57
 
58
-        $matches=[];
59
-        if (preg_match_all('%('.$supportFormats.')%ius',$this->sql,$matches)){
58
+        $matches = [];
59
+        if (preg_match_all('%(' . $supportFormats . ')%ius', $this->sql, $matches)) {
60 60
 
61 61
             // skip add "format json"
62 62
             if (isset($matches[0]))
63 63
             {
64 64
 
65
-                $this->format=trim(str_ireplace('format','',$matches[0][0]));
65
+                $this->format = trim(str_ireplace('format', '', $matches[0][0]));
66 66
 
67 67
             }
68 68
         } else {
Please login to merge, or discard this patch.
src/Query/Degeneration/Conditions.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,8 +29,7 @@
 block discarded – undo
29 29
         if ($else)
30 30
         {
31 31
             list($condition, $preset, $variable, $content_true, $content_false) = $matches;
32
-        }
33
-        else
32
+        } else
34 33
         {
35 34
             list($condition, $preset, $variable, $content_true) = $matches;
36 35
         }
Please login to merge, or discard this patch.