1515use PhpComp \Http \Client \ClientUtil ;
1616use PhpComp \Http \Client \Exception \ClientException ;
1717use PhpComp \Http \Client \Traits \ParseRawResponseTrait ;
18+ use function array_merge ;
1819use function curl_close ;
1920use function curl_errno ;
2021use function curl_error ;
@@ -109,9 +110,9 @@ class CurlClient extends AbstractClient implements CurlClientInterface
109110 use ParseRawResponseTrait;
110111
111112 // ssl auth type
112- const SSL_TYPE_CERT = 'cert ' ;
113+ public const SSL_TYPE_CERT = 'cert ' ;
113114
114- const SSL_TYPE_KEY = 'key ' ;
115+ public const SSL_TYPE_KEY = 'key ' ;
115116
116117 /**
117118 * Can to retry request
@@ -306,7 +307,7 @@ public function downloadImage(string $imgUrl, string $saveDir, string $rename =
306307 *
307308 * @return $this
308309 */
309- public function request (string $ url , $ data = null , string $ method = 'GET ' , array $ headers = [], array $ options = [])
310+ public function request (string $ url , $ data = null , string $ method = 'GET ' , array $ headers = [], array $ options = []): ClientInterface
310311 {
311312 if ($ method = strtoupper ($ method )) {
312313 $ options ['method ' ] = $ method ;
@@ -381,7 +382,7 @@ protected function prepareRequest(string $url, $data, array $headers, array $opt
381382 }
382383
383384 // merge global options.
384- $ options = \ array_merge ($ this ->options , $ options );
385+ $ options = array_merge ($ this ->options , $ options );
385386 $ method = $ this ->formatAndCheckMethod ($ options ['method ' ]);
386387
387388 switch ($ method ) {
@@ -426,12 +427,12 @@ protected function prepareRequest(string $url, $data, array $headers, array $opt
426427 $ curlOptions [CURLOPT_URL ] = ClientUtil::encodeURL ($ url );
427428
428429 // append http headers
429- if ($ headers = \ array_merge ($ this ->headers , $ options ['headers ' ], $ headers )) {
430+ if ($ headers = array_merge ($ this ->headers , $ options ['headers ' ], $ headers )) {
430431 $ curlOptions [CURLOPT_HTTPHEADER ] = $ this ->formatHeaders ($ headers );
431432 }
432433
433434 // append http cookies
434- if ($ cookies = \ array_merge ($ this ->cookies , $ options ['cookies ' ])) {
435+ if ($ cookies = array_merge ($ this ->cookies , $ options ['cookies ' ])) {
435436 $ curlOptions [CURLOPT_COOKIE ] = http_build_query ($ cookies , '' , '; ' );
436437 }
437438
@@ -480,7 +481,7 @@ public function getTotalTime(): int
480481 /**
481482 * @return $this
482483 */
483- public function resetOptions ()
484+ public function resetOptions (): ClientInterface
484485 {
485486 // $this->_curlOptions = [];
486487
@@ -491,7 +492,7 @@ public function resetOptions()
491492 /**
492493 * @return $this
493494 */
494- public function resetResponse ()
495+ public function resetResponse (): ClientInterface
495496 {
496497 $ this ->rawResponse = '' ;
497498 $ this ->responseParsed = false ;
@@ -535,7 +536,7 @@ public function setReferrer(string $referrer): self
535536 *
536537 * @return $this
537538 */
538- public function setUserAuth (string $ user , string $ pwd = '' , int $ authType = CURLAUTH_BASIC )
539+ public function setUserAuth (string $ user , string $ pwd = '' , int $ authType = CURLAUTH_BASIC ): ClientInterface
539540 {
540541 $ this ->_curlOptions [CURLOPT_HTTPAUTH ] = $ authType ;
541542 $ this ->_curlOptions [CURLOPT_USERPWD ] = "$ user: $ pwd " ;
@@ -551,7 +552,7 @@ public function setUserAuth(string $user, string $pwd = '', int $authType = CURL
551552 *
552553 * @return $this
553554 */
554- public function setSSLAuth (string $ pwd , string $ file , string $ authType = self ::SSL_TYPE_CERT )
555+ public function setSSLAuth (string $ pwd , string $ file , string $ authType = self ::SSL_TYPE_CERT ): ClientInterface
555556 {
556557 if ($ authType !== self ::SSL_TYPE_CERT && $ authType !== self ::SSL_TYPE_KEY ) {
557558 throw new InvalidArgumentException ('The SSL auth type only allow: cert|key ' );
0 commit comments