mirror of https://gitee.com/karson/fastadmin.git
Pre Merge pull request !478 from 端木/develop
commit
3a7be52867
|
|
@ -15,7 +15,7 @@ class Http
|
|||
* @param array $options 扩展参数
|
||||
* @return mixed|string
|
||||
*/
|
||||
public static function post($url, $params = [], $options = [])
|
||||
public static function post(string $url, array $params = [], array $options = [])
|
||||
{
|
||||
$req = self::sendRequest($url, $params, 'POST', $options);
|
||||
return $req['ret'] ? $req['msg'] : '';
|
||||
|
|
@ -28,7 +28,7 @@ class Http
|
|||
* @param array $options 扩展参数
|
||||
* @return mixed|string
|
||||
*/
|
||||
public static function get($url, $params = [], $options = [])
|
||||
public static function get(string $url, array $params = [], array $options = [])
|
||||
{
|
||||
$req = self::sendRequest($url, $params, 'GET', $options);
|
||||
return $req['ret'] ? $req['msg'] : '';
|
||||
|
|
@ -42,7 +42,7 @@ class Http
|
|||
* @param mixed $options CURL的参数
|
||||
* @return array
|
||||
*/
|
||||
public static function sendRequest($url, $params = [], $method = 'POST', $options = [])
|
||||
public static function sendRequest(string $url, $params = [], string $method = 'POST', $options = []): array
|
||||
{
|
||||
$method = strtoupper($method);
|
||||
$protocol = substr($url, 0, 5);
|
||||
|
|
@ -108,7 +108,7 @@ class Http
|
|||
* @param string $method 请求的方法
|
||||
* @return boolean TRUE
|
||||
*/
|
||||
public static function sendAsyncRequest($url, $params = [], $method = 'POST')
|
||||
public static function sendAsyncRequest(string $url, $params = [], string $method = 'POST'): bool
|
||||
{
|
||||
$method = strtoupper($method);
|
||||
$method = $method == 'POST' ? 'POST' : 'GET';
|
||||
|
|
@ -157,10 +157,10 @@ class Http
|
|||
/**
|
||||
* 发送文件到客户端
|
||||
* @param string $file
|
||||
* @param bool $delaftersend
|
||||
* @param bool $exitaftersend
|
||||
* @param bool $deleteAfterSend
|
||||
* @param bool $exitAfterSend
|
||||
*/
|
||||
public static function sendToBrowser($file, $delaftersend = true, $exitaftersend = true)
|
||||
public static function sendToBrowser(string $file, bool $deleteAfterSend = true, bool $exitAfterSend = true)
|
||||
{
|
||||
if (file_exists($file) && is_readable($file)) {
|
||||
header('Content-Description: File Transfer');
|
||||
|
|
@ -174,10 +174,10 @@ class Http
|
|||
ob_clean();
|
||||
flush();
|
||||
readfile($file);
|
||||
if ($delaftersend) {
|
||||
if ($deleteAfterSend) {
|
||||
unlink($file);
|
||||
}
|
||||
if ($exitaftersend) {
|
||||
if ($exitAfterSend) {
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class Random
|
|||
* @param int $len 长度
|
||||
* @return string
|
||||
*/
|
||||
public static function alnum($len = 6)
|
||||
public static function alnum(int $len = 6): string
|
||||
{
|
||||
return self::build('alnum', $len);
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@ class Random
|
|||
* @param int $len 长度
|
||||
* @return string
|
||||
*/
|
||||
public static function alpha($len = 6)
|
||||
public static function alpha(int $len = 6): string
|
||||
{
|
||||
return self::build('alpha', $len);
|
||||
}
|
||||
|
|
@ -36,7 +36,7 @@ class Random
|
|||
* @param int $len 长度
|
||||
* @return string
|
||||
*/
|
||||
public static function numeric($len = 4)
|
||||
public static function numeric(int $len = 4): string
|
||||
{
|
||||
return self::build('numeric', $len);
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@ class Random
|
|||
* @param int $len 长度
|
||||
* @return string
|
||||
*/
|
||||
public static function nozero($len = 4)
|
||||
public static function nozero(int $len = 4): string
|
||||
{
|
||||
return self::build('nozero', $len);
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ class Random
|
|||
* @param int $len 长度
|
||||
* @return string
|
||||
*/
|
||||
public static function build($type = 'alnum', $len = 8)
|
||||
public static function build(string $type = 'alnum', int $len = 8): string
|
||||
{
|
||||
switch ($type) {
|
||||
case 'alpha':
|
||||
|
|
@ -93,7 +93,7 @@ class Random
|
|||
* 获取全球唯一标识
|
||||
* @return string
|
||||
*/
|
||||
public static function uuid()
|
||||
public static function uuid(): string
|
||||
{
|
||||
return sprintf(
|
||||
'%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
|
||||
|
|
|
|||
Loading…
Reference in New Issue