@@ -132,18 +132,18 @@ public function write($url, $body = [], $method = CurlInterface::POST, $headers
132132 CURLOPT_RETURNTRANSFER => true ,
133133 CURLOPT_FOLLOWLOCATION => true ,
134134 CURLOPT_COOKIEFILE => '' ,
135- CURLOPT_HTTPHEADER => $ headers ,
135+ CURLOPT_HTTPHEADER => is_object ( $ headers ) ? ( array ) $ headers : $ headers ,
136136 CURLOPT_SSL_VERIFYPEER => false ,
137137 CURLOPT_SSL_VERIFYHOST => false ,
138138 ];
139139 switch ($ method ) {
140140 case CurlInterface::POST :
141141 $ options [CURLOPT_POST ] = true ;
142- $ options [CURLOPT_POSTFIELDS ] = $ body ;
142+ $ options [CURLOPT_POSTFIELDS ] = is_object ( $ body ) ? ( array ) $ body : $ body ;
143143 break ;
144144 case CurlInterface::PUT :
145145 $ options [CURLOPT_CUSTOMREQUEST ] = self ::PUT ;
146- $ options [CURLOPT_POSTFIELDS ] = $ body ;
146+ $ options [CURLOPT_POSTFIELDS ] = is_object ( $ body ) ? ( array ) $ body : $ body ;
147147 break ;
148148 case CurlInterface::DELETE :
149149 $ options [CURLOPT_CUSTOMREQUEST ] = self ::DELETE ;
@@ -189,7 +189,10 @@ public function read($successRegex = null, $returnRegex = null, $returnIndex = n
189189 */
190190 public function close ()
191191 {
192- curl_close ($ this ->getResource ());
192+ if (version_compare (PHP_VERSION , '8.0 ' ) < 0 ) {
193+ // this function no longer has an effect in PHP 8.0, but it's required in earlier versions
194+ curl_close ($ this ->getResource ());
195+ }
193196 $ this ->resource = null ;
194197 }
195198
@@ -271,7 +274,11 @@ public function multiRequest(array $urls, array $options = [])
271274 $ result [$ key ] = curl_multi_getcontent ($ handle );
272275 curl_multi_remove_handle ($ multiHandle , $ handle );
273276 }
274- curl_multi_close ($ multiHandle );
277+ if (version_compare (PHP_VERSION , '8.0 ' ) < 0 ) {
278+ // this function no longer has an effect in PHP 8.0, but it's required in earlier versions
279+ curl_multi_close ($ multiHandle );
280+ }
281+
275282 return $ result ;
276283 }
277284
0 commit comments