@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | { |
70 | 70 | $base64 = false; |
71 | 71 | $local = new LocalFile(); |
72 | - $local->isFile($file) && $base64 = base64_encode((string) $local->getFileContent($file)); |
|
72 | + $local->isFile($file) && $base64 = base64_encode((string)$local->getFileContent($file)); |
|
73 | 73 | return $base64; |
74 | 74 | } |
75 | 75 | |
@@ -86,6 +86,6 @@ discard block |
||
86 | 86 | public static function toFile($string, $file = null) |
87 | 87 | { |
88 | 88 | null === $file && $file = './Base64_toFile_' . date('YmdHis') . '.txt'; |
89 | - return (bool) file_put_contents($file, base64_decode($string)); |
|
89 | + return (bool)file_put_contents($file, base64_decode($string)); |
|
90 | 90 | } |
91 | 91 | } |
@@ -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 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | private function __file($file) |
93 | 93 | { |
94 | - return (string) I::getAlias($file); |
|
94 | + return (string)I::getAlias($file); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | if ($result && $info = curl_getinfo($curl)) { |
154 | 154 | if (200 == $info['http_code']) { |
155 | 155 | $this->_attributes[$hashName]['isExists'] = true; |
156 | - $this->_attributes[$hashName]['fileSize'] = (int) $info['download_content_length']; |
|
156 | + $this->_attributes[$hashName]['fileSize'] = (int)$info['download_content_length']; |
|
157 | 157 | } |
158 | 158 | } |
159 | 159 | curl_close($curl); |
@@ -163,8 +163,8 @@ discard block |
||
163 | 163 | if ('fsockopen' === $this->_c['loader']) { |
164 | 164 | $url = parse_url($fileName); |
165 | 165 | $host = $url['host']; |
166 | - $path = (string) I::get($url, 'path', '/'); |
|
167 | - $port = (int) I::get($url, 'port', 80); |
|
166 | + $path = (string)I::get($url, 'path', '/'); |
|
167 | + $port = (int)I::get($url, 'port', 80); |
|
168 | 168 | $fp = fsockopen($host, $port); |
169 | 169 | if (is_resource($fp)) { |
170 | 170 | fputs($fp, "GET {$path} HTTP/1.1\r\n"); |
@@ -173,17 +173,17 @@ discard block |
||
173 | 173 | while (!feof($fp)) { |
174 | 174 | $line = fgets($fp); |
175 | 175 | preg_match('/HTTP.*(\s\d{3}\s)/', $line, $arr) && $this->_attributes[$hashName]['isExists'] = true; |
176 | - preg_match('/Content-Length:(.*)/si', $line, $arr) && $this->_attributes[$hashName]['fileSize'] = (int) trim($arr[1]); |
|
176 | + preg_match('/Content-Length:(.*)/si', $line, $arr) && $this->_attributes[$hashName]['fileSize'] = (int)trim($arr[1]); |
|
177 | 177 | } |
178 | 178 | fclose($fp); |
179 | 179 | } |
180 | 180 | return $this; |
181 | 181 | } |
182 | - if ('fopen' === $this->_c['loader'] && (bool) ini_get('allow_url_fopen')) { |
|
183 | - $headArray = (array) get_headers($fileName, 1); |
|
182 | + if ('fopen' === $this->_c['loader'] && (bool)ini_get('allow_url_fopen')) { |
|
183 | + $headArray = (array)get_headers($fileName, 1); |
|
184 | 184 | if (preg_match('/200/', $headArray[0])) { |
185 | 185 | $this->_attributes[$hashName]['isExists'] = true; |
186 | - $this->_attributes[$hashName]['fileSize'] = (int) $headArray['Content-Length']; |
|
186 | + $this->_attributes[$hashName]['fileSize'] = (int)$headArray['Content-Length']; |
|
187 | 187 | } |
188 | 188 | return $this; |
189 | 189 | } |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | public function line($fileName, $lineNumber = 0, $autoClose = false) |
281 | 281 | { |
282 | 282 | $spl = $this->spl($fileName, 'r'); |
283 | - $lineNumber = (int) $lineNumber; |
|
283 | + $lineNumber = (int)$lineNumber; |
|
284 | 284 | foreach ($this->linesGenerator($fileName, $autoClose) as $k => $line) { |
285 | 285 | if ($k === $lineNumber) { |
286 | 286 | $spl->rewind(); |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | */ |
387 | 387 | public function getFilesize($fileName) |
388 | 388 | { |
389 | - return (int) $this->attribute($fileName, 'fileSize'); |
|
389 | + return (int)$this->attribute($fileName, 'fileSize'); |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | /** |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | if (true === $isLocal) { |
423 | 423 | return is_file($this->__file($file)); |
424 | 424 | } else { |
425 | - return (bool) $this->attribute($file, 'isExists'); |
|
425 | + return (bool)$this->attribute($file, 'isExists'); |
|
426 | 426 | } |
427 | 427 | } |
428 | 428 | |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | list($originName, $downloadName) = $this->fileMap($fileName); |
612 | 612 | $originName = $this->__file($originName); |
613 | 613 | try { |
614 | - $ip = (string) I::get($config, self::C_DOWNLOAD_IP, '*'); |
|
614 | + $ip = (string)I::get($config, self::C_DOWNLOAD_IP, '*'); |
|
615 | 615 | if ('*' !== $ip) { |
616 | 616 | C::assertTrue(Arrays::in((new Request())->getUserIP(), Strings::toArray($ip)), 'http/1.1 403.6 此 IP 禁止访问'); |
617 | 617 | } |
@@ -621,9 +621,9 @@ discard block |
||
621 | 621 | header('Accept-Ranges:bytes'); |
622 | 622 | header('Content-Length:' . $fileSize); |
623 | 623 | header('Content-Disposition: attachment; filename=' . $downloadName); |
624 | - $speed = (int) I::get($config, self::C_DOWNLOAD_SPEED, 0); |
|
624 | + $speed = (int)I::get($config, self::C_DOWNLOAD_SPEED, 0); |
|
625 | 625 | $xSendFile = I::get($config, self::C_DOWNLOAD_X_SEND_FILE, false); |
626 | - $xSendFileRoot = (string) I::get($config, self::C_DOWNLOAD_X_SEND_FILE_ROOT, '/protected/'); |
|
626 | + $xSendFileRoot = (string)I::get($config, self::C_DOWNLOAD_X_SEND_FILE_ROOT, '/protected/'); |
|
627 | 627 | if (true === $xSendFile) { |
628 | 628 | $path = rtrim($xSendFileRoot, '/') . '/' . $this->getBasename($originName); |
629 | 629 | header('X-Accel-Redirect: ' . $path); // Nginx、Cherokee 实现了该头 |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | { |
35 | 35 | C::assertTrue(function_exists('ftp_connect'), '请开启 ftp 扩展'); |
36 | 36 | C::assertTrue(Arrays::keyExistsAll(['host', 'username', 'password'], $config, $diff), '缺少 ' . implode(',', $diff) . ' 参数'); |
37 | - $this->_conn = ftp_connect((string) I::get($config, 'host'), (int) I::get($config, 'port', 21), (int) I::get($config, 'timeout', 90)); |
|
37 | + $this->_conn = ftp_connect((string)I::get($config, 'host'), (int)I::get($config, 'port', 21), (int)I::get($config, 'timeout', 90)); |
|
38 | 38 | C::assertTrue(is_resource($this->_conn), '连接失败'); |
39 | - C::assertTrue(@ftp_login($this->_conn, (string) I::get($config, 'username'), (string) I::get($config, 'password')), '账号密码错误'); |
|
39 | + C::assertTrue(@ftp_login($this->_conn, (string)I::get($config, 'username'), (string)I::get($config, 'password')), '账号密码错误'); |
|
40 | 40 | ftp_pasv($this->_conn, true); |
41 | 41 | } |
42 | 42 | |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | /** @scrutinizer ignore-unhandled */@ftp_chmod($this->_conn, $mode, $subFile); |
195 | 195 | } |
196 | 196 | } |
197 | - return (bool) /** @scrutinizer ignore-unhandled */@ftp_chmod($this->_conn, $mode, $file); |
|
197 | + return (bool)/** @scrutinizer ignore-unhandled */@ftp_chmod($this->_conn, $mode, $file); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | */ |
240 | 240 | protected function _mkdir($dir, $mode = 0777) |
241 | 241 | { |
242 | - $isCreated = (bool) @ftp_mkdir($this->_conn, $dir); |
|
242 | + $isCreated = (bool)@ftp_mkdir($this->_conn, $dir); |
|
243 | 243 | $this->chmod($dir, $mode, FileConstants::RECURSIVE_DISABLED); |
244 | 244 | return $isCreated; |
245 | 245 | } |