@@ -277,7 +277,7 @@ discard block |
||
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 |
||
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(); |
@@ -9,7 +9,7 @@ |
||
9 | 9 | class StreamWrite extends Stream |
10 | 10 | { |
11 | 11 | |
12 | - public function __construct( $source) |
|
12 | + public function __construct($source) |
|
13 | 13 | { |
14 | 14 | |
15 | 15 | parent::__construct($source); |
@@ -31,7 +31,7 @@ |
||
31 | 31 | * @param CurlerRequest $request |
32 | 32 | * @param CurlerRolling|null $curlerRolling |
33 | 33 | */ |
34 | - public function __construct($source, CurlerRequest $request, $curlerRolling=null) |
|
34 | + public function __construct($source, CurlerRequest $request, $curlerRolling = null) |
|
35 | 35 | { |
36 | 36 | if (!is_resource($source)) { |
37 | 37 | throw new \InvalidArgumentException('Argument $source must be resource'); |
@@ -293,7 +293,7 @@ |
||
293 | 293 | |
294 | 294 | if (stripos($format, 'json') !== false) |
295 | 295 | { |
296 | - if (stripos($format,'JSONEachRow')===false) |
|
296 | + if (stripos($format, 'JSONEachRow') === false) |
|
297 | 297 | return $this->json(); |
298 | 298 | } |
299 | 299 | return $this->body(); |
@@ -293,8 +293,9 @@ |
||
293 | 293 | |
294 | 294 | if (stripos($format, 'json') !== false) |
295 | 295 | { |
296 | - if (stripos($format,'JSONEachRow')===false) |
|
297 | - return $this->json(); |
|
296 | + if (stripos($format,'JSONEachRow')===false) { |
|
297 | + return $this->json(); |
|
298 | + } |
|
298 | 299 | } |
299 | 300 | return $this->body(); |
300 | 301 |
@@ -650,8 +650,9 @@ |
||
650 | 650 | } |
651 | 651 | return $response; |
652 | 652 | } finally { |
653 | - if ($streamRW->isWrite()) |
|
654 | - fclose($stream); |
|
653 | + if ($streamRW->isWrite()) { |
|
654 | + fclose($stream); |
|
655 | + } |
|
655 | 656 | } |
656 | 657 | |
657 | 658 |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | /** |
93 | 93 | * @param CurlerRolling $curler |
94 | 94 | */ |
95 | - public function setDirtyCurler(CurlerRolling $curler){ |
|
96 | - if ($curler instanceof CurlerRolling){ |
|
95 | + public function setDirtyCurler(CurlerRolling $curler) { |
|
96 | + if ($curler instanceof CurlerRolling) { |
|
97 | 97 | $this->_curler = $curler; |
98 | 98 | } |
99 | 99 | } |
@@ -129,10 +129,10 @@ discard block |
||
129 | 129 | $proto = 'https'; |
130 | 130 | } |
131 | 131 | $uri = $proto . '://' . $this->_host; |
132 | - if (stripos($this->_host,'/')!==false || stripos($this->_host,':')!==false) { |
|
132 | + if (stripos($this->_host, '/') !== false || stripos($this->_host, ':') !== false) { |
|
133 | 133 | return $uri; |
134 | 134 | } |
135 | - if (intval($this->_port)>0) { |
|
135 | + if (intval($this->_port) > 0) { |
|
136 | 136 | return $uri . ':' . $this->_port; |
137 | 137 | } |
138 | 138 | return $uri; |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | } |
205 | 205 | |
206 | 206 | $new->timeOut($this->settings()->getTimeOut()); |
207 | - $new->connectTimeOut($this->_connectTimeOut);//->keepAlive(); // one sec |
|
207 | + $new->connectTimeOut($this->_connectTimeOut); //->keepAlive(); // one sec |
|
208 | 208 | $new->verbose(boolval($this->_verbose)); |
209 | 209 | |
210 | 210 | return $new; |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | { |
258 | 258 | |
259 | 259 | if ($sql instanceof Query) { |
260 | - $query=$sql; |
|
260 | + $query = $sql; |
|
261 | 261 | } else { |
262 | 262 | $query = new Query($sql); |
263 | 263 | } |
@@ -619,10 +619,10 @@ discard block |
||
619 | 619 | * @return Statement |
620 | 620 | * @throws \ClickHouseDB\Exception\TransportException |
621 | 621 | */ |
622 | - private function streaming(Stream $streamRW,CurlerRequest $request) |
|
622 | + private function streaming(Stream $streamRW, CurlerRequest $request) |
|
623 | 623 | { |
624 | - $callable=$streamRW->getClosure(); |
|
625 | - $stream=$streamRW->getStream(); |
|
624 | + $callable = $streamRW->getClosure(); |
|
625 | + $stream = $streamRW->getStream(); |
|
626 | 626 | |
627 | 627 | |
628 | 628 | |
@@ -633,11 +633,11 @@ discard block |
||
633 | 633 | if ($streamRW->isWrite()) |
634 | 634 | { |
635 | 635 | |
636 | - $callable = function ($ch, $fd, $length) use ($stream) { |
|
636 | + $callable = function($ch, $fd, $length) use ($stream) { |
|
637 | 637 | return ($line = fread($stream, $length)) ? $line : ''; |
638 | 638 | }; |
639 | 639 | } else { |
640 | - $callable = function ($ch, $fd) use ($stream) { |
|
640 | + $callable = function($ch, $fd) use ($stream) { |
|
641 | 641 | return fwrite($stream, $fd); |
642 | 642 | }; |
643 | 643 | } |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | } |
673 | 673 | |
674 | 674 | |
675 | - $this->_curler->execOne($request,true); |
|
675 | + $this->_curler->execOne($request, true); |
|
676 | 676 | $response = new Statement($request); |
677 | 677 | if ($response->isError()) { |
678 | 678 | $response->error(); |
@@ -694,11 +694,11 @@ discard block |
||
694 | 694 | * @return Statement |
695 | 695 | * @throws \ClickHouseDB\Exception\TransportException |
696 | 696 | */ |
697 | - public function streamRead(Stream $streamRead,$sql,$bindings=[]) |
|
697 | + public function streamRead(Stream $streamRead, $sql, $bindings = []) |
|
698 | 698 | { |
699 | - $sql=$this->prepareQuery($sql,$bindings); |
|
700 | - $request=$this->getRequestRead($sql); |
|
701 | - return $this->streaming($streamRead,$request); |
|
699 | + $sql = $this->prepareQuery($sql, $bindings); |
|
700 | + $request = $this->getRequestRead($sql); |
|
701 | + return $this->streaming($streamRead, $request); |
|
702 | 702 | |
703 | 703 | } |
704 | 704 | |
@@ -709,10 +709,10 @@ discard block |
||
709 | 709 | * @return Statement |
710 | 710 | * @throws \ClickHouseDB\Exception\TransportException |
711 | 711 | */ |
712 | - public function streamWrite(Stream $streamWrite,$sql,$bindings=[]) |
|
712 | + public function streamWrite(Stream $streamWrite, $sql, $bindings = []) |
|
713 | 713 | { |
714 | - $sql=$this->prepareQuery($sql,$bindings); |
|
714 | + $sql = $this->prepareQuery($sql, $bindings); |
|
715 | 715 | $request = $this->writeStreamData($sql); |
716 | - return $this->streaming($streamWrite,$request); |
|
716 | + return $this->streaming($streamWrite, $request); |
|
717 | 717 | } |
718 | 718 | } |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * @var bool |
17 | 17 | */ |
18 | - private $gzip=false; |
|
18 | + private $gzip = false; |
|
19 | 19 | /** |
20 | 20 | * @var null|callable |
21 | 21 | */ |
22 | - private $callable=null; |
|
22 | + private $callable = null; |
|
23 | 23 | /** |
24 | 24 | * @param resource $source |
25 | 25 | */ |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function closure(callable $callable) |
62 | 62 | { |
63 | - $this->callable=$callable; |
|
63 | + $this->callable = $callable; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function enableGzipHeader() |
70 | 70 | { |
71 | - $this->gzip=true; |
|
71 | + $this->gzip = true; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | } |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | * @param string $pattern |
57 | 57 | * @return string |
58 | 58 | */ |
59 | - public function compile_binds($sql, $binds,$pattern) |
|
59 | + public function compile_binds($sql, $binds, $pattern) |
|
60 | 60 | { |
61 | 61 | return preg_replace_callback($pattern, function($m) use ($binds){ |
62 | - if(isset($binds[$m[1]])){ // If it exists in our array |
|
62 | + if (isset($binds[$m[1]])) { // If it exists in our array |
|
63 | 63 | return $binds[$m[1]]; // Then replace it from our array |
64 | 64 | } |
65 | 65 | |
@@ -75,14 +75,14 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function process($sql) |
77 | 77 | { |
78 | - $bindFormatted=[]; |
|
79 | - $bindRaw=[]; |
|
78 | + $bindFormatted = []; |
|
79 | + $bindRaw = []; |
|
80 | 80 | foreach ($this->bindings as $key => $value) { |
81 | 81 | if (is_array($value)) { |
82 | 82 | $valueSet = implode(', ', $value); |
83 | 83 | |
84 | 84 | $values = array_map( |
85 | - function ($value) { |
|
85 | + function($value) { |
|
86 | 86 | return ValueFormatter::formatValue($value); |
87 | 87 | }, |
88 | 88 | $value |
@@ -95,21 +95,21 @@ discard block |
||
95 | 95 | } |
96 | 96 | |
97 | 97 | if ($formattedParameter !== null) { |
98 | - $bindFormatted[$key]=$formattedParameter; |
|
98 | + $bindFormatted[$key] = $formattedParameter; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | if ($valueSet !== null) { |
102 | - $bindRaw[$key]=$valueSet; |
|
102 | + $bindRaw[$key] = $valueSet; |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
106 | - for ($loop=0;$loop<2;$loop++) |
|
106 | + for ($loop = 0; $loop < 2; $loop++) |
|
107 | 107 | { |
108 | 108 | // dipping in binds |
109 | 109 | // example ['A' => '{B}' , 'B'=>':C','C'=>123] |
110 | - $sql=$this->compile_binds($sql,$bindRaw,'#{([\w+]+)}#'); |
|
110 | + $sql = $this->compile_binds($sql, $bindRaw, '#{([\w+]+)}#'); |
|
111 | 111 | } |
112 | - $sql=$this->compile_binds($sql,$bindFormatted,'#:([\w+]+)#'); |
|
112 | + $sql = $this->compile_binds($sql, $bindFormatted, '#:([\w+]+)#'); |
|
113 | 113 | |
114 | 114 | return $sql; |
115 | 115 | } |
@@ -80,8 +80,8 @@ |
||
80 | 80 | // Elements of the array - the numbers are formatted as usual, and the dates, dates-with-time, and lines are in |
81 | 81 | // single quotation marks with the same screening rules as above. |
82 | 82 | // as in the TabSeparated format, and then the resulting string is output in InsertRow in double quotes. |
83 | - $value = array_map( |
|
84 | - function ($v) use ($enclosure_esc, $encode_esc) { |
|
83 | + $value = array_map( |
|
84 | + function($v) use ($enclosure_esc, $encode_esc) { |
|
85 | 85 | return is_string($v) ? $this->encodeString($v, $enclosure_esc, $encode_esc) : $v; |
86 | 86 | }, |
87 | 87 | $value |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | */ |
238 | 238 | public function setWriteFunction($callback) |
239 | 239 | { |
240 | - $this->options[CURLOPT_WRITEFUNCTION]=$callback; |
|
240 | + $this->options[CURLOPT_WRITEFUNCTION] = $callback; |
|
241 | 241 | } |
242 | 242 | /** |
243 | 243 | * @param callable $callback |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | */ |
613 | 613 | public function response() |
614 | 614 | { |
615 | - if (! $this->response) { |
|
615 | + if (!$this->response) { |
|
616 | 616 | throw new \ClickHouseDB\Exception\TransportException('Can`t fetch response - is empty'); |
617 | 617 | } |
618 | 618 | |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | |
709 | 709 | if (!empty($curl_opt[CURLOPT_WRITEFUNCTION])) |
710 | 710 | { |
711 | - $curl_opt[CURLOPT_HEADER]=false; |
|
711 | + $curl_opt[CURLOPT_HEADER] = false; |
|
712 | 712 | } |
713 | 713 | |
714 | 714 | if ($this->resultFileHandle) { |