22
33namespace VCR \LibraryHooks ;
44
5+ use CurlHandle ;
56use VCR \CodeTransform \AbstractCodeTransform ;
67use VCR \Request ;
78use VCR \Response ;
@@ -166,15 +167,9 @@ public static function __callStatic($method, array $args)
166167 }
167168
168169 /**
169- * Initialize a cURL session.
170- *
171170 * @see http://www.php.net/manual/en/function.curl-init.php
172- *
173- * @param string|null $url (Optional) url
174- *
175- * @return resource|false cURL handle
176171 */
177- public static function curlInit (?string $ url = null )
172+ public static function curlInit (?string $ url = null ): CurlHandle | false
178173 {
179174 $ curlHandle = curl_init ($ url );
180175 if (false !== $ curlHandle ) {
@@ -186,13 +181,9 @@ public static function curlInit(?string $url = null)
186181 }
187182
188183 /**
189- * Reset a cURL session.
190- *
191184 * @see http://www.php.net/manual/en/function.curl-reset.php
192- *
193- * @param resource $curlHandle a cURL handle returned by curl_init()
194185 */
195- public static function curlReset ($ curlHandle ): void
186+ public static function curlReset (CurlHandle $ curlHandle ): void
196187 {
197188 curl_reset ($ curlHandle );
198189 self ::$ requests [(int ) $ curlHandle ] = new Request ('GET ' , null );
@@ -205,13 +196,11 @@ public static function curlReset($curlHandle): void
205196 *
206197 * @see http://www.php.net/manual/en/function.curl-exec.php
207198 *
208- * @param resource $curlHandle a cURL handle returned by curl_init()
209- *
210199 * @return mixed Returns TRUE on success or FALSE on failure.
211200 * However, if the CURLOPT_RETURNTRANSFER option is set, it will return the
212201 * result on success, FALSE on failure.
213202 */
214- public static function curlExec ($ curlHandle )
203+ public static function curlExec (CurlHandle $ curlHandle )
215204 {
216205 try {
217206 $ request = self ::$ requests [(int ) $ curlHandle ];
@@ -330,12 +319,9 @@ public static function curlMultiGetcontent($curlHandle): ?string
330319 *
331320 * @see http://www.php.net/manual/en/function.curl-getinfo.php
332321 *
333- * @param resource $curlHandle a cURL handle returned by curl_init()
334- * @param int $option a cURL option defined in the cURL Predefined Constants
335- *
336322 * @return mixed
337323 */
338- public static function curlGetinfo ($ curlHandle , int $ option = 0 )
324+ public static function curlGetinfo (CurlHandle $ curlHandle , int $ option = 0 )
339325 {
340326 if (isset (self ::$ responses [(int ) $ curlHandle ])) {
341327 return CurlHelper::getCurlOptionFromResponse (
@@ -354,15 +340,11 @@ public static function curlGetinfo($curlHandle, int $option = 0)
354340 *
355341 * @see http://www.php.net/manual/en/function.curl-setopt.php
356342 *
357- * @param resource $curlHandle a cURL handle returned by curl_init()
358- * @param int $option the CURLOPT_XXX option to set
359- * @param mixed $value the value to be set on option
360- *
361- * @return bool returns TRUE on success or FALSE on failure
343+ * @param mixed $value the value to be set on option
362344 */
363- public static function curlSetopt ($ curlHandle , int $ option , $ value ): bool
345+ public static function curlSetopt (CurlHandle $ curlHandle , int $ option , $ value ): bool
364346 {
365- CurlHelper::setCurlOptionOnRequest (self ::$ requests [(int ) $ curlHandle ], $ option , $ value, $ curlHandle );
347+ CurlHelper::setCurlOptionOnRequest (self ::$ requests [(int ) $ curlHandle ], $ option , $ value );
366348
367349 static ::$ curlOptions [(int ) $ curlHandle ][$ option ] = $ value ;
368350
@@ -374,29 +356,21 @@ public static function curlSetopt($curlHandle, int $option, $value): bool
374356 *
375357 * @see http://www.php.net/manual/en/function.curl-setopt-array.php
376358 *
377- * @param resource $curlHandle a cURL handle returned by curl_init()
378- * @param array<int, mixed> $options an array specifying which options to set and their values
359+ * @param array<int, mixed> $options an array specifying which options to set and their values
379360 */
380- public static function curlSetoptArray ($ curlHandle , array $ options ): void
361+ public static function curlSetoptArray (CurlHandle $ curlHandle , array $ options ): void
381362 {
382- if (\is_array ($ options )) {
383- foreach ($ options as $ option => $ value ) {
384- static ::curlSetopt ($ curlHandle , $ option , $ value );
385- }
363+ foreach ($ options as $ option => $ value ) {
364+ static ::curlSetopt ($ curlHandle , $ option , $ value );
386365 }
387366 }
388367
389368 /**
390369 * Return a string containing the last error for the current session.
391370 *
392371 * @see https://php.net/manual/en/function.curl-error.php
393- *
394- * @param resource $curlHandle
395- *
396- * @return string the error message or '' (the empty string) if no
397- * error occurred
398372 */
399- public static function curlError ($ curlHandle ): string
373+ public static function curlError (CurlHandle $ curlHandle ): string
400374 {
401375 if (isset (self ::$ lastErrors [(int ) $ curlHandle ])) {
402376 return self ::$ lastErrors [(int ) $ curlHandle ]->getMessage ();
@@ -409,13 +383,8 @@ public static function curlError($curlHandle): string
409383 * Return the last error number.
410384 *
411385 * @see https://php.net/manual/en/function.curl-errno.php
412- *
413- * @param resource $curlHandle
414- *
415- * @return int the error number or 0 (zero) if no error
416- * occurred
417386 */
418- public static function curlErrno ($ curlHandle ): int
387+ public static function curlErrno (CurlHandle $ curlHandle ): int
419388 {
420389 if (isset (self ::$ lastErrors [(int ) $ curlHandle ])) {
421390 return self ::$ lastErrors [(int ) $ curlHandle ]->getCode ();
0 commit comments