@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | public function __construct($options = []) |
| 67 | 67 | { |
| 68 | 68 | $this->_c = Arrays::merge($this->_c, $options); |
| 69 | - setlocale(LC_ALL, (string) I::get($this->_c, 'locale', 'zh_CN.UTF-8')); |
|
| 69 | + setlocale(LC_ALL, (string)I::get($this->_c, 'locale', 'zh_CN.UTF-8')); |
|
| 70 | 70 | clearstatcache(); |
| 71 | 71 | } |
| 72 | 72 | |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | private function __file($file) |
| 94 | 94 | { |
| 95 | - return (string) I::getAlias($file); |
|
| 95 | + return (string)I::getAlias($file); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | if ($result && $info = curl_getinfo($curl)) { |
| 152 | 152 | if (200 == $info['http_code']) { |
| 153 | 153 | $this->_attributes[$hashName]['isExists'] = true; |
| 154 | - $this->_attributes[$hashName]['fileSize'] = (int) $info['download_content_length']; |
|
| 154 | + $this->_attributes[$hashName]['fileSize'] = (int)$info['download_content_length']; |
|
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | curl_close($curl); |
@@ -161,8 +161,8 @@ discard block |
||
| 161 | 161 | if ('fsockopen' === $this->_c['loader']) { |
| 162 | 162 | $url = parse_url($fileName); |
| 163 | 163 | $host = $url['host']; |
| 164 | - $path = (string) I::get($url, 'path', '/'); |
|
| 165 | - $port = (int) I::get($url, 'port', 80); |
|
| 164 | + $path = (string)I::get($url, 'path', '/'); |
|
| 165 | + $port = (int)I::get($url, 'port', 80); |
|
| 166 | 166 | $fp = fsockopen($host, $port); |
| 167 | 167 | if (is_resource($fp)) { |
| 168 | 168 | fputs($fp, "GET {$path} HTTP/1.1\r\n"); |
@@ -171,17 +171,17 @@ discard block |
||
| 171 | 171 | while (!feof($fp)) { |
| 172 | 172 | $line = fgets($fp); |
| 173 | 173 | preg_match('/HTTP.*(\s\d{3}\s)/', $line, $arr) && $this->_attributes[$hashName]['isExists'] = true; |
| 174 | - preg_match('/Content-Length:(.*)/si', $line, $arr) && $this->_attributes[$hashName]['fileSize'] = (int) trim($arr[1]); |
|
| 174 | + preg_match('/Content-Length:(.*)/si', $line, $arr) && $this->_attributes[$hashName]['fileSize'] = (int)trim($arr[1]); |
|
| 175 | 175 | } |
| 176 | 176 | fclose($fp); |
| 177 | 177 | } |
| 178 | 178 | return $this; |
| 179 | 179 | } |
| 180 | - if ('fopen' === $this->_c['loader'] && (bool) ini_get('allow_url_fopen')) { |
|
| 181 | - $headArray = (array) get_headers($fileName, 1); |
|
| 180 | + if ('fopen' === $this->_c['loader'] && (bool)ini_get('allow_url_fopen')) { |
|
| 181 | + $headArray = (array)get_headers($fileName, 1); |
|
| 182 | 182 | if (preg_match('/200/', $headArray[0])) { |
| 183 | 183 | $this->_attributes[$hashName]['isExists'] = true; |
| 184 | - $this->_attributes[$hashName]['fileSize'] = (int) $headArray['Content-Length']; |
|
| 184 | + $this->_attributes[$hashName]['fileSize'] = (int)$headArray['Content-Length']; |
|
| 185 | 185 | } |
| 186 | 186 | return $this; |
| 187 | 187 | } |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | public function line($fileName, $lineNumber = 0, $autoClose = false) |
| 279 | 279 | { |
| 280 | 280 | $spl = $this->spl($fileName, 'r'); |
| 281 | - $lineNumber = (int) $lineNumber; |
|
| 281 | + $lineNumber = (int)$lineNumber; |
|
| 282 | 282 | foreach ($this->linesGenerator($fileName, $autoClose) as $k => $line) { |
| 283 | 283 | if ($k === $lineNumber) { |
| 284 | 284 | $spl->rewind(); |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | */ |
| 385 | 385 | public function getFilesize($fileName) |
| 386 | 386 | { |
| 387 | - return (int) $this->attribute($fileName, 'fileSize'); |
|
| 387 | + return (int)$this->attribute($fileName, 'fileSize'); |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | /** |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | list($originName, $downloadName) = $this->fileMap($fileName); |
| 602 | 602 | $originName = $this->__file($originName); |
| 603 | 603 | try { |
| 604 | - $ip = (string) I::get($config, self::C_DOWNLOAD_IP, '*'); |
|
| 604 | + $ip = (string)I::get($config, self::C_DOWNLOAD_IP, '*'); |
|
| 605 | 605 | if ('*' !== $ip) { |
| 606 | 606 | C::assertTrue(Arrays::in((new Request())->getUserIP(), Strings::toArray($ip)), 'http/1.1 403.6 此 IP 禁止访问'); |
| 607 | 607 | } |
@@ -611,9 +611,9 @@ discard block |
||
| 611 | 611 | header('Accept-Ranges:bytes'); |
| 612 | 612 | header('Content-Length:' . $fileSize); |
| 613 | 613 | header('Content-Disposition: attachment; filename=' . $downloadName); |
| 614 | - $speed = (int) I::get($config, self::C_DOWNLOAD_SPEED, 0); |
|
| 614 | + $speed = (int)I::get($config, self::C_DOWNLOAD_SPEED, 0); |
|
| 615 | 615 | $xSendFile = I::get($config, self::C_DOWNLOAD_X_SEND_FILE, false); |
| 616 | - $xSendFileRoot = (string) I::get($config, self::C_DOWNLOAD_X_SEND_FILE_ROOT, '/protected/'); |
|
| 616 | + $xSendFileRoot = (string)I::get($config, self::C_DOWNLOAD_X_SEND_FILE_ROOT, '/protected/'); |
|
| 617 | 617 | if (true === $xSendFile) { |
| 618 | 618 | $path = rtrim($xSendFileRoot, '/') . '/' . $this->getBasename($originName); |
| 619 | 619 | header('X-Accel-Redirect: ' . $path); // Nginx、Cherokee 实现了该头 |
@@ -38,9 +38,9 @@ discard block |
||
| 38 | 38 | public function dayRange($offset = 0, $time = null) |
| 39 | 39 | { |
| 40 | 40 | null === $time && $time = time(); |
| 41 | - $y = (int) (date('Y', $time)); |
|
| 42 | - $m = (int) (date('m', $time)); |
|
| 43 | - $d = (int) (date('d', $time) + $offset); |
|
| 41 | + $y = (int)(date('Y', $time)); |
|
| 42 | + $m = (int)(date('m', $time)); |
|
| 43 | + $d = (int)(date('d', $time) + $offset); |
|
| 44 | 44 | return [ |
| 45 | 45 | mktime(0, 0, 0, $m, $d, $y), |
| 46 | 46 | mktime(23, 59, 59, $m, $d, $y), |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | public function weekRange($offset = 0, $time = null) |
| 61 | 61 | { |
| 62 | 62 | null === $time && $time = time(); |
| 63 | - $offset = (int) $offset; |
|
| 63 | + $offset = (int)$offset; |
|
| 64 | 64 | return [ |
| 65 | 65 | strtotime(date('Y-m-d', strtotime('Sunday ' . ($offset - 1) . ' week', $time))), |
| 66 | 66 | strtotime(date('Y-m-d', strtotime('Saturday ' . $offset . ' week', $time))) + 24 * 3600 - 1, |
@@ -78,10 +78,10 @@ discard block |
||
| 78 | 78 | public function monthRange($offset = 0, $time = null) |
| 79 | 79 | { |
| 80 | 80 | null === $time && $time = time(); |
| 81 | - $y = (int) (date('Y', $time)); |
|
| 82 | - $m = (int) (date('m', $time) + $offset); |
|
| 81 | + $y = (int)(date('Y', $time)); |
|
| 82 | + $m = (int)(date('m', $time) + $offset); |
|
| 83 | 83 | $begin = mktime(0, 0, 0, $m, 1, $y); |
| 84 | - $end = mktime(23, 59, 59, $m, (int) date('t', $begin), $y); |
|
| 84 | + $end = mktime(23, 59, 59, $m, (int)date('t', $begin), $y); |
|
| 85 | 85 | |
| 86 | 86 | return [$begin, $end]; |
| 87 | 87 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | public function yearRange($offset = 0, $time = null) |
| 98 | 98 | { |
| 99 | 99 | null === $time && $time = time(); |
| 100 | - $year = (int) (date('Y', $time) + $offset); |
|
| 100 | + $year = (int)(date('Y', $time) + $offset); |
|
| 101 | 101 | return [ |
| 102 | 102 | mktime(0, 0, 0, 1, 1, $year), |
| 103 | 103 | mktime(23, 59, 59, 12, 31, $year), |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | public function day($offset = 0, $time = null) |
| 116 | 116 | { |
| 117 | 117 | null === $time && $time = time(); |
| 118 | - $offset = (int) $offset; |
|
| 118 | + $offset = (int)$offset; |
|
| 119 | 119 | return $time + 3600 * 24 * $offset; |
| 120 | 120 | } |
| 121 | 121 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | public function week($offset = 0, $time = null) |
| 131 | 131 | { |
| 132 | 132 | null === $time && $time = time(); |
| 133 | - $offset = (int) $offset; |
|
| 133 | + $offset = (int)$offset; |
|
| 134 | 134 | return $time + 3600 * 24 * 7 * $offset; |
| 135 | 135 | } |
| 136 | 136 | |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | public function month($offset = 0, $time = null) |
| 146 | 146 | { |
| 147 | 147 | null === $time && $time = time(); |
| 148 | - $offset = (int) $offset; |
|
| 148 | + $offset = (int)$offset; |
|
| 149 | 149 | return $time + 3600 * 24 * date('t', $time) * $offset; |
| 150 | 150 | } |
| 151 | 151 | |
@@ -160,8 +160,8 @@ discard block |
||
| 160 | 160 | public function year($offset = 0, $time = null) |
| 161 | 161 | { |
| 162 | 162 | null === $time && $time = time(); |
| 163 | - $offset = (int) $offset; |
|
| 164 | - return mktime((int) date('H', $time), (int) date('i', $time), (int) date('s', $time), (int) date('m', $time), (int) date('d', $time), (int) date('Y', $time) + $offset); |
|
| 163 | + $offset = (int)$offset; |
|
| 164 | + return mktime((int)date('H', $time), (int)date('i', $time), (int)date('s', $time), (int)date('m', $time), (int)date('d', $time), (int)date('Y', $time) + $offset); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | public function isLeapYear($time = null) |
| 201 | 201 | { |
| 202 | 202 | null === $time && $time = time(); |
| 203 | - return (bool) date('L', $time); |
|
| 203 | + return (bool)date('L', $time); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -215,6 +215,6 @@ discard block |
||
| 215 | 215 | public function yearPosition($time = null) |
| 216 | 216 | { |
| 217 | 217 | null === $time && $time = time(); |
| 218 | - return (int) date('z', $time) + 1; |
|
| 218 | + return (int)date('z', $time) + 1; |
|
| 219 | 219 | } |
| 220 | 220 | } |
@@ -201,7 +201,7 @@ |
||
| 201 | 201 | /** @scrutinizer ignore-unhandled */ @ftp_chmod($this->_conn, $mode, $subFile); |
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | - return (bool) /** @scrutinizer ignore-unhandled */ @ftp_chmod($this->_conn, $mode, $file); |
|
| 204 | + return (bool)/** @scrutinizer ignore-unhandled */ @ftp_chmod($this->_conn, $mode, $file); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |