Skip to content

Commit 1036690

Browse files
author
igor
committed
Add functions type in Http
1 parent 9a3a1b0 commit 1036690

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

src/Transport/Http.php

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,15 @@ public function __construct($host, $port, $username, $password, $authMethod = nu
115115
}
116116

117117

118-
public function setCurler()
118+
public function setCurler() : void
119119
{
120120
$this->_curler = new CurlerRolling();
121121
}
122122

123123
/**
124124
* @param CurlerRolling $curler
125125
*/
126-
public function setDirtyCurler(CurlerRolling $curler)
126+
public function setDirtyCurler(CurlerRolling $curler) : void
127127
{
128128
if ($curler instanceof CurlerRolling) {
129129
$this->_curler = $curler;
@@ -133,7 +133,7 @@ public function setDirtyCurler(CurlerRolling $curler)
133133
/**
134134
* @return CurlerRolling
135135
*/
136-
public function getCurler()
136+
public function getCurler(): ?CurlerRolling
137137
{
138138
return $this->_curler;
139139
}
@@ -142,7 +142,7 @@ public function getCurler()
142142
* @param string $host
143143
* @param int $port
144144
*/
145-
public function setHost($host, $port = -1)
145+
public function setHost(string $host, $port = -1) : void
146146
{
147147
if ($port > 0) {
148148
$this->_port = $port;
@@ -156,15 +156,15 @@ public function setHost($host, $port = -1)
156156
*
157157
* @param string $caPath
158158
*/
159-
public function setSslCa($caPath)
159+
public function setSslCa(string $caPath) : void
160160
{
161161
$this->sslCA = $caPath;
162162
}
163163

164164
/**
165165
* @return string
166166
*/
167-
public function getUri()
167+
public function getUri(): string
168168
{
169169
$proto = 'http';
170170
if ($this->settings()->isHttps()) {
@@ -183,7 +183,7 @@ public function getUri()
183183
/**
184184
* @return Settings
185185
*/
186-
public function settings()
186+
public function settings(): Settings
187187
{
188188
return $this->_settings;
189189
}
@@ -192,7 +192,7 @@ public function settings()
192192
* @param bool|int $flag
193193
* @return mixed
194194
*/
195-
public function verbose($flag)
195+
public function verbose($flag): mixed
196196
{
197197
$this->_verbose = $flag;
198198
return $flag;
@@ -202,7 +202,7 @@ public function verbose($flag)
202202
* @param array $params
203203
* @return string
204204
*/
205-
private function getUrl($params = [])
205+
private function getUrl($params = []): string
206206
{
207207
$settings = $this->settings()->getSettings();
208208

@@ -229,7 +229,7 @@ private function getUrl($params = [])
229229
* @param array $extendinfo
230230
* @return CurlerRequest
231231
*/
232-
private function newRequest($extendinfo)
232+
private function newRequest($extendinfo): CurlerRequest
233233
{
234234
$new = new CurlerRequest();
235235

@@ -276,7 +276,7 @@ private function newRequest($extendinfo)
276276
* @return CurlerRequest
277277
* @throws \ClickHouseDB\Exception\TransportException
278278
*/
279-
private function makeRequest(Query $query, $urlParams = [], $query_as_string = false)
279+
private function makeRequest(Query $query, $urlParams = [], $query_as_string = false): CurlerRequest
280280
{
281281
$sql = $query->toSql();
282282

@@ -314,7 +314,7 @@ private function makeRequest(Query $query, $urlParams = [], $query_as_string = f
314314
* @param string|Query $sql
315315
* @return CurlerRequest
316316
*/
317-
public function writeStreamData($sql)
317+
public function writeStreamData($sql): CurlerRequest
318318
{
319319

320320
if ($sql instanceof Query) {
@@ -351,7 +351,7 @@ public function writeStreamData($sql)
351351
* @return Statement
352352
* @throws \ClickHouseDB\Exception\TransportException
353353
*/
354-
public function writeAsyncCSV($sql, $file_name)
354+
public function writeAsyncCSV($sql, $file_name): Statement
355355
{
356356
$query = new Query($sql);
357357

@@ -392,7 +392,7 @@ public function writeAsyncCSV($sql, $file_name)
392392
*
393393
* @return int
394394
*/
395-
public function getCountPendingQueue()
395+
public function getCountPendingQueue(): int
396396
{
397397
return $this->_curler->countPending();
398398
}
@@ -402,7 +402,7 @@ public function getCountPendingQueue()
402402
*
403403
* @param int $connectTimeOut
404404
*/
405-
public function setConnectTimeOut($connectTimeOut)
405+
public function setConnectTimeOut(int $connectTimeOut)
406406
{
407407
$this->_connectTimeOut = $connectTimeOut;
408408
}
@@ -412,13 +412,13 @@ public function setConnectTimeOut($connectTimeOut)
412412
*
413413
* @return int
414414
*/
415-
public function getConnectTimeOut()
415+
public function getConnectTimeOut(): int
416416
{
417417
return $this->_connectTimeOut;
418418
}
419419

420420

421-
public function __findXClickHouseProgress($handle)
421+
public function __findXClickHouseProgress($handle): bool
422422
{
423423
$code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
424424

@@ -455,7 +455,7 @@ public function __findXClickHouseProgress($handle)
455455
}
456456

457457
}
458-
458+
return false;
459459
}
460460

461461
/**
@@ -465,7 +465,7 @@ public function __findXClickHouseProgress($handle)
465465
* @return CurlerRequest
466466
* @throws \Exception
467467
*/
468-
public function getRequestRead(Query $query, $whereInFile = null, $writeToFile = null)
468+
public function getRequestRead(Query $query, $whereInFile = null, $writeToFile = null): CurlerRequest
469469
{
470470
$urlParams = ['readonly' => 2];
471471
$query_as_string = false;
@@ -526,13 +526,13 @@ public function getRequestRead(Query $query, $whereInFile = null, $writeToFile =
526526

527527
}
528528

529-
public function cleanQueryDegeneration()
529+
public function cleanQueryDegeneration(): bool
530530
{
531531
$this->_query_degenerations = [];
532532
return true;
533533
}
534534

535-
public function addQueryDegeneration(Degeneration $degeneration)
535+
public function addQueryDegeneration(Degeneration $degeneration): bool
536536
{
537537
$this->_query_degenerations[] = $degeneration;
538538
return true;
@@ -543,7 +543,7 @@ public function addQueryDegeneration(Degeneration $degeneration)
543543
* @return CurlerRequest
544544
* @throws \ClickHouseDB\Exception\TransportException
545545
*/
546-
public function getRequestWrite(Query $query)
546+
public function getRequestWrite(Query $query): CurlerRequest
547547
{
548548
$urlParams = ['readonly' => 0];
549549
return $this->makeRequest($query, $urlParams);
@@ -566,7 +566,7 @@ public function ping(): bool
566566
* @param mixed[] $bindings
567567
* @return Query
568568
*/
569-
private function prepareQuery($sql, $bindings)
569+
private function prepareQuery($sql, $bindings): Query
570570
{
571571

572572
// add Degeneration query
@@ -586,7 +586,7 @@ private function prepareQuery($sql, $bindings)
586586
* @return CurlerRequest
587587
* @throws \Exception
588588
*/
589-
private function prepareSelect($sql, $bindings, $whereInFile, $writeToFile = null)
589+
private function prepareSelect($sql, $bindings, $whereInFile, $writeToFile = null): CurlerRequest
590590
{
591591
if ($sql instanceof Query) {
592592
return $this->getRequestWrite($sql);
@@ -603,7 +603,7 @@ private function prepareSelect($sql, $bindings, $whereInFile, $writeToFile = nul
603603
* @return CurlerRequest
604604
* @throws \ClickHouseDB\Exception\TransportException
605605
*/
606-
private function prepareWrite($sql, $bindings = [])
606+
private function prepareWrite($sql, $bindings = []): CurlerRequest
607607
{
608608
if ($sql instanceof Query) {
609609
return $this->getRequestWrite($sql);
@@ -617,7 +617,7 @@ private function prepareWrite($sql, $bindings = [])
617617
* @return bool
618618
* @throws \ClickHouseDB\Exception\TransportException
619619
*/
620-
public function executeAsync()
620+
public function executeAsync(): bool
621621
{
622622
return $this->_curler->execLoopWait();
623623
}
@@ -631,7 +631,7 @@ public function executeAsync()
631631
* @throws \ClickHouseDB\Exception\TransportException
632632
* @throws \Exception
633633
*/
634-
public function select($sql, array $bindings = [], $whereInFile = null, $writeToFile = null)
634+
public function select($sql, array $bindings = [], $whereInFile = null, $writeToFile = null): Statement
635635
{
636636
$request = $this->prepareSelect($sql, $bindings, $whereInFile, $writeToFile);
637637
$this->_curler->execOne($request);
@@ -647,7 +647,7 @@ public function select($sql, array $bindings = [], $whereInFile = null, $writeTo
647647
* @throws \ClickHouseDB\Exception\TransportException
648648
* @throws \Exception
649649
*/
650-
public function selectAsync($sql, array $bindings = [], $whereInFile = null, $writeToFile = null)
650+
public function selectAsync($sql, array $bindings = [], $whereInFile = null, $writeToFile = null): Statement
651651
{
652652
$request = $this->prepareSelect($sql, $bindings, $whereInFile, $writeToFile);
653653
$this->_curler->addQueLoop($request);
@@ -669,7 +669,7 @@ public function setProgressFunction(callable $callback) : void
669669
* @return Statement
670670
* @throws \ClickHouseDB\Exception\TransportException
671671
*/
672-
public function write($sql, array $bindings = [], $exception = true)
672+
public function write($sql, array $bindings = [], $exception = true): Statement
673673
{
674674
$request = $this->prepareWrite($sql, $bindings);
675675
$this->_curler->execOne($request);
@@ -688,7 +688,7 @@ public function write($sql, array $bindings = [], $exception = true)
688688
* @return Statement
689689
* @throws \ClickHouseDB\Exception\TransportException
690690
*/
691-
private function streaming(Stream $streamRW, CurlerRequest $request)
691+
private function streaming(Stream $streamRW, CurlerRequest $request): Statement
692692
{
693693
$callable = $streamRW->getClosure();
694694
$stream = $streamRW->getStream();
@@ -757,7 +757,7 @@ private function streaming(Stream $streamRW, CurlerRequest $request)
757757
* @return Statement
758758
* @throws \ClickHouseDB\Exception\TransportException
759759
*/
760-
public function streamRead(Stream $streamRead, $sql, $bindings = [])
760+
public function streamRead(Stream $streamRead, $sql, $bindings = []): Statement
761761
{
762762
$sql = $this->prepareQuery($sql, $bindings);
763763
$request = $this->getRequestRead($sql);
@@ -772,7 +772,7 @@ public function streamRead(Stream $streamRead, $sql, $bindings = [])
772772
* @return Statement
773773
* @throws \ClickHouseDB\Exception\TransportException
774774
*/
775-
public function streamWrite(Stream $streamWrite, $sql, $bindings = [])
775+
public function streamWrite(Stream $streamWrite, $sql, $bindings = []): Statement
776776
{
777777
$sql = $this->prepareQuery($sql, $bindings);
778778
$request = $this->writeStreamData($sql);

0 commit comments

Comments
 (0)