@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | protected static $curlAlias = array( |
20 | 20 | 'url' => 'CURLOPT_URL', |
21 | 21 | 'uri' => 'CURLOPT_URL', |
22 | - 'debug' => 'CURLOPT_VERBOSE',//for debug verbose |
|
22 | + 'debug' => 'CURLOPT_VERBOSE', //for debug verbose |
|
23 | 23 | 'method' => 'CURLOPT_CUSTOMREQUEST', |
24 | 24 | 'data' => 'CURLOPT_POSTFIELDS', // array or string , file begin with '@' |
25 | 25 | 'ua' => 'CURLOPT_USERAGENT', |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | 'follow_location' => true, |
63 | 63 | 'timeout' => 0, |
64 | 64 | // 'ip' => null, //host, in string, .e.g: 172.16.1.1:888 |
65 | - 'retry_times' => 1,//redo task when failed |
|
66 | - 'retry_duration' => 0,//in seconds |
|
65 | + 'retry_times' => 1, //redo task when failed |
|
66 | + 'retry_duration' => 0, //in seconds |
|
67 | 67 | ); |
68 | 68 | protected $endCallback; |
69 | 69 | protected $withURIQuery; |
@@ -254,9 +254,9 @@ discard block |
||
254 | 254 | } |
255 | 255 | /* no body */ |
256 | 256 | |
257 | - protected function ini($method, $url, $data , array $options = array()) |
|
257 | + protected function ini($method, $url, $data, array $options = array()) |
|
258 | 258 | { |
259 | - $options = array('url' => $url, 'method' => $method, 'data' => $data) + $options; |
|
259 | + $options = array('url' => $url, 'method' => $method, 'data' => $data)+$options; |
|
260 | 260 | $this->addOptions($options); |
261 | 261 | |
262 | 262 | return $this; |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | |
265 | 265 | public function addOptions(array $options = array()) |
266 | 266 | { |
267 | - $this->options = $options + $this->options; |
|
267 | + $this->options = $options+$this->options; |
|
268 | 268 | $this->uri = $this->options['url']; |
269 | 269 | return $this; |
270 | 270 | } |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | } |
356 | 356 | |
357 | 357 | if (isset($this->options['data'])) { |
358 | - $this->options['data'] = is_array($this->options['data']) ? http_build_query($this->options['data']) : $this->options['data'];//for better compatibility |
|
358 | + $this->options['data'] = is_array($this->options['data']) ? http_build_query($this->options['data']) : $this->options['data']; //for better compatibility |
|
359 | 359 | } |
360 | 360 | if (isset($this->withURIQuery)) { |
361 | 361 | $this->options['url'] .= strpos($this->options['url'], '?') === FALSE ? '?' : '&'; |
@@ -371,11 +371,11 @@ discard block |
||
371 | 371 | preg_match('/\/\/([^\/]+)/', $this->options['url'], $matches); |
372 | 372 | $host = $matches[1]; |
373 | 373 | if (empty($this->options['headers']) || !is_array($this->options['headers'])) { |
374 | - $this->options['headers'] = array('Host: ' . $host); |
|
374 | + $this->options['headers'] = array('Host: '.$host); |
|
375 | 375 | } else { |
376 | - $this->options['headers'][] = 'Host: ' . $host; |
|
376 | + $this->options['headers'][] = 'Host: '.$host; |
|
377 | 377 | } |
378 | - $this->options['url'] = preg_replace('/\/\/([^\/]+)/', '//' . $this->options['ip'], $this->options['url']); |
|
378 | + $this->options['url'] = preg_replace('/\/\/([^\/]+)/', '//'.$this->options['ip'], $this->options['url']); |
|
379 | 379 | unset($this->options['ip']); |
380 | 380 | unset($host); |
381 | 381 | } |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | //convert secs to milliseconds |
395 | 395 | if (defined('CURLOPT_TIMEOUT_MS')) { |
396 | 396 | if (!isset($this->options['timeout_ms'])) { |
397 | - $this->options['timeout_ms'] = intval($this->options['timeout'] * 1000); |
|
397 | + $this->options['timeout_ms'] = intval($this->options['timeout']*1000); |
|
398 | 398 | } else { |
399 | 399 | $this->options['timeout_ms'] = intval($this->options['timeout_ms']); |
400 | 400 | } |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | public function onEnd(callable $callback) |
411 | 411 | { |
412 | 412 | if (!is_callable($callback)) { |
413 | - throw new InvalidArgumentException('callback not is callable :' . print_r($callback, 1)); |
|
413 | + throw new InvalidArgumentException('callback not is callable :'.print_r($callback, 1)); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | $this->endCallback = $callback; |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | private static function log(Response $response) |
459 | 459 | { |
460 | 460 | if ($response->hasErrors()) { |
461 | - self::$logger->error($response->request->getURI() . "\t" . $response->error, array( |
|
461 | + self::$logger->error($response->request->getURI()."\t".$response->error, array( |
|
462 | 462 | 'response' => print_r($response, 1), |
463 | 463 | )); |
464 | 464 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | 'method' => $method, |
53 | 53 | 'url' => $uri, |
54 | 54 | 'data' => $payload, |
55 | - ) + $options; |
|
55 | + )+$options; |
|
56 | 56 | $this->addOptions(array($options)); |
57 | 57 | return $this; |
58 | 58 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | public function execute() |
92 | 92 | { |
93 | 93 | // if($this->isLazy) return array(); |
94 | - $sleepTime = 1000;//microsecond, prevent CPU 100% |
|
94 | + $sleepTime = 1000; //microsecond, prevent CPU 100% |
|
95 | 95 | do { |
96 | 96 | curl_multi_exec(self::$multiHandler, $active); |
97 | 97 | // bug in PHP 5.3.18+ where curl_multi_select can return -1 |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | usleep($sleepTime); |
101 | 101 | } |
102 | 102 | usleep($sleepTime); |
103 | - } while ($active); |
|
103 | + }while ($active); |
|
104 | 104 | $return = array(); |
105 | 105 | foreach (self::$requestPool as $request) { |
106 | 106 | $response = $request->makeResponse(true); |