@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | * Progress |
| 228 | 228 | * |
| 229 | 229 | * @access public |
| 230 | - * @param $callback |
|
| 230 | + * @param \Closure $callback |
|
| 231 | 231 | */ |
| 232 | 232 | public function progress($callback) |
| 233 | 233 | { |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | * Download Complete |
| 264 | 264 | * |
| 265 | 265 | * @access private |
| 266 | - * @param $fh |
|
| 266 | + * @param resource $fh |
|
| 267 | 267 | */ |
| 268 | 268 | private function downloadComplete($fh) |
| 269 | 269 | { |
@@ -442,7 +442,7 @@ discard block |
||
| 442 | 442 | * Get Info |
| 443 | 443 | * |
| 444 | 444 | * @access public |
| 445 | - * @param $opt |
|
| 445 | + * @param integer $opt |
|
| 446 | 446 | * |
| 447 | 447 | * @return mixed |
| 448 | 448 | */ |
@@ -462,7 +462,7 @@ discard block |
||
| 462 | 462 | * Get Opt |
| 463 | 463 | * |
| 464 | 464 | * @access public |
| 465 | - * @param $option |
|
| 465 | + * @param integer $option |
|
| 466 | 466 | * |
| 467 | 467 | * @return mixed |
| 468 | 468 | */ |
@@ -1105,7 +1105,7 @@ discard block |
||
| 1105 | 1105 | * Set Timeout |
| 1106 | 1106 | * |
| 1107 | 1107 | * @access public |
| 1108 | - * @param $seconds |
|
| 1108 | + * @param integer $seconds |
|
| 1109 | 1109 | */ |
| 1110 | 1110 | public function setTimeout($seconds) |
| 1111 | 1111 | { |
@@ -1130,7 +1130,7 @@ discard block |
||
| 1130 | 1130 | * Set User Agent |
| 1131 | 1131 | * |
| 1132 | 1132 | * @access public |
| 1133 | - * @param $user_agent |
|
| 1133 | + * @param string $user_agent |
|
| 1134 | 1134 | */ |
| 1135 | 1135 | public function setUserAgent($user_agent) |
| 1136 | 1136 | { |
@@ -1173,7 +1173,7 @@ discard block |
||
| 1173 | 1173 | * Using `curl -H "Host:" ...' is equivalent to $curl->removeHeader('Host');. |
| 1174 | 1174 | * |
| 1175 | 1175 | * @access public |
| 1176 | - * @param $key |
|
| 1176 | + * @param string $key |
|
| 1177 | 1177 | */ |
| 1178 | 1178 | public function removeHeader($key) |
| 1179 | 1179 | { |
@@ -1360,7 +1360,7 @@ discard block |
||
| 1360 | 1360 | * Parse Response Headers |
| 1361 | 1361 | * |
| 1362 | 1362 | * @access private |
| 1363 | - * @param $raw_response_headers |
|
| 1363 | + * @param string $raw_response_headers |
|
| 1364 | 1364 | * |
| 1365 | 1365 | * @return array |
| 1366 | 1366 | */ |
@@ -9,51 +9,51 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | class Curl { |
| 11 | 11 | |
| 12 | - const VERSION = '7.2.0'; |
|
| 13 | - const DEFAULT_TIMEOUT = 30; |
|
| 12 | + const VERSION='7.2.0'; |
|
| 13 | + const DEFAULT_TIMEOUT=30; |
|
| 14 | 14 | |
| 15 | 15 | public $curl; |
| 16 | - public $id = null; |
|
| 17 | - |
|
| 18 | - public $error = false; |
|
| 19 | - public $errorCode = 0; |
|
| 20 | - public $errorMessage = null; |
|
| 21 | - |
|
| 22 | - public $curlError = false; |
|
| 23 | - public $curlErrorCode = 0; |
|
| 24 | - public $curlErrorMessage = null; |
|
| 25 | - |
|
| 26 | - public $httpError = false; |
|
| 27 | - public $httpStatusCode = 0; |
|
| 28 | - public $httpErrorMessage = null; |
|
| 29 | - |
|
| 30 | - public $baseUrl = null; |
|
| 31 | - public $url = null; |
|
| 32 | - public $requestHeaders = null; |
|
| 33 | - public $responseHeaders = null; |
|
| 34 | - public $rawResponseHeaders = ''; |
|
| 35 | - public $responseCookies = array(); |
|
| 36 | - public $response = null; |
|
| 37 | - public $rawResponse = null; |
|
| 38 | - |
|
| 39 | - public $beforeSendFunction = null; |
|
| 40 | - public $downloadCompleteFunction = null; |
|
| 41 | - public $successFunction = null; |
|
| 42 | - public $errorFunction = null; |
|
| 43 | - public $completeFunction = null; |
|
| 44 | - public $fileHandle = null; |
|
| 45 | - |
|
| 46 | - private $cookies = array(); |
|
| 47 | - private $headers = array(); |
|
| 48 | - private $options = array(); |
|
| 49 | - |
|
| 50 | - private $jsonDecoder = null; |
|
| 51 | - private $jsonPattern = '/^(?:application|text)\/(?:[a-z]+(?:[\.-][0-9a-z]+){0,}[\+\.]|x-)?json(?:-[a-z]+)?/i'; |
|
| 52 | - private $xmlDecoder = null; |
|
| 53 | - private $xmlPattern = '~^(?:text/|application/(?:atom\+|rss\+)?)xml~i'; |
|
| 54 | - private $defaultDecoder = null; |
|
| 55 | - |
|
| 56 | - public static $RFC2616 = array( |
|
| 16 | + public $id=null; |
|
| 17 | + |
|
| 18 | + public $error=false; |
|
| 19 | + public $errorCode=0; |
|
| 20 | + public $errorMessage=null; |
|
| 21 | + |
|
| 22 | + public $curlError=false; |
|
| 23 | + public $curlErrorCode=0; |
|
| 24 | + public $curlErrorMessage=null; |
|
| 25 | + |
|
| 26 | + public $httpError=false; |
|
| 27 | + public $httpStatusCode=0; |
|
| 28 | + public $httpErrorMessage=null; |
|
| 29 | + |
|
| 30 | + public $baseUrl=null; |
|
| 31 | + public $url=null; |
|
| 32 | + public $requestHeaders=null; |
|
| 33 | + public $responseHeaders=null; |
|
| 34 | + public $rawResponseHeaders=''; |
|
| 35 | + public $responseCookies=array(); |
|
| 36 | + public $response=null; |
|
| 37 | + public $rawResponse=null; |
|
| 38 | + |
|
| 39 | + public $beforeSendFunction=null; |
|
| 40 | + public $downloadCompleteFunction=null; |
|
| 41 | + public $successFunction=null; |
|
| 42 | + public $errorFunction=null; |
|
| 43 | + public $completeFunction=null; |
|
| 44 | + public $fileHandle=null; |
|
| 45 | + |
|
| 46 | + private $cookies=array(); |
|
| 47 | + private $headers=array(); |
|
| 48 | + private $options=array(); |
|
| 49 | + |
|
| 50 | + private $jsonDecoder=null; |
|
| 51 | + private $jsonPattern='/^(?:application|text)\/(?:[a-z]+(?:[\.-][0-9a-z]+){0,}[\+\.]|x-)?json(?:-[a-z]+)?/i'; |
|
| 52 | + private $xmlDecoder=null; |
|
| 53 | + private $xmlPattern='~^(?:text/|application/(?:atom\+|rss\+)?)xml~i'; |
|
| 54 | + private $defaultDecoder=null; |
|
| 55 | + |
|
| 56 | + public static $RFC2616=array( |
|
| 57 | 57 | // RFC2616: "any CHAR except CTLs or separators". |
| 58 | 58 | // CHAR = <any US-ASCII character (octets 0 - 127)> |
| 59 | 59 | // CTL = <any US-ASCII control character |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | 'Y', 'Z', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', |
| 71 | 71 | 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '|', '~', |
| 72 | 72 | ); |
| 73 | - public static $RFC6265 = array( |
|
| 73 | + public static $RFC6265=array( |
|
| 74 | 74 | // RFC6265: "US-ASCII characters excluding CTLs, whitespace DQUOTE, comma, semicolon, and backslash". |
| 75 | 75 | // %x21 |
| 76 | 76 | '!', |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', |
| 87 | 87 | ); |
| 88 | 88 | |
| 89 | - private static $deferredProperties = array( |
|
| 89 | + private static $deferredProperties=array( |
|
| 90 | 90 | 'effectiveUrl', |
| 91 | 91 | 'rfc2616', |
| 92 | 92 | 'rfc6265', |
@@ -100,14 +100,14 @@ discard block |
||
| 100 | 100 | * @param $base_url |
| 101 | 101 | * @throws \ErrorException |
| 102 | 102 | */ |
| 103 | - public function __construct($base_url = null) |
|
| 103 | + public function __construct($base_url=null) |
|
| 104 | 104 | { |
| 105 | 105 | if (!extension_loaded('curl')) { |
| 106 | 106 | throw new \ErrorException('cURL library is not loaded'); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - $this->curl = curl_init(); |
|
| 110 | - $this->id = uniqid('', true); |
|
| 109 | + $this->curl=curl_init(); |
|
| 110 | + $this->id=uniqid('', true); |
|
| 111 | 111 | $this->setDefaultUserAgent(); |
| 112 | 112 | $this->setDefaultJsonDecoder(); |
| 113 | 113 | $this->setDefaultXmlDecoder(); |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | $this->setOpt(CURLINFO_HEADER_OUT, true); |
| 116 | 116 | $this->setOpt(CURLOPT_HEADERFUNCTION, array($this, 'headerCallback')); |
| 117 | 117 | $this->setOpt(CURLOPT_RETURNTRANSFER, true); |
| 118 | - $this->headers = []; |
|
| 118 | + $this->headers=[]; |
|
| 119 | 119 | $this->setUrl($base_url); |
| 120 | 120 | } |
| 121 | 121 | |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function beforeSend($callback) |
| 129 | 129 | { |
| 130 | - $this->beforeSendFunction = $callback; |
|
| 130 | + $this->beforeSendFunction=$callback; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -140,21 +140,21 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | public function buildPostData($data) |
| 142 | 142 | { |
| 143 | - $binary_data = false; |
|
| 143 | + $binary_data=false; |
|
| 144 | 144 | if (is_array($data)) { |
| 145 | 145 | // Return JSON-encoded string when the request's content-type is JSON. |
| 146 | 146 | if (isset($this->headers['Content-Type']) && |
| 147 | 147 | preg_match($this->jsonPattern, $this->headers['Content-Type'])) { |
| 148 | - $json_str = json_encode($data); |
|
| 148 | + $json_str=json_encode($data); |
|
| 149 | 149 | if (!($json_str === false)) { |
| 150 | - $data = $json_str; |
|
| 150 | + $data=$json_str; |
|
| 151 | 151 | } |
| 152 | 152 | } else { |
| 153 | 153 | // Manually build a single-dimensional array from a multi-dimensional array as using curl_setopt($ch, |
| 154 | 154 | // CURLOPT_POSTFIELDS, $data) doesn't correctly handle multi-dimensional arrays when files are |
| 155 | 155 | // referenced. |
| 156 | 156 | if (Arr::isMultidim($data)) { |
| 157 | - $data = Arr::flatten($data); |
|
| 157 | + $data=Arr::flatten($data); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | // Modify array values to ensure any referenced files are properly handled depending on the support of |
@@ -163,19 +163,19 @@ discard block |
||
| 163 | 163 | // non-file values prefixed with the @ character. |
| 164 | 164 | foreach ($data as $key => $value) { |
| 165 | 165 | if (is_string($value) && strpos($value, '@') === 0 && is_file(substr($value, 1))) { |
| 166 | - $binary_data = true; |
|
| 166 | + $binary_data=true; |
|
| 167 | 167 | if (class_exists('CURLFile')) { |
| 168 | - $data[$key] = new \CURLFile(substr($value, 1)); |
|
| 168 | + $data[$key]=new \CURLFile(substr($value, 1)); |
|
| 169 | 169 | } |
| 170 | 170 | } elseif ($value instanceof \CURLFile) { |
| 171 | - $binary_data = true; |
|
| 171 | + $binary_data=true; |
|
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | if (!$binary_data && (is_array($data) || is_object($data))) { |
| 178 | - $data = http_build_query($data, '', '&'); |
|
| 178 | + $data=http_build_query($data, '', '&'); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | return $data; |
@@ -188,8 +188,8 @@ discard block |
||
| 188 | 188 | */ |
| 189 | 189 | public function call() |
| 190 | 190 | { |
| 191 | - $args = func_get_args(); |
|
| 192 | - $function = array_shift($args); |
|
| 191 | + $args=func_get_args(); |
|
| 192 | + $function=array_shift($args); |
|
| 193 | 193 | if (is_callable($function)) { |
| 194 | 194 | array_unshift($args, $this); |
| 195 | 195 | call_user_func_array($function, $args); |
@@ -206,10 +206,10 @@ discard block |
||
| 206 | 206 | if (is_resource($this->curl)) { |
| 207 | 207 | curl_close($this->curl); |
| 208 | 208 | } |
| 209 | - $this->options = null; |
|
| 210 | - $this->jsonDecoder = null; |
|
| 211 | - $this->xmlDecoder = null; |
|
| 212 | - $this->defaultDecoder = null; |
|
| 209 | + $this->options=null; |
|
| 210 | + $this->jsonDecoder=null; |
|
| 211 | + $this->xmlDecoder=null; |
|
| 212 | + $this->defaultDecoder=null; |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | */ |
| 221 | 221 | public function complete($callback) |
| 222 | 222 | { |
| 223 | - $this->completeFunction = $callback; |
|
| 223 | + $this->completeFunction=$callback; |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | /** |
@@ -245,12 +245,12 @@ discard block |
||
| 245 | 245 | * |
| 246 | 246 | * @return string |
| 247 | 247 | */ |
| 248 | - public function delete($url, $query_parameters = array(), $data = array()) |
|
| 248 | + public function delete($url, $query_parameters=array(), $data=array()) |
|
| 249 | 249 | { |
| 250 | 250 | if (is_array($url)) { |
| 251 | - $data = $query_parameters; |
|
| 252 | - $query_parameters = $url; |
|
| 253 | - $url = $this->baseUrl; |
|
| 251 | + $data=$query_parameters; |
|
| 252 | + $query_parameters=$url; |
|
| 253 | + $url=$this->baseUrl; |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | $this->setUrl($url, $query_parameters); |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | if (!$this->error && $this->downloadCompleteFunction) { |
| 271 | 271 | rewind($fh); |
| 272 | 272 | $this->call($this->downloadCompleteFunction, $fh); |
| 273 | - $this->downloadCompleteFunction = null; |
|
| 273 | + $this->downloadCompleteFunction=null; |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | if (is_resource($fh)) { |
@@ -306,29 +306,29 @@ discard block |
||
| 306 | 306 | public function download($url, $mixed_filename) |
| 307 | 307 | { |
| 308 | 308 | if (is_callable($mixed_filename)) { |
| 309 | - $this->downloadCompleteFunction = $mixed_filename; |
|
| 310 | - $this->fileHandle = tmpfile(); |
|
| 309 | + $this->downloadCompleteFunction=$mixed_filename; |
|
| 310 | + $this->fileHandle=tmpfile(); |
|
| 311 | 311 | } else { |
| 312 | - $filename = $mixed_filename; |
|
| 312 | + $filename=$mixed_filename; |
|
| 313 | 313 | |
| 314 | 314 | // Use a temporary file when downloading. Not using a temporary file can cause an error when an existing |
| 315 | 315 | // file has already fully completed downloading and a new download is started with the same destination save |
| 316 | 316 | // path. The download request will include header "Range: bytes=$filesize-" which is syntactically valid, |
| 317 | 317 | // but unsatisfiable. |
| 318 | - $download_filename = $filename . '.pccdownload'; |
|
| 318 | + $download_filename=$filename.'.pccdownload'; |
|
| 319 | 319 | |
| 320 | - $mode = 'wb'; |
|
| 320 | + $mode='wb'; |
|
| 321 | 321 | // Attempt to resume download only when a temporary download file exists and is not empty. |
| 322 | - if (file_exists($download_filename) && $filesize = filesize($download_filename)) { |
|
| 323 | - $mode = 'ab'; |
|
| 324 | - $first_byte_position = $filesize; |
|
| 325 | - $range = $first_byte_position . '-'; |
|
| 322 | + if (file_exists($download_filename) && $filesize=filesize($download_filename)) { |
|
| 323 | + $mode='ab'; |
|
| 324 | + $first_byte_position=$filesize; |
|
| 325 | + $range=$first_byte_position.'-'; |
|
| 326 | 326 | $this->setOpt(CURLOPT_RANGE, $range); |
| 327 | 327 | } |
| 328 | - $this->fileHandle = fopen($download_filename, $mode); |
|
| 328 | + $this->fileHandle=fopen($download_filename, $mode); |
|
| 329 | 329 | |
| 330 | 330 | // Move the downloaded temporary file to the destination save path. |
| 331 | - $this->downloadCompleteFunction = function ($fh) use ($download_filename, $filename) { |
|
| 331 | + $this->downloadCompleteFunction=function($fh) use ($download_filename, $filename) { |
|
| 332 | 332 | rename($download_filename, $filename); |
| 333 | 333 | }; |
| 334 | 334 | } |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | $this->setOpt(CURLOPT_FILE, $this->fileHandle); |
| 337 | 337 | $this->get($url); |
| 338 | 338 | |
| 339 | - return ! $this->error; |
|
| 339 | + return !$this->error; |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | /** |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | */ |
| 348 | 348 | public function error($callback) |
| 349 | 349 | { |
| 350 | - $this->errorFunction = $callback; |
|
| 350 | + $this->errorFunction=$callback; |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | /** |
@@ -358,48 +358,48 @@ discard block |
||
| 358 | 358 | * |
| 359 | 359 | * @return mixed Returns the value provided by parseResponse. |
| 360 | 360 | */ |
| 361 | - public function exec($ch = null) |
|
| 361 | + public function exec($ch=null) |
|
| 362 | 362 | { |
| 363 | 363 | if ($ch === null) { |
| 364 | - $this->responseCookies = array(); |
|
| 364 | + $this->responseCookies=array(); |
|
| 365 | 365 | $this->call($this->beforeSendFunction); |
| 366 | - $this->rawResponse = curl_exec($this->curl); |
|
| 367 | - $this->curlErrorCode = curl_errno($this->curl); |
|
| 368 | - $this->curlErrorMessage = curl_error($this->curl); |
|
| 366 | + $this->rawResponse=curl_exec($this->curl); |
|
| 367 | + $this->curlErrorCode=curl_errno($this->curl); |
|
| 368 | + $this->curlErrorMessage=curl_error($this->curl); |
|
| 369 | 369 | } else { |
| 370 | - $this->rawResponse = curl_multi_getcontent($ch); |
|
| 371 | - $this->curlErrorMessage = curl_error($ch); |
|
| 370 | + $this->rawResponse=curl_multi_getcontent($ch); |
|
| 371 | + $this->curlErrorMessage=curl_error($ch); |
|
| 372 | 372 | } |
| 373 | - $this->curlError = !($this->curlErrorCode === 0); |
|
| 373 | + $this->curlError=!($this->curlErrorCode === 0); |
|
| 374 | 374 | // Include additional error code information in error message when possible. |
| 375 | 375 | if ($this->curlError && function_exists('curl_strerror')) { |
| 376 | - $this->curlErrorMessage = |
|
| 377 | - curl_strerror($this->curlErrorCode) . ( |
|
| 378 | - empty($this->curlErrorMessage) ? '' : ': ' . $this->curlErrorMessage |
|
| 376 | + $this->curlErrorMessage= |
|
| 377 | + curl_strerror($this->curlErrorCode).( |
|
| 378 | + empty($this->curlErrorMessage) ? '' : ': '.$this->curlErrorMessage |
|
| 379 | 379 | ); |
| 380 | 380 | print_r($this->rawResponse); |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | - $this->httpStatusCode = $this->getInfo(CURLINFO_HTTP_CODE); |
|
| 384 | - $this->httpError = in_array(floor($this->httpStatusCode / 100), array(4, 5)); |
|
| 385 | - $this->error = $this->curlError || $this->httpError; |
|
| 386 | - $this->errorCode = $this->error ? ($this->curlError ? $this->curlErrorCode : $this->httpStatusCode) : 0; |
|
| 383 | + $this->httpStatusCode=$this->getInfo(CURLINFO_HTTP_CODE); |
|
| 384 | + $this->httpError=in_array(floor($this->httpStatusCode / 100), array(4, 5)); |
|
| 385 | + $this->error=$this->curlError || $this->httpError; |
|
| 386 | + $this->errorCode=$this->error ? ($this->curlError ? $this->curlErrorCode : $this->httpStatusCode) : 0; |
|
| 387 | 387 | |
| 388 | 388 | // NOTE: CURLINFO_HEADER_OUT set to true is required for requestHeaders |
| 389 | 389 | // to not be empty (e.g. $curl->setOpt(CURLINFO_HEADER_OUT, true);). |
| 390 | 390 | if ($this->getOpt(CURLINFO_HEADER_OUT) === true) { |
| 391 | - $this->requestHeaders = $this->parseRequestHeaders($this->getInfo(CURLINFO_HEADER_OUT)); |
|
| 391 | + $this->requestHeaders=$this->parseRequestHeaders($this->getInfo(CURLINFO_HEADER_OUT)); |
|
| 392 | 392 | } |
| 393 | - $this->responseHeaders = $this->parseResponseHeaders($this->rawResponseHeaders); |
|
| 394 | - $this->response = $this->parseResponse($this->responseHeaders, $this->rawResponse); |
|
| 393 | + $this->responseHeaders=$this->parseResponseHeaders($this->rawResponseHeaders); |
|
| 394 | + $this->response=$this->parseResponse($this->responseHeaders, $this->rawResponse); |
|
| 395 | 395 | |
| 396 | - $this->httpErrorMessage = ''; |
|
| 396 | + $this->httpErrorMessage=''; |
|
| 397 | 397 | if ($this->error) { |
| 398 | 398 | if (isset($this->responseHeaders['Status-Line'])) { |
| 399 | - $this->httpErrorMessage = $this->responseHeaders['Status-Line']; |
|
| 399 | + $this->httpErrorMessage=$this->responseHeaders['Status-Line']; |
|
| 400 | 400 | } |
| 401 | 401 | } |
| 402 | - $this->errorMessage = $this->curlError ? $this->curlErrorMessage : $this->httpErrorMessage; |
|
| 402 | + $this->errorMessage=$this->curlError ? $this->curlErrorMessage : $this->httpErrorMessage; |
|
| 403 | 403 | |
| 404 | 404 | if (!$this->error) { |
| 405 | 405 | $this->call($this->successFunction); |
@@ -426,11 +426,11 @@ discard block |
||
| 426 | 426 | * |
| 427 | 427 | * @return mixed Returns the value provided by exec. |
| 428 | 428 | */ |
| 429 | - public function get($url, $data = array()) |
|
| 429 | + public function get($url, $data=array()) |
|
| 430 | 430 | { |
| 431 | 431 | if (is_array($url)) { |
| 432 | - $data = $url; |
|
| 433 | - $url = $this->baseUrl; |
|
| 432 | + $data=$url; |
|
| 433 | + $url=$this->baseUrl; |
|
| 434 | 434 | } |
| 435 | 435 | $this->setUrl($url, $data); |
| 436 | 436 | $this->setOpt(CURLOPT_CUSTOMREQUEST, 'GET'); |
@@ -446,13 +446,13 @@ discard block |
||
| 446 | 446 | * |
| 447 | 447 | * @return mixed |
| 448 | 448 | */ |
| 449 | - public function getInfo($opt = null) |
|
| 449 | + public function getInfo($opt=null) |
|
| 450 | 450 | { |
| 451 | - $args = array(); |
|
| 452 | - $args[] = $this->curl; |
|
| 451 | + $args=array(); |
|
| 452 | + $args[]=$this->curl; |
|
| 453 | 453 | |
| 454 | 454 | if (func_num_args()) { |
| 455 | - $args[] = $opt; |
|
| 455 | + $args[]=$opt; |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | return call_user_func_array('curl_getinfo', $args); |
@@ -480,11 +480,11 @@ discard block |
||
| 480 | 480 | * |
| 481 | 481 | * @return string |
| 482 | 482 | */ |
| 483 | - public function head($url, $data = array()) |
|
| 483 | + public function head($url, $data=array()) |
|
| 484 | 484 | { |
| 485 | 485 | if (is_array($url)) { |
| 486 | - $data = $url; |
|
| 487 | - $url = $this->baseUrl; |
|
| 486 | + $data=$url; |
|
| 487 | + $url=$this->baseUrl; |
|
| 488 | 488 | } |
| 489 | 489 | $this->setUrl($url, $data); |
| 490 | 490 | $this->setOpt(CURLOPT_CUSTOMREQUEST, 'HEAD'); |
@@ -504,9 +504,9 @@ discard block |
||
| 504 | 504 | public function headerCallback($ch, $header) |
| 505 | 505 | { |
| 506 | 506 | if (preg_match('/^Set-Cookie:\s*([^=]+)=([^;]+)/mi', $header, $cookie) === 1) { |
| 507 | - $this->responseCookies[$cookie[1]] = trim($cookie[2], " \n\r\t\0\x0B"); |
|
| 507 | + $this->responseCookies[$cookie[1]]=trim($cookie[2], " \n\r\t\0\x0B"); |
|
| 508 | 508 | } |
| 509 | - $this->rawResponseHeaders .= $header; |
|
| 509 | + $this->rawResponseHeaders.=$header; |
|
| 510 | 510 | return strlen($header); |
| 511 | 511 | } |
| 512 | 512 | |
@@ -519,11 +519,11 @@ discard block |
||
| 519 | 519 | * |
| 520 | 520 | * @return string |
| 521 | 521 | */ |
| 522 | - public function options($url, $data = array()) |
|
| 522 | + public function options($url, $data=array()) |
|
| 523 | 523 | { |
| 524 | 524 | if (is_array($url)) { |
| 525 | - $data = $url; |
|
| 526 | - $url = $this->baseUrl; |
|
| 525 | + $data=$url; |
|
| 526 | + $url=$this->baseUrl; |
|
| 527 | 527 | } |
| 528 | 528 | $this->setUrl($url, $data); |
| 529 | 529 | $this->removeHeader('Content-Length'); |
@@ -540,11 +540,11 @@ discard block |
||
| 540 | 540 | * |
| 541 | 541 | * @return string |
| 542 | 542 | */ |
| 543 | - public function patch($url, $data = array()) |
|
| 543 | + public function patch($url, $data=array()) |
|
| 544 | 544 | { |
| 545 | 545 | if (is_array($url)) { |
| 546 | - $data = $url; |
|
| 547 | - $url = $this->baseUrl; |
|
| 546 | + $data=$url; |
|
| 547 | + $url=$this->baseUrl; |
|
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | if (is_array($data) && empty($data)) { |
@@ -582,12 +582,12 @@ discard block |
||
| 582 | 582 | * [2] https://github.com/php/php-src/pull/531 |
| 583 | 583 | * [3] http://php.net/ChangeLog-5.php#5.5.11 |
| 584 | 584 | */ |
| 585 | - public function post($url, $data = array(), $follow_303_with_post = false) |
|
| 585 | + public function post($url, $data=array(), $follow_303_with_post=false) |
|
| 586 | 586 | { |
| 587 | 587 | if (is_array($url)) { |
| 588 | - $follow_303_with_post = (bool)$data; |
|
| 589 | - $data = $url; |
|
| 590 | - $url = $this->baseUrl; |
|
| 588 | + $follow_303_with_post=(bool) $data; |
|
| 589 | + $data=$url; |
|
| 590 | + $url=$this->baseUrl; |
|
| 591 | 591 | } |
| 592 | 592 | |
| 593 | 593 | $this->setUrl($url); |
@@ -624,15 +624,15 @@ discard block |
||
| 624 | 624 | * |
| 625 | 625 | * @return string |
| 626 | 626 | */ |
| 627 | - public function put($url, $data = array()) |
|
| 627 | + public function put($url, $data=array()) |
|
| 628 | 628 | { |
| 629 | 629 | if (is_array($url)) { |
| 630 | - $data = $url; |
|
| 631 | - $url = $this->baseUrl; |
|
| 630 | + $data=$url; |
|
| 631 | + $url=$this->baseUrl; |
|
| 632 | 632 | } |
| 633 | 633 | $this->setUrl($url); |
| 634 | 634 | $this->setOpt(CURLOPT_CUSTOMREQUEST, 'PUT'); |
| 635 | - $put_data = $this->buildPostData($data); |
|
| 635 | + $put_data=$this->buildPostData($data); |
|
| 636 | 636 | if (empty($this->options[CURLOPT_INFILE]) && empty($this->options[CURLOPT_INFILESIZE])) { |
| 637 | 637 | if (is_string($put_data)) { |
| 638 | 638 | $this->setHeader('Content-Length', strlen($put_data)); |
@@ -653,15 +653,15 @@ discard block |
||
| 653 | 653 | * |
| 654 | 654 | * @return string |
| 655 | 655 | */ |
| 656 | - public function search($url, $data = array()) |
|
| 656 | + public function search($url, $data=array()) |
|
| 657 | 657 | { |
| 658 | 658 | if (is_array($url)) { |
| 659 | - $data = $url; |
|
| 660 | - $url = $this->baseUrl; |
|
| 659 | + $data=$url; |
|
| 660 | + $url=$this->baseUrl; |
|
| 661 | 661 | } |
| 662 | 662 | $this->setUrl($url); |
| 663 | 663 | $this->setOpt(CURLOPT_CUSTOMREQUEST, 'SEARCH'); |
| 664 | - $put_data = $this->buildPostData($data); |
|
| 664 | + $put_data=$this->buildPostData($data); |
|
| 665 | 665 | if (empty($this->options[CURLOPT_INFILE]) && empty($this->options[CURLOPT_INFILESIZE])) { |
| 666 | 666 | if (is_string($put_data)) { |
| 667 | 667 | $this->setHeader('Content-Length', strlen($put_data)); |
@@ -680,10 +680,10 @@ discard block |
||
| 680 | 680 | * @param $username |
| 681 | 681 | * @param $password |
| 682 | 682 | */ |
| 683 | - public function setBasicAuthentication($username, $password = '') |
|
| 683 | + public function setBasicAuthentication($username, $password='') |
|
| 684 | 684 | { |
| 685 | 685 | $this->setOpt(CURLOPT_HTTPAUTH, CURLAUTH_BASIC); |
| 686 | - $this->setOpt(CURLOPT_USERPWD, $username . ':' . $password); |
|
| 686 | + $this->setOpt(CURLOPT_USERPWD, $username.':'.$password); |
|
| 687 | 687 | } |
| 688 | 688 | |
| 689 | 689 | /** |
@@ -693,10 +693,10 @@ discard block |
||
| 693 | 693 | * @param $username |
| 694 | 694 | * @param $password |
| 695 | 695 | */ |
| 696 | - public function setDigestAuthentication($username, $password = '') |
|
| 696 | + public function setDigestAuthentication($username, $password='') |
|
| 697 | 697 | { |
| 698 | 698 | $this->setOpt(CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); |
| 699 | - $this->setOpt(CURLOPT_USERPWD, $username . ':' . $password); |
|
| 699 | + $this->setOpt(CURLOPT_USERPWD, $username.':'.$password); |
|
| 700 | 700 | } |
| 701 | 701 | |
| 702 | 702 | /** |
@@ -708,27 +708,27 @@ discard block |
||
| 708 | 708 | */ |
| 709 | 709 | public function setCookie($key, $value) |
| 710 | 710 | { |
| 711 | - $name_chars = array(); |
|
| 711 | + $name_chars=array(); |
|
| 712 | 712 | foreach (str_split($key) as $name_char) { |
| 713 | 713 | if (!isset($this->rfc2616[$name_char])) { |
| 714 | - $name_chars[] = rawurlencode($name_char); |
|
| 714 | + $name_chars[]=rawurlencode($name_char); |
|
| 715 | 715 | } else { |
| 716 | - $name_chars[] = $name_char; |
|
| 716 | + $name_chars[]=$name_char; |
|
| 717 | 717 | } |
| 718 | 718 | } |
| 719 | 719 | |
| 720 | - $value_chars = array(); |
|
| 720 | + $value_chars=array(); |
|
| 721 | 721 | foreach (str_split($value) as $value_char) { |
| 722 | 722 | if (!isset($this->rfc6265[$value_char])) { |
| 723 | - $value_chars[] = rawurlencode($value_char); |
|
| 723 | + $value_chars[]=rawurlencode($value_char); |
|
| 724 | 724 | } else { |
| 725 | - $value_chars[] = $value_char; |
|
| 725 | + $value_chars[]=$value_char; |
|
| 726 | 726 | } |
| 727 | 727 | } |
| 728 | 728 | |
| 729 | - $this->cookies[implode('', $name_chars)] = implode('', $value_chars); |
|
| 730 | - $this->setOpt(CURLOPT_COOKIE, implode('; ', array_map(function ($k, $v) { |
|
| 731 | - return $k . '=' . $v; |
|
| 729 | + $this->cookies[implode('', $name_chars)]=implode('', $value_chars); |
|
| 730 | + $this->setOpt(CURLOPT_COOKIE, implode('; ', array_map(function($k, $v) { |
|
| 731 | + return $k.'='.$v; |
|
| 732 | 732 | }, array_keys($this->cookies), array_values($this->cookies)))); |
| 733 | 733 | } |
| 734 | 734 | |
@@ -741,29 +741,29 @@ discard block |
||
| 741 | 741 | public function setCookies($cookies) |
| 742 | 742 | { |
| 743 | 743 | foreach ($cookies as $key => $value) { |
| 744 | - $name_chars = array(); |
|
| 744 | + $name_chars=array(); |
|
| 745 | 745 | foreach (str_split($key) as $name_char) { |
| 746 | 746 | if (!isset($this->rfc2616[$name_char])) { |
| 747 | - $name_chars[] = rawurlencode($name_char); |
|
| 747 | + $name_chars[]=rawurlencode($name_char); |
|
| 748 | 748 | } else { |
| 749 | - $name_chars[] = $name_char; |
|
| 749 | + $name_chars[]=$name_char; |
|
| 750 | 750 | } |
| 751 | 751 | } |
| 752 | 752 | |
| 753 | - $value_chars = array(); |
|
| 753 | + $value_chars=array(); |
|
| 754 | 754 | foreach (str_split($value) as $value_char) { |
| 755 | 755 | if (!isset($this->rfc6265[$value_char])) { |
| 756 | - $value_chars[] = rawurlencode($value_char); |
|
| 756 | + $value_chars[]=rawurlencode($value_char); |
|
| 757 | 757 | } else { |
| 758 | - $value_chars[] = $value_char; |
|
| 758 | + $value_chars[]=$value_char; |
|
| 759 | 759 | } |
| 760 | 760 | } |
| 761 | 761 | |
| 762 | - $this->cookies[implode('', $name_chars)] = implode('', $value_chars); |
|
| 762 | + $this->cookies[implode('', $name_chars)]=implode('', $value_chars); |
|
| 763 | 763 | } |
| 764 | 764 | |
| 765 | - $this->setOpt(CURLOPT_COOKIE, implode('; ', array_map(function ($k, $v) { |
|
| 766 | - return $k . '=' . $v; |
|
| 765 | + $this->setOpt(CURLOPT_COOKIE, implode('; ', array_map(function($k, $v) { |
|
| 766 | + return $k.'='.$v; |
|
| 767 | 767 | }, array_keys($this->cookies), array_values($this->cookies)))); |
| 768 | 768 | } |
| 769 | 769 | |
@@ -803,14 +803,14 @@ discard block |
||
| 803 | 803 | { |
| 804 | 804 | // Make compatible with PHP version both before and after 5.5.0. PHP 5.5.0 added the cURL resource as the first |
| 805 | 805 | // argument to the CURLOPT_PROGRESSFUNCTION callback. |
| 806 | - $gte_v550 = version_compare(PHP_VERSION, '5.5.0') >= 0; |
|
| 806 | + $gte_v550=version_compare(PHP_VERSION, '5.5.0') >= 0; |
|
| 807 | 807 | if ($gte_v550) { |
| 808 | - $callback = function ($resource, $download_size, $downloaded, $upload_size, $uploaded) use ($bytes) { |
|
| 808 | + $callback=function($resource, $download_size, $downloaded, $upload_size, $uploaded) use ($bytes) { |
|
| 809 | 809 | // Abort the transfer when $downloaded bytes exceeds maximum $bytes by returning a non-zero value. |
| 810 | 810 | return $downloaded > $bytes ? 1 : 0; |
| 811 | 811 | }; |
| 812 | 812 | } else { |
| 813 | - $callback = function ($download_size, $downloaded, $upload_size, $uploaded) use ($bytes) { |
|
| 813 | + $callback=function($download_size, $downloaded, $upload_size, $uploaded) use ($bytes) { |
|
| 814 | 814 | return $downloaded > $bytes ? 1 : 0; |
| 815 | 815 | }; |
| 816 | 816 | } |
@@ -889,20 +889,20 @@ discard block |
||
| 889 | 889 | */ |
| 890 | 890 | public function setDefaultJsonDecoder() |
| 891 | 891 | { |
| 892 | - $args = func_get_args(); |
|
| 893 | - $this->jsonDecoder = function ($response) use ($args) { |
|
| 892 | + $args=func_get_args(); |
|
| 893 | + $this->jsonDecoder=function($response) use ($args) { |
|
| 894 | 894 | array_unshift($args, $response); |
| 895 | 895 | |
| 896 | 896 | // Call json_decode() without the $options parameter in PHP |
| 897 | 897 | // versions less than 5.4.0 as the $options parameter was added in |
| 898 | 898 | // PHP version 5.4.0. |
| 899 | 899 | if (version_compare(PHP_VERSION, '5.4.0', '<')) { |
| 900 | - $args = array_slice($args, 0, 3); |
|
| 900 | + $args=array_slice($args, 0, 3); |
|
| 901 | 901 | } |
| 902 | 902 | |
| 903 | - $json_obj = call_user_func_array('json_decode', $args); |
|
| 903 | + $json_obj=call_user_func_array('json_decode', $args); |
|
| 904 | 904 | if (!($json_obj === null)) { |
| 905 | - $response = $json_obj; |
|
| 905 | + $response=$json_obj; |
|
| 906 | 906 | } |
| 907 | 907 | return $response; |
| 908 | 908 | }; |
@@ -915,10 +915,10 @@ discard block |
||
| 915 | 915 | */ |
| 916 | 916 | public function setDefaultXmlDecoder() |
| 917 | 917 | { |
| 918 | - $this->xmlDecoder = function ($response) { |
|
| 919 | - $xml_obj = @simplexml_load_string($response); |
|
| 918 | + $this->xmlDecoder=function($response) { |
|
| 919 | + $xml_obj=@simplexml_load_string($response); |
|
| 920 | 920 | if (!($xml_obj === false)) { |
| 921 | - $response = $xml_obj; |
|
| 921 | + $response=$xml_obj; |
|
| 922 | 922 | } |
| 923 | 923 | return $response; |
| 924 | 924 | }; |
@@ -930,15 +930,15 @@ discard block |
||
| 930 | 930 | * @access public |
| 931 | 931 | * @param $decoder string|callable |
| 932 | 932 | */ |
| 933 | - public function setDefaultDecoder($decoder = 'json') |
|
| 933 | + public function setDefaultDecoder($decoder='json') |
|
| 934 | 934 | { |
| 935 | 935 | if (is_callable($decoder)) { |
| 936 | - $this->defaultDecoder = $decoder; |
|
| 936 | + $this->defaultDecoder=$decoder; |
|
| 937 | 937 | } else { |
| 938 | 938 | if ($decoder === 'json') { |
| 939 | - $this->defaultDecoder = $this->jsonDecoder; |
|
| 939 | + $this->defaultDecoder=$this->jsonDecoder; |
|
| 940 | 940 | } elseif ($decoder === 'xml') { |
| 941 | - $this->defaultDecoder = $this->xmlDecoder; |
|
| 941 | + $this->defaultDecoder=$this->xmlDecoder; |
|
| 942 | 942 | } |
| 943 | 943 | } |
| 944 | 944 | } |
@@ -960,10 +960,10 @@ discard block |
||
| 960 | 960 | */ |
| 961 | 961 | public function setDefaultUserAgent() |
| 962 | 962 | { |
| 963 | - $user_agent = 'puck client' . self::VERSION . ' mini'; |
|
| 964 | - $user_agent .= ' PHP/' . PHP_VERSION; |
|
| 965 | - $curl_version = curl_version(); |
|
| 966 | - $user_agent .= ' curl/' . $curl_version['version']; |
|
| 963 | + $user_agent='puck client'.self::VERSION.' mini'; |
|
| 964 | + $user_agent.=' PHP/'.PHP_VERSION; |
|
| 965 | + $curl_version=curl_version(); |
|
| 966 | + $user_agent.=' curl/'.$curl_version['version']; |
|
| 967 | 967 | $this->setUserAgent($user_agent); |
| 968 | 968 | } |
| 969 | 969 | |
@@ -978,10 +978,10 @@ discard block |
||
| 978 | 978 | */ |
| 979 | 979 | public function setHeader($key, $value) |
| 980 | 980 | { |
| 981 | - $this->headers[$key] = $value; |
|
| 982 | - $headers = array(); |
|
| 981 | + $this->headers[$key]=$value; |
|
| 982 | + $headers=array(); |
|
| 983 | 983 | foreach ($this->headers as $key => $value) { |
| 984 | - $headers[] = $key . ': ' . $value; |
|
| 984 | + $headers[]=$key.': '.$value; |
|
| 985 | 985 | } |
| 986 | 986 | $this->setOpt(CURLOPT_HTTPHEADER, $headers); |
| 987 | 987 | } |
@@ -997,12 +997,12 @@ discard block |
||
| 997 | 997 | public function setHeaders($headers) |
| 998 | 998 | { |
| 999 | 999 | foreach ($headers as $key => $value) { |
| 1000 | - $this->headers[$key] = $value; |
|
| 1000 | + $this->headers[$key]=$value; |
|
| 1001 | 1001 | } |
| 1002 | 1002 | |
| 1003 | - $headers = array(); |
|
| 1003 | + $headers=array(); |
|
| 1004 | 1004 | foreach ($this->headers as $key => $value) { |
| 1005 | - $headers[] = $key . ': ' . $value; |
|
| 1005 | + $headers[]=$key.': '.$value; |
|
| 1006 | 1006 | } |
| 1007 | 1007 | $this->setOpt(CURLOPT_HTTPHEADER, $headers); |
| 1008 | 1008 | } |
@@ -1016,7 +1016,7 @@ discard block |
||
| 1016 | 1016 | public function setJsonDecoder($function) |
| 1017 | 1017 | { |
| 1018 | 1018 | if (is_callable($function)) { |
| 1019 | - $this->jsonDecoder = $function; |
|
| 1019 | + $this->jsonDecoder=$function; |
|
| 1020 | 1020 | } |
| 1021 | 1021 | } |
| 1022 | 1022 | |
@@ -1029,7 +1029,7 @@ discard block |
||
| 1029 | 1029 | public function setXmlDecoder($function) |
| 1030 | 1030 | { |
| 1031 | 1031 | if (is_callable($function)) { |
| 1032 | - $this->xmlDecoder = $function; |
|
| 1032 | + $this->xmlDecoder=$function; |
|
| 1033 | 1033 | } |
| 1034 | 1034 | } |
| 1035 | 1035 | |
@@ -1044,17 +1044,17 @@ discard block |
||
| 1044 | 1044 | */ |
| 1045 | 1045 | public function setOpt($option, $value) |
| 1046 | 1046 | { |
| 1047 | - $required_options = array( |
|
| 1047 | + $required_options=array( |
|
| 1048 | 1048 | CURLOPT_RETURNTRANSFER => 'CURLOPT_RETURNTRANSFER', |
| 1049 | 1049 | ); |
| 1050 | 1050 | |
| 1051 | 1051 | if (in_array($option, array_keys($required_options), true) && !($value === true)) { |
| 1052 | - trigger_error($required_options[$option] . ' is a required option', E_USER_WARNING); |
|
| 1052 | + trigger_error($required_options[$option].' is a required option', E_USER_WARNING); |
|
| 1053 | 1053 | } |
| 1054 | 1054 | |
| 1055 | - $success = curl_setopt($this->curl, $option, $value); |
|
| 1055 | + $success=curl_setopt($this->curl, $option, $value); |
|
| 1056 | 1056 | if ($success) { |
| 1057 | - $this->options[$option] = $value; |
|
| 1057 | + $this->options[$option]=$value; |
|
| 1058 | 1058 | } |
| 1059 | 1059 | return $success; |
| 1060 | 1060 | } |
@@ -1119,10 +1119,10 @@ discard block |
||
| 1119 | 1119 | * @param $url |
| 1120 | 1120 | * @param $data |
| 1121 | 1121 | */ |
| 1122 | - public function setUrl($url, $data = array()) |
|
| 1122 | + public function setUrl($url, $data=array()) |
|
| 1123 | 1123 | { |
| 1124 | - $this->baseUrl = $url; |
|
| 1125 | - $this->url = $this->buildURL($url, $data); |
|
| 1124 | + $this->baseUrl=$url; |
|
| 1125 | + $this->url=$this->buildURL($url, $data); |
|
| 1126 | 1126 | $this->setOpt(CURLOPT_URL, $this->url); |
| 1127 | 1127 | } |
| 1128 | 1128 | |
@@ -1145,7 +1145,7 @@ discard block |
||
| 1145 | 1145 | */ |
| 1146 | 1146 | public function success($callback) |
| 1147 | 1147 | { |
| 1148 | - $this->successFunction = $callback; |
|
| 1148 | + $this->successFunction=$callback; |
|
| 1149 | 1149 | } |
| 1150 | 1150 | |
| 1151 | 1151 | /** |
@@ -1159,9 +1159,9 @@ discard block |
||
| 1159 | 1159 | public function unsetHeader($key) |
| 1160 | 1160 | { |
| 1161 | 1161 | unset($this->headers[$key]); |
| 1162 | - $headers = array(); |
|
| 1162 | + $headers=array(); |
|
| 1163 | 1163 | foreach ($this->headers as $key => $value) { |
| 1164 | - $headers[] = $key . ': ' . $value; |
|
| 1164 | + $headers[]=$key.': '.$value; |
|
| 1165 | 1165 | } |
| 1166 | 1166 | $this->setOpt(CURLOPT_HTTPHEADER, $headers); |
| 1167 | 1167 | } |
@@ -1187,7 +1187,7 @@ discard block |
||
| 1187 | 1187 | * @param bool $on |
| 1188 | 1188 | * @param resource $output |
| 1189 | 1189 | */ |
| 1190 | - public function verbose($on = true, $output = STDERR) |
|
| 1190 | + public function verbose($on=true, $output=STDERR) |
|
| 1191 | 1191 | { |
| 1192 | 1192 | // Turn off CURLINFO_HEADER_OUT for verbose to work. This has the side |
| 1193 | 1193 | // effect of causing Curl::requestHeaders to be empty. |
@@ -1210,9 +1210,9 @@ discard block |
||
| 1210 | 1210 | |
| 1211 | 1211 | public function __get($name) |
| 1212 | 1212 | { |
| 1213 | - $return = null; |
|
| 1214 | - if (in_array($name, self::$deferredProperties) && is_callable(array($this, $getter = '__get_' . $name))) { |
|
| 1215 | - $return = $this->$name = $this->$getter(); |
|
| 1213 | + $return=null; |
|
| 1214 | + if (in_array($name, self::$deferredProperties) && is_callable(array($this, $getter='__get_'.$name))) { |
|
| 1215 | + $return=$this->$name=$this->$getter(); |
|
| 1216 | 1216 | } |
| 1217 | 1217 | return $return; |
| 1218 | 1218 | } |
@@ -1266,9 +1266,9 @@ discard block |
||
| 1266 | 1266 | * |
| 1267 | 1267 | * @return string |
| 1268 | 1268 | */ |
| 1269 | - private function buildURL($url, $data = array()) |
|
| 1269 | + private function buildURL($url, $data=array()) |
|
| 1270 | 1270 | { |
| 1271 | - return $url . (empty($data) ? '' : '?' . http_build_query($data, '', '&')); |
|
| 1271 | + return $url.(empty($data) ? '' : '?'.http_build_query($data, '', '&')); |
|
| 1272 | 1272 | } |
| 1273 | 1273 | |
| 1274 | 1274 | /** |
@@ -1281,19 +1281,19 @@ discard block |
||
| 1281 | 1281 | */ |
| 1282 | 1282 | private function parseHeaders($raw_headers) |
| 1283 | 1283 | { |
| 1284 | - $raw_headers = preg_split('/\r\n/', $raw_headers, null, PREG_SPLIT_NO_EMPTY); |
|
| 1285 | - $http_headers = []; |
|
| 1284 | + $raw_headers=preg_split('/\r\n/', $raw_headers, null, PREG_SPLIT_NO_EMPTY); |
|
| 1285 | + $http_headers=[]; |
|
| 1286 | 1286 | |
| 1287 | - $raw_headers_count = count($raw_headers); |
|
| 1288 | - for ($i = 1; $i < $raw_headers_count; $i++) { |
|
| 1289 | - list($key, $value) = explode(':', $raw_headers[$i], 2); |
|
| 1290 | - $key = trim($key); |
|
| 1291 | - $value = trim($value); |
|
| 1287 | + $raw_headers_count=count($raw_headers); |
|
| 1288 | + for ($i=1; $i < $raw_headers_count; $i++) { |
|
| 1289 | + list($key, $value)=explode(':', $raw_headers[$i], 2); |
|
| 1290 | + $key=trim($key); |
|
| 1291 | + $value=trim($value); |
|
| 1292 | 1292 | // Use isset() as array_key_exists() and ArrayAccess are not compatible. |
| 1293 | 1293 | if (isset($http_headers[$key])) { |
| 1294 | - $http_headers[$key] .= ',' . $value; |
|
| 1294 | + $http_headers[$key].=','.$value; |
|
| 1295 | 1295 | } else { |
| 1296 | - $http_headers[$key] = $value; |
|
| 1296 | + $http_headers[$key]=$value; |
|
| 1297 | 1297 | } |
| 1298 | 1298 | } |
| 1299 | 1299 | |
@@ -1310,11 +1310,11 @@ discard block |
||
| 1310 | 1310 | */ |
| 1311 | 1311 | private function parseRequestHeaders($raw_headers) |
| 1312 | 1312 | { |
| 1313 | - $request_headers = []; |
|
| 1314 | - list($first_line, $headers) = $this->parseHeaders($raw_headers); |
|
| 1315 | - $request_headers['Request-Line'] = $first_line; |
|
| 1313 | + $request_headers=[]; |
|
| 1314 | + list($first_line, $headers)=$this->parseHeaders($raw_headers); |
|
| 1315 | + $request_headers['Request-Line']=$first_line; |
|
| 1316 | 1316 | foreach ($headers as $key => $value) { |
| 1317 | - $request_headers[$key] = $value; |
|
| 1317 | + $request_headers[$key]=$value; |
|
| 1318 | 1318 | } |
| 1319 | 1319 | return $request_headers; |
| 1320 | 1320 | } |
@@ -1333,22 +1333,22 @@ discard block |
||
| 1333 | 1333 | */ |
| 1334 | 1334 | private function parseResponse($response_headers, $raw_response) |
| 1335 | 1335 | { |
| 1336 | - $response = $raw_response; |
|
| 1336 | + $response=$raw_response; |
|
| 1337 | 1337 | if (isset($response_headers['Content-Type'])) { |
| 1338 | 1338 | if (preg_match($this->jsonPattern, $response_headers['Content-Type'])) { |
| 1339 | - $json_decoder = $this->jsonDecoder; |
|
| 1339 | + $json_decoder=$this->jsonDecoder; |
|
| 1340 | 1340 | if (is_callable($json_decoder)) { |
| 1341 | - $response = $json_decoder($response); |
|
| 1341 | + $response=$json_decoder($response); |
|
| 1342 | 1342 | } |
| 1343 | 1343 | } elseif (preg_match($this->xmlPattern, $response_headers['Content-Type'])) { |
| 1344 | - $xml_decoder = $this->xmlDecoder; |
|
| 1344 | + $xml_decoder=$this->xmlDecoder; |
|
| 1345 | 1345 | if (is_callable($xml_decoder)) { |
| 1346 | - $response = $xml_decoder($response); |
|
| 1346 | + $response=$xml_decoder($response); |
|
| 1347 | 1347 | } |
| 1348 | 1348 | } else { |
| 1349 | - $decoder = $this->defaultDecoder; |
|
| 1349 | + $decoder=$this->defaultDecoder; |
|
| 1350 | 1350 | if (is_callable($decoder)) { |
| 1351 | - $response = $decoder($response); |
|
| 1351 | + $response=$decoder($response); |
|
| 1352 | 1352 | } |
| 1353 | 1353 | } |
| 1354 | 1354 | } |
@@ -1366,20 +1366,20 @@ discard block |
||
| 1366 | 1366 | */ |
| 1367 | 1367 | private function parseResponseHeaders($raw_response_headers) |
| 1368 | 1368 | { |
| 1369 | - $response_header_array = explode("\r\n\r\n", $raw_response_headers); |
|
| 1370 | - $response_header = ''; |
|
| 1371 | - for ($i = count($response_header_array) - 1; $i >= 0; $i--) { |
|
| 1369 | + $response_header_array=explode("\r\n\r\n", $raw_response_headers); |
|
| 1370 | + $response_header=''; |
|
| 1371 | + for ($i=count($response_header_array) - 1; $i >= 0; $i--) { |
|
| 1372 | 1372 | if (stripos($response_header_array[$i], 'HTTP/') === 0) { |
| 1373 | - $response_header = $response_header_array[$i]; |
|
| 1373 | + $response_header=$response_header_array[$i]; |
|
| 1374 | 1374 | break; |
| 1375 | 1375 | } |
| 1376 | 1376 | } |
| 1377 | 1377 | |
| 1378 | - $response_headers = []; |
|
| 1379 | - list($first_line, $headers) = $this->parseHeaders($response_header); |
|
| 1380 | - $response_headers['Status-Line'] = $first_line; |
|
| 1378 | + $response_headers=[]; |
|
| 1379 | + list($first_line, $headers)=$this->parseHeaders($response_header); |
|
| 1380 | + $response_headers['Status-Line']=$first_line; |
|
| 1381 | 1381 | foreach ($headers as $key => $value) { |
| 1382 | - $response_headers[$key] = $value; |
|
| 1382 | + $response_headers[$key]=$value; |
|
| 1383 | 1383 | } |
| 1384 | 1384 | return $response_headers; |
| 1385 | 1385 | } |
@@ -42,16 +42,16 @@ discard block |
||
| 42 | 42 | * @return array |
| 43 | 43 | */ |
| 44 | 44 | public static function collapse($array) { |
| 45 | - $results = []; |
|
| 45 | + $results=[]; |
|
| 46 | 46 | |
| 47 | 47 | foreach ($array as $values) { |
| 48 | 48 | if ($values instanceof Collection) { |
| 49 | - $values = $values->all(); |
|
| 49 | + $values=$values->all(); |
|
| 50 | 50 | } elseif (!is_array($values)) { |
| 51 | 51 | continue; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - $results = array_merge($results, $values); |
|
| 54 | + $results=array_merge($results, $values); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | return $results; |
@@ -74,14 +74,14 @@ discard block |
||
| 74 | 74 | * @param string $prepend |
| 75 | 75 | * @return array |
| 76 | 76 | */ |
| 77 | - public static function dot($array, $prepend = '') { |
|
| 78 | - $results = []; |
|
| 77 | + public static function dot($array, $prepend='') { |
|
| 78 | + $results=[]; |
|
| 79 | 79 | |
| 80 | 80 | foreach ($array as $key => $value) { |
| 81 | 81 | if (is_array($value) && !empty($value)) { |
| 82 | - $results = array_merge($results, static::dot($value, $prepend . $key . '.')); |
|
| 82 | + $results=array_merge($results, static::dot($value, $prepend.$key.'.')); |
|
| 83 | 83 | } else { |
| 84 | - $results[$prepend . $key] = $value; |
|
| 84 | + $results[$prepend.$key]=$value; |
|
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | * @param mixed $default |
| 125 | 125 | * @return mixed |
| 126 | 126 | */ |
| 127 | - public static function first($array, callable $callback = null, $default = null) { |
|
| 127 | + public static function first($array, callable $callback=null, $default=null) { |
|
| 128 | 128 | if (is_null($callback)) { |
| 129 | 129 | if (empty($array)) { |
| 130 | 130 | return value($default); |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * @param mixed $default |
| 153 | 153 | * @return mixed |
| 154 | 154 | */ |
| 155 | - public static function last($array, callable $callback = null, $default = null) { |
|
| 155 | + public static function last($array, callable $callback=null, $default=null) { |
|
| 156 | 156 | if (is_null($callback)) { |
| 157 | 157 | return empty($array) ? value($default) : end($array); |
| 158 | 158 | } |
@@ -167,9 +167,9 @@ discard block |
||
| 167 | 167 | * @param int $depth |
| 168 | 168 | * @return array |
| 169 | 169 | */ |
| 170 | - public static function flatten($array, $depth = INF) { |
|
| 171 | - return array_reduce($array, function ($result, $item) use ($depth) { |
|
| 172 | - $item = $item instanceof Collection ? $item->all() : $item; |
|
| 170 | + public static function flatten($array, $depth=INF) { |
|
| 171 | + return array_reduce($array, function($result, $item) use ($depth) { |
|
| 172 | + $item=$item instanceof Collection ? $item->all() : $item; |
|
| 173 | 173 | |
| 174 | 174 | if (!is_array($item)) { |
| 175 | 175 | return array_merge($result, [$item]); |
@@ -189,9 +189,9 @@ discard block |
||
| 189 | 189 | * @return void |
| 190 | 190 | */ |
| 191 | 191 | public static function forget(&$array, $keys) { |
| 192 | - $original = &$array; |
|
| 192 | + $original=&$array; |
|
| 193 | 193 | |
| 194 | - $keys = (array)$keys; |
|
| 194 | + $keys=(array) $keys; |
|
| 195 | 195 | |
| 196 | 196 | if (count($keys) === 0) { |
| 197 | 197 | return; |
@@ -205,16 +205,16 @@ discard block |
||
| 205 | 205 | continue; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - $parts = explode('.', $key); |
|
| 208 | + $parts=explode('.', $key); |
|
| 209 | 209 | |
| 210 | 210 | // clean up before each pass |
| 211 | - $array = &$original; |
|
| 211 | + $array=&$original; |
|
| 212 | 212 | |
| 213 | 213 | while (count($parts) > 1) { |
| 214 | - $part = array_shift($parts); |
|
| 214 | + $part=array_shift($parts); |
|
| 215 | 215 | |
| 216 | 216 | if (isset($array[$part]) && is_array($array[$part])) { |
| 217 | - $array = &$array[$part]; |
|
| 217 | + $array=&$array[$part]; |
|
| 218 | 218 | } else { |
| 219 | 219 | continue 2; |
| 220 | 220 | } |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | * @param mixed $default |
| 233 | 233 | * @return mixed |
| 234 | 234 | */ |
| 235 | - public static function get($array, $key, $default = null) { |
|
| 235 | + public static function get($array, $key, $default=null) { |
|
| 236 | 236 | if (!static::accessible($array)) { |
| 237 | 237 | return value($default); |
| 238 | 238 | } |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | |
| 248 | 248 | foreach (explode('.', $key) as $segment) { |
| 249 | 249 | if (static::accessible($array) && static::exists($array, $segment)) { |
| 250 | - $array = $array[$segment]; |
|
| 250 | + $array=$array[$segment]; |
|
| 251 | 251 | } else { |
| 252 | 252 | return value($default); |
| 253 | 253 | } |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | return false; |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | - $keys = (array)$keys; |
|
| 271 | + $keys=(array) $keys; |
|
| 272 | 272 | |
| 273 | 273 | if (!$array) { |
| 274 | 274 | return false; |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | foreach ($keys as $key) { |
| 282 | - $subKeyArray = $array; |
|
| 282 | + $subKeyArray=$array; |
|
| 283 | 283 | |
| 284 | 284 | if (static::exists($array, $key)) { |
| 285 | 285 | continue; |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | |
| 288 | 288 | foreach (explode('.', $key) as $segment) { |
| 289 | 289 | if (static::accessible($subKeyArray) && static::exists($subKeyArray, $segment)) { |
| 290 | - $subKeyArray = $subKeyArray[$segment]; |
|
| 290 | + $subKeyArray=$subKeyArray[$segment]; |
|
| 291 | 291 | } else { |
| 292 | 292 | return false; |
| 293 | 293 | } |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | * @return bool |
| 307 | 307 | */ |
| 308 | 308 | public static function isAssoc(array $array) { |
| 309 | - $keys = array_keys($array); |
|
| 309 | + $keys=array_keys($array); |
|
| 310 | 310 | |
| 311 | 311 | return array_keys($keys) !== $keys; |
| 312 | 312 | } |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | return false; |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | - return (bool)count(array_filter($array, 'is_array')); |
|
| 327 | + return (bool) count(array_filter($array, 'is_array')); |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | /** |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | * @return array |
| 336 | 336 | */ |
| 337 | 337 | public static function only($array, $keys) { |
| 338 | - return array_intersect_key($array, array_flip((array)$keys)); |
|
| 338 | + return array_intersect_key($array, array_flip((array) $keys)); |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | /** |
@@ -346,23 +346,23 @@ discard block |
||
| 346 | 346 | * @param string|array|null $key |
| 347 | 347 | * @return array |
| 348 | 348 | */ |
| 349 | - public static function pluck($array, $value, $key = null) { |
|
| 350 | - $results = []; |
|
| 349 | + public static function pluck($array, $value, $key=null) { |
|
| 350 | + $results=[]; |
|
| 351 | 351 | |
| 352 | - list($value, $key) = static::explodePluckParameters($value, $key); |
|
| 352 | + list($value, $key)=static::explodePluckParameters($value, $key); |
|
| 353 | 353 | |
| 354 | 354 | foreach ($array as $item) { |
| 355 | - $itemValue = data_get($item, $value); |
|
| 355 | + $itemValue=data_get($item, $value); |
|
| 356 | 356 | |
| 357 | 357 | // If the key is "null", we will just append the value to the array and keep |
| 358 | 358 | // looping. Otherwise we will key the array using the value of the key we |
| 359 | 359 | // received from the developer. Then we'll return the final array form. |
| 360 | 360 | if (is_null($key)) { |
| 361 | - $results[] = $itemValue; |
|
| 361 | + $results[]=$itemValue; |
|
| 362 | 362 | } else { |
| 363 | - $itemKey = data_get($item, $key); |
|
| 363 | + $itemKey=data_get($item, $key); |
|
| 364 | 364 | |
| 365 | - $results[$itemKey] = $itemValue; |
|
| 365 | + $results[$itemKey]=$itemValue; |
|
| 366 | 366 | } |
| 367 | 367 | } |
| 368 | 368 | |
@@ -377,9 +377,9 @@ discard block |
||
| 377 | 377 | * @return array |
| 378 | 378 | */ |
| 379 | 379 | protected static function explodePluckParameters($value, $key) { |
| 380 | - $value = is_string($value) ? explode('.', $value) : $value; |
|
| 380 | + $value=is_string($value) ? explode('.', $value) : $value; |
|
| 381 | 381 | |
| 382 | - $key = is_null($key) || is_array($key) ? $key : explode('.', $key); |
|
| 382 | + $key=is_null($key) || is_array($key) ? $key : explode('.', $key); |
|
| 383 | 383 | |
| 384 | 384 | return [$value, $key]; |
| 385 | 385 | } |
@@ -392,11 +392,11 @@ discard block |
||
| 392 | 392 | * @param mixed $key |
| 393 | 393 | * @return array |
| 394 | 394 | */ |
| 395 | - public static function prepend($array, $value, $key = null) { |
|
| 395 | + public static function prepend($array, $value, $key=null) { |
|
| 396 | 396 | if (is_null($key)) { |
| 397 | 397 | array_unshift($array, $value); |
| 398 | 398 | } else { |
| 399 | - $array = [$key => $value] + $array; |
|
| 399 | + $array=[$key => $value] + $array; |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | return $array; |
@@ -410,8 +410,8 @@ discard block |
||
| 410 | 410 | * @param mixed $default |
| 411 | 411 | * @return mixed |
| 412 | 412 | */ |
| 413 | - public static function pull(&$array, $key, $default = null) { |
|
| 414 | - $value = static::get($array, $key, $default); |
|
| 413 | + public static function pull(&$array, $key, $default=null) { |
|
| 414 | + $value=static::get($array, $key, $default); |
|
| 415 | 415 | |
| 416 | 416 | static::forget($array, $key); |
| 417 | 417 | |
@@ -430,25 +430,25 @@ discard block |
||
| 430 | 430 | */ |
| 431 | 431 | public static function set(&$array, $key, $value) { |
| 432 | 432 | if (is_null($key)) { |
| 433 | - return $array = $value; |
|
| 433 | + return $array=$value; |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - $keys = explode('.', $key); |
|
| 436 | + $keys=explode('.', $key); |
|
| 437 | 437 | |
| 438 | 438 | while (count($keys) > 1) { |
| 439 | - $key = array_shift($keys); |
|
| 439 | + $key=array_shift($keys); |
|
| 440 | 440 | |
| 441 | 441 | // If the key doesn't exist at this depth, we will just create an empty array |
| 442 | 442 | // to hold the next value, allowing us to create the arrays to hold final |
| 443 | 443 | // values at the correct depth. Then we'll keep digging into the array. |
| 444 | 444 | if (!isset($array[$key]) || !is_array($array[$key])) { |
| 445 | - $array[$key] = []; |
|
| 445 | + $array[$key]=[]; |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | - $array = &$array[$key]; |
|
| 448 | + $array=&$array[$key]; |
|
| 449 | 449 | } |
| 450 | 450 | |
| 451 | - $array[array_shift($keys)] = $value; |
|
| 451 | + $array[array_shift($keys)]=$value; |
|
| 452 | 452 | |
| 453 | 453 | return $array; |
| 454 | 454 | } |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | public static function sortRecursive($array) { |
| 486 | 486 | foreach ($array as &$value) { |
| 487 | 487 | if (is_array($value)) { |
| 488 | - $value = static::sortRecursive($value); |
|
| 488 | + $value=static::sortRecursive($value); |
|
| 489 | 489 | } |
| 490 | 490 | } |
| 491 | 491 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * |
| 19 | 19 | * @var array |
| 20 | 20 | */ |
| 21 | - protected $loadedConfigurations = []; |
|
| 21 | + protected $loadedConfigurations=[]; |
|
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * 应用的根目录. |
@@ -32,16 +32,16 @@ discard block |
||
| 32 | 32 | $this->initContainer(); |
| 33 | 33 | $this->initConfig(); |
| 34 | 34 | } |
| 35 | - private function initConfig(){ |
|
| 35 | + private function initConfig() { |
|
| 36 | 36 | $this->configure('core'); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - private function initEnv(){ |
|
| 40 | - $dotEnv = new Dotenv($this->basePath); |
|
| 39 | + private function initEnv() { |
|
| 40 | + $dotEnv=new Dotenv($this->basePath); |
|
| 41 | 41 | $dotEnv->load(); |
| 42 | 42 | date_default_timezone_set(env('APP_TIMEZONE', 'Asia/Shanghai')); |
| 43 | 43 | define('IS_CLI', $this->runningInConsole()); |
| 44 | - define('IS_DEBUG',env('DEBUG',false)); |
|
| 44 | + define('IS_DEBUG', env('DEBUG', false)); |
|
| 45 | 45 | if (IS_DEBUG) { |
| 46 | 46 | error_reporting(E_ALL); |
| 47 | 47 | @ini_set('display_errors', 'On'); |
@@ -63,12 +63,12 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | private function initContainer() { |
| 65 | 65 | static::setInstance($this); |
| 66 | - $this->instance('app',$this); |
|
| 67 | - $this->instance('config',new Config()); |
|
| 68 | - $this->instance('request',new Request($this->config)); |
|
| 69 | - $this->instance('route',new Route($this->request)); |
|
| 70 | - $this->bind('pinyin','\puck\helpers\PinYin'); |
|
| 71 | - $this->bind('curl','\puck\helpers\Curl'); |
|
| 66 | + $this->instance('app', $this); |
|
| 67 | + $this->instance('config', new Config()); |
|
| 68 | + $this->instance('request', new Request($this->config)); |
|
| 69 | + $this->instance('route', new Route($this->request)); |
|
| 70 | + $this->bind('pinyin', '\puck\helpers\PinYin'); |
|
| 71 | + $this->bind('curl', '\puck\helpers\Curl'); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -77,16 +77,16 @@ discard block |
||
| 77 | 77 | * @param string|null $path |
| 78 | 78 | * @return string |
| 79 | 79 | */ |
| 80 | - public function basePath($path = null) |
|
| 80 | + public function basePath($path=null) |
|
| 81 | 81 | { |
| 82 | 82 | if (isset($this->basePath)) { |
| 83 | 83 | return $this->basePath.($path ? '/'.$path : $path); |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | if ($this->runningInConsole()) { |
| 87 | - $this->basePath = getcwd(); |
|
| 87 | + $this->basePath=getcwd(); |
|
| 88 | 88 | } else { |
| 89 | - $this->basePath = realpath(getcwd().'/../'); |
|
| 89 | + $this->basePath=realpath(getcwd().'/../'); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | return $this->basePath($path); |
@@ -112,8 +112,8 @@ discard block |
||
| 112 | 112 | return; |
| 113 | 113 | } |
| 114 | 114 | //标记为已加载 |
| 115 | - $this->loadedConfigurations[$name] = true; |
|
| 116 | - $path = $this->getConfigurationPath($name); |
|
| 115 | + $this->loadedConfigurations[$name]=true; |
|
| 116 | + $path=$this->getConfigurationPath($name); |
|
| 117 | 117 | if ($path) { |
| 118 | 118 | $this->make('config')->set($name, require $path); |
| 119 | 119 | } |
@@ -130,21 +130,21 @@ discard block |
||
| 130 | 130 | * @param string|null $name |
| 131 | 131 | * @return string |
| 132 | 132 | */ |
| 133 | - public function getConfigurationPath($name = null) |
|
| 133 | + public function getConfigurationPath($name=null) |
|
| 134 | 134 | { |
| 135 | - if (! $name) { |
|
| 136 | - $appConfigDir = $this->basePath('configs').'/'; |
|
| 135 | + if (!$name) { |
|
| 136 | + $appConfigDir=$this->basePath('configs').'/'; |
|
| 137 | 137 | |
| 138 | 138 | if (file_exists($appConfigDir)) { |
| 139 | 139 | return $appConfigDir; |
| 140 | - } elseif (file_exists($path = __DIR__.'/configs/')) { |
|
| 140 | + } elseif (file_exists($path=__DIR__.'/configs/')) { |
|
| 141 | 141 | return $path; |
| 142 | 142 | } |
| 143 | 143 | } else { |
| 144 | - $appConfigPath = $this->basePath('configs').'/'.$name.'.php'; |
|
| 144 | + $appConfigPath=$this->basePath('configs').'/'.$name.'.php'; |
|
| 145 | 145 | if (file_exists($appConfigPath)) { |
| 146 | 146 | return $appConfigPath; |
| 147 | - } elseif (file_exists($path = __DIR__.'/configs/'.$name.'.php')) { |
|
| 147 | + } elseif (file_exists($path=__DIR__.'/configs/'.$name.'.php')) { |
|
| 148 | 148 | return $path; |
| 149 | 149 | } |
| 150 | 150 | } |