@@ -290,9 +290,9 @@ discard block |
||
| 290 | 290 | |
| 291 | 291 | |
| 292 | 292 | if (is_object($done['handle'])) { |
| 293 | - $key = spl_object_id( $done['handle'] ); |
|
| 293 | + $key = spl_object_id($done['handle']); |
|
| 294 | 294 | } else { |
| 295 | - $key = (string) $done['handle'] ; |
|
| 295 | + $key = (string) $done['handle']; |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | $task_id = $this->handleMapTasks[$key]; |
@@ -374,9 +374,9 @@ discard block |
||
| 374 | 374 | curl_multi_add_handle($this->handlerMulti(), $h); |
| 375 | 375 | |
| 376 | 376 | if (is_object($h)) { |
| 377 | - $key = spl_object_id( $h ); |
|
| 377 | + $key = spl_object_id($h); |
|
| 378 | 378 | } else { |
| 379 | - $key = (string) $h ; |
|
| 379 | + $key = (string) $h; |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | $this->handleMapTasks[$key] = $task_id; |
@@ -379,7 +379,9 @@ |
||
| 379 | 379 | return null; |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | - if (!$key) return $this->statistics; |
|
| 382 | + if (!$key) { |
|
| 383 | + return $this->statistics; |
|
| 384 | + } |
|
| 383 | 385 | |
| 384 | 386 | if (!isset($this->statistics[$key])) { |
| 385 | 387 | return null; |
@@ -536,7 +536,7 @@ |
||
| 536 | 536 | |
| 537 | 537 | /** |
| 538 | 538 | * @return false|string |
| 539 | - */ |
|
| 539 | + */ |
|
| 540 | 540 | public function jsonRows() |
| 541 | 541 | { |
| 542 | 542 | return json_encode($this->rows(), JSON_PRETTY_PRINT); |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | |
| 160 | 160 | try { |
| 161 | 161 | json_decode($body, true, 512, JSON_THROW_ON_ERROR); |
| 162 | - } catch (\JsonException $e) { |
|
| 162 | + }catch (\JsonException $e) { |
|
| 163 | 163 | return true; |
| 164 | 164 | } |
| 165 | 165 | |
@@ -274,8 +274,8 @@ discard block |
||
| 274 | 274 | foreach (['meta', 'data', 'totals', 'extremes', 'rows', 'rows_before_limit_at_least', 'statistics'] as $key) { |
| 275 | 275 | |
| 276 | 276 | if (isset($this->_rawData[$key])) { |
| 277 | - if ($key=='data') { |
|
| 278 | - $data=$this->_rawData[$key]; |
|
| 277 | + if ($key == 'data') { |
|
| 278 | + $data = $this->_rawData[$key]; |
|
| 279 | 279 | } else { |
| 280 | 280 | $this->{$key} = $this->_rawData[$key]; |
| 281 | 281 | } |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | throw new QueryException('Can`t find meta'); |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - $isJSONCompact=(stripos($this->format,'JSONCompact')!==false?true:false); |
|
| 289 | + $isJSONCompact = (stripos($this->format, 'JSONCompact') !== false ?true:false); |
|
| 290 | 290 | $this->array_data = []; |
| 291 | 291 | foreach ($data as $rows) { |
| 292 | 292 | $r = []; |
@@ -440,14 +440,14 @@ discard block |
||
| 440 | 440 | */ |
| 441 | 441 | public function resetIterator() |
| 442 | 442 | { |
| 443 | - $this->iterator=0; |
|
| 443 | + $this->iterator = 0; |
|
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | public function fetchRow($key = null) |
| 447 | 447 | { |
| 448 | 448 | $this->init(); |
| 449 | 449 | |
| 450 | - $position=$this->iterator; |
|
| 450 | + $position = $this->iterator; |
|
| 451 | 451 | |
| 452 | 452 | if (!isset($this->array_data[$position])) { |
| 453 | 453 | return null; |
@@ -743,7 +743,9 @@ |
||
| 743 | 743 | public function ping(bool $throwException=false): bool |
| 744 | 744 | { |
| 745 | 745 | $result=$this->transport()->ping(); |
| 746 | - if ($throwException && !$result) throw new TransportException('Can`t ping server'); |
|
| 746 | + if ($throwException && !$result) { |
|
| 747 | + throw new TransportException('Can`t ping server'); |
|
| 748 | + } |
|
| 747 | 749 | return $result; |
| 748 | 750 | } |
| 749 | 751 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | class Client |
| 40 | 40 | { |
| 41 | - const SUPPORTED_FORMATS = ['TabSeparated', 'TabSeparatedWithNames', 'CSV', 'CSVWithNames', 'JSONEachRow','CSVWithNamesAndTypes','TSVWithNamesAndTypes']; |
|
| 41 | + const SUPPORTED_FORMATS = ['TabSeparated', 'TabSeparatedWithNames', 'CSV', 'CSVWithNames', 'JSONEachRow', 'CSVWithNamesAndTypes', 'TSVWithNamesAndTypes']; |
|
| 42 | 42 | |
| 43 | 43 | /** @var Http */ |
| 44 | 44 | private $transport; |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | */ |
| 345 | 345 | public function enableLogQueries(bool $flag = true) |
| 346 | 346 | { |
| 347 | - $this->settings()->set('log_queries', (int)$flag); |
|
| 347 | + $this->settings()->set('log_queries', (int) $flag); |
|
| 348 | 348 | |
| 349 | 349 | return $this; |
| 350 | 350 | } |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | */ |
| 381 | 381 | public function enableExtremes(bool $flag = true) |
| 382 | 382 | { |
| 383 | - $this->settings()->set('extremes', (int)$flag); |
|
| 383 | + $this->settings()->set('extremes', (int) $flag); |
|
| 384 | 384 | |
| 385 | 385 | return $this; |
| 386 | 386 | } |
@@ -743,9 +743,9 @@ discard block |
||
| 743 | 743 | * @return bool |
| 744 | 744 | * @throws TransportException |
| 745 | 745 | */ |
| 746 | - public function ping(bool $throwException=false): bool |
|
| 746 | + public function ping(bool $throwException = false): bool |
|
| 747 | 747 | { |
| 748 | - $result=$this->transport()->ping(); |
|
| 748 | + $result = $this->transport()->ping(); |
|
| 749 | 749 | if ($throwException && !$result) throw new TransportException('Can`t ping server'); |
| 750 | 750 | return $result; |
| 751 | 751 | } |
@@ -814,7 +814,7 @@ discard block |
||
| 814 | 814 | public function partitions(string $table, int $limit = null, bool $active = null) |
| 815 | 815 | { |
| 816 | 816 | $database = $this->settings()->getDatabase(); |
| 817 | - $whereActiveClause = $active === null ? '' : sprintf(' AND active = %s', (int)$active); |
|
| 817 | + $whereActiveClause = $active === null ? '' : sprintf(' AND active = %s', (int) $active); |
|
| 818 | 818 | $limitClause = $limit !== null ? ' LIMIT ' . $limit : ''; |
| 819 | 819 | |
| 820 | 820 | return $this->select(<<<CLICKHOUSE |
@@ -885,7 +885,7 @@ discard block |
||
| 885 | 885 | */ |
| 886 | 886 | public function getServerVersion(): string |
| 887 | 887 | { |
| 888 | - return (string)$this->select('SELECT version() as version')->fetchOne('version'); |
|
| 888 | + return (string) $this->select('SELECT version() as version')->fetchOne('version'); |
|
| 889 | 889 | } |
| 890 | 890 | |
| 891 | 891 | /** |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | public function setStdErrOut($stream) |
| 308 | 308 | { |
| 309 | 309 | if (is_resource($stream)) { |
| 310 | - $this->stdErrOut=$stream; |
|
| 310 | + $this->stdErrOut = $stream; |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | } |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | */ |
| 494 | 494 | public function connectTimeOut(float $seconds = 1.0) |
| 495 | 495 | { |
| 496 | - $this->options[CURLOPT_CONNECTTIMEOUT_MS] = (int) ($seconds*1000.0); |
|
| 496 | + $this->options[CURLOPT_CONNECTTIMEOUT_MS] = (int) ($seconds * 1000.0); |
|
| 497 | 497 | return $this; |
| 498 | 498 | } |
| 499 | 499 | |
@@ -736,7 +736,7 @@ discard block |
||
| 736 | 736 | $curl_opt[CURLOPT_POSTFIELDS] = $this->parameters; |
| 737 | 737 | |
| 738 | 738 | if (!is_array($this->parameters)) { |
| 739 | - $this->header('Content-Length', mb_strlen($this->parameters, '8bit')); |
|
| 739 | + $this->header('Content-Length', mb_strlen($this->parameters, '8bit')); |
|
| 740 | 740 | } |
| 741 | 741 | } |
| 742 | 742 | } |
@@ -767,9 +767,9 @@ discard block |
||
| 767 | 767 | } |
| 768 | 768 | |
| 769 | 769 | if ($this->options[CURLOPT_VERBOSE]) { |
| 770 | - $msg="\n-----------BODY REQUEST----------\n" . $curl_opt[CURLOPT_POSTFIELDS] . "\n------END--------\n"; |
|
| 770 | + $msg = "\n-----------BODY REQUEST----------\n" . $curl_opt[CURLOPT_POSTFIELDS] . "\n------END--------\n"; |
|
| 771 | 771 | if ($this->stdErrOut && is_resource($this->stdErrOut)) { |
| 772 | - fwrite($this->stdErrOut,$msg); |
|
| 772 | + fwrite($this->stdErrOut, $msg); |
|
| 773 | 773 | } else { |
| 774 | 774 | echo $msg; |
| 775 | 775 | } |
@@ -777,7 +777,7 @@ discard block |
||
| 777 | 777 | |
| 778 | 778 | if ($this->stdErrOut) { |
| 779 | 779 | if (is_resource($this->stdErrOut)) { |
| 780 | - $curl_opt[CURLOPT_STDERR]=$this->stdErrOut; |
|
| 780 | + $curl_opt[CURLOPT_STDERR] = $this->stdErrOut; |
|
| 781 | 781 | } |
| 782 | 782 | } |
| 783 | 783 | |
@@ -180,7 +180,7 @@ |
||
| 180 | 180 | */ |
| 181 | 181 | public function max_execution_time(int $time) |
| 182 | 182 | { |
| 183 | - $this->set('max_execution_time',$time); |
|
| 183 | + $this->set('max_execution_time', $time); |
|
| 184 | 184 | return $this; |
| 185 | 185 | } |
| 186 | 186 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | private $degenerations = []; |
| 24 | 24 | |
| 25 | - private $supportFormats=[ |
|
| 25 | + private $supportFormats = [ |
|
| 26 | 26 | "FORMAT\\s+TSVRaw", |
| 27 | 27 | "FORMAT\\s+TSVWithNamesAndTypes", |
| 28 | 28 | "FORMAT\\s+TSVWithNames", |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | if (null === $this->format) { |
| 72 | 72 | return false; |
| 73 | 73 | } |
| 74 | - $supportFormats = implode("|",$this->supportFormats); |
|
| 74 | + $supportFormats = implode("|", $this->supportFormats); |
|
| 75 | 75 | |
| 76 | 76 | $this->sql = trim($this->sql); |
| 77 | 77 | if (substr($this->sql, -1) == ';') { |
@@ -110,16 +110,16 @@ discard block |
||
| 110 | 110 | public function isUseInUrlBindingsParams():bool |
| 111 | 111 | { |
| 112 | 112 | // 'query=select {p1:UInt8} + {p2:UInt8}' -F "param_p1=3" -F "param_p2=4" |
| 113 | - return preg_match('#{[\w+]+:[\w+()]+}#',$this->sql); |
|
| 113 | + return preg_match('#{[\w+]+:[\w+()]+}#', $this->sql); |
|
| 114 | 114 | |
| 115 | 115 | } |
| 116 | 116 | public function getUrlBindingsParams():array |
| 117 | 117 | { |
| 118 | - $out=[]; |
|
| 118 | + $out = []; |
|
| 119 | 119 | if (sizeof($this->degenerations)) { |
| 120 | 120 | foreach ($this->degenerations as $degeneration) { |
| 121 | 121 | if ($degeneration instanceof Degeneration) { |
| 122 | - $params=$degeneration->getBind(); |
|
| 122 | + $params = $degeneration->getBind(); |
|
| 123 | 123 | break; |
| 124 | 124 | // need first response |
| 125 | 125 | } |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | if (sizeof($params)) { |
| 129 | 129 | foreach ($params as $key=>$value) |
| 130 | 130 | { |
| 131 | - $out['param_'.$key]=$value; |
|
| 131 | + $out['param_' . $key] = $value; |
|
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | 134 | return $out; |