-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
51 lines (41 loc) · 1001 Bytes
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
use Hi\Kernel;
function kernel(): Kernel
{
return Kernel::instance();
}
function config(string $key, $defaultValue = null)
{
return kernel()->getConfig()->get($key, $defaultValue);
}
function basePath(string $subPath = '')
{
return pathJoin(kernel()->getBasePath(), $subPath);
}
function storagePath(string $subPath = '')
{
return pathJoin(kernel()->getStoragePath(), $subPath);
}
function pathJoin(string $basePath, string $subPath = '')
{
if ($subPath) {
return $basePath . DIRECTORY_SEPARATOR . trim($subPath, DIRECTORY_SEPARATOR);
}
return $basePath;
}
function app(string $id)
{
return kernel()->getContainer()->get($id);
}
if (!function_exists('backtracePoint')) {
/**
* 返回指定调用回溯位置信息
*
* @param int $depth 栈深度
*/
function backtracePoint(int $depth = 2): array
{
$traces = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $depth);
return array_pop($traces);
}
}