@trigger_error('Since guzzlehttp/guzzle 7.2.0: Using environment variable GUZZLE_CURL_SELECT_TIMEOUT is deprecated. Use option "select_timeout" instead.',\E_USER_DEPRECATED);
$this->selectTimeout=(int)$selectTimeout;
}else{
$this->selectTimeout=1;
}
$this->options=$options['options']??[];
// unsetting the property forces the first access to go through
// __get().
unset($this->_mh);
}
/**
* @param string $name
*
* @return resource|\CurlMultiHandle
*
* @throws \BadMethodCallException when another field as `_mh` will be gotten
* @throws \RuntimeException when curl can not initialize a multi handle
*/
publicfunction__get($name)
{
if($name!=='_mh'){
thrownew\BadMethodCallException("Can not get other property as '_mh'.");
}
$multiHandle=\curl_multi_init();
if(false===$multiHandle){
thrownew\RuntimeException('Can not initialize curl multi handle.');
* Cancels a handle from sending and removes references to it.
*
* @param int $id Handle ID to cancel and remove.
*
* @return bool True on success, false on failure.
*/
privatefunctioncancel($id):bool
{
if(!is_int($id)){
trigger_deprecation('guzzlehttp/guzzle','7.4','Not passing an integer to %s::%s() is deprecated and will cause an error in 8.0.',__CLASS__,__FUNCTION__);
}
// Cannot cancel if it has been processed.
if(!isset($this->handles[$id])){
returnfalse;
}
$handle=$this->handles[$id]['easy']->handle;
unset($this->delays[$id],$this->handles[$id]);
\curl_multi_remove_handle($this->_mh,$handle);
\curl_close($handle);
returntrue;
}
privatefunctionprocessMessages():void
{
while($done=\curl_multi_info_read($this->_mh)){
if($done['msg']!==\CURLMSG_DONE){
// if it's not done, then it would be premature to remove the handle. ref https://github.com/guzzle/guzzle/pull/2892#issuecomment-945150216