Skip to content

Commit

Permalink
助手函数增加命名空间
Browse files Browse the repository at this point in the history
  • Loading branch information
yunwuxin committed Nov 18, 2021
1 parent e29d83a commit 8276c61
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions src/helpers.php
@@ -1,27 +1,30 @@
<?php

use think\swoole\response\File;
namespace {

if (!function_exists('swoole_cpu_num')) {
function swoole_cpu_num(): int
{
return 1;
if (!function_exists('swoole_cpu_num')) {
function swoole_cpu_num(): int
{
return 1;
}
}
}

if (!defined('SWOOLE_SOCK_TCP')) {
define('SWOOLE_SOCK_TCP', 1);
}
if (!defined('SWOOLE_SOCK_TCP')) {
define('SWOOLE_SOCK_TCP', 1);
}

if (!defined('SWOOLE_PROCESS')) {
define('SWOOLE_PROCESS', 3);
}
if (!defined('SWOOLE_PROCESS')) {
define('SWOOLE_PROCESS', 3);
}

if (!defined('SWOOLE_HOOK_ALL')) {
define('SWOOLE_HOOK_ALL', 1879048191);
if (!defined('SWOOLE_HOOK_ALL')) {
define('SWOOLE_HOOK_ALL', 1879048191);
}
}

if (!function_exists('download')) {
namespace think\swoole\helper {

use think\swoole\response\File;

function download(string $filename, string $name = '', $disposition = File::DISPOSITION_ATTACHMENT): File
{
Expand All @@ -33,9 +36,7 @@ function download(string $filename, string $name = '', $disposition = File::DISP

return $response;
}
}

if (!function_exists('file')) {
function file(string $filename)
{
return new File($filename);
Expand Down

0 comments on commit 8276c61

Please sign in to comment.