-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.dev.php
More file actions
146 lines (120 loc) · 3.58 KB
/
bootstrap.dev.php
File metadata and controls
146 lines (120 loc) · 3.58 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?php
declare(strict_types=1);
\error_reporting(\E_ALL);
\define('DIR_ROOT', __DIR__);
if (!\defined('TEST_DIR_FILES')) {
\define('TEST_DIR_FILES', __DIR__ . '/tests/files');
}
require_once __DIR__ . '/vendor/autoload.php';
use Inilim\Dump\Dump;
use Inilim\IPDO\IPDOSQLite;
Dump::init();
if (!\function_exists('__include')) {
/**
* @param string|string[] $names example "Other::getClassContextFromClosure"
* @return void
* TODO add ...$name
*/
function __include($names)
{
if (\is_string($names)) {
$names = [$names];
}
if (!$names) {
return;
}
foreach ($names as $name) {
[$class, $func] = \preg_split('#(::)|(\\\\)#', $name);
$pathToFile = \sprintf(
'%s/src/Method/%s/%s.php',
__DIR__,
$class,
$func,
);
if (!\is_file($pathToFile)) {
$body = \sprintf(
'
%s
Arg: "%s"
Файл не найден: "%s"
%s
',
\str_repeat('-', 30),
$name,
$pathToFile,
\str_repeat('-', 30),
);
$body = \explode(PHP_EOL, $body);
$body = \array_map('trim', $body);
$body = \implode(PHP_EOL, $body);
throw new \Exception($body);
}
require_once $pathToFile;
}
}
}
if (!\function_exists('__includeDeep')) {
/**
* @param string|string[] $names example "Other::getClassContextFromClosure"
* @return void
* TODO add ...$name
*/
function __includeDeep($names)
{
if (\is_string($names)) {
$names = [$names];
}
if (!$names) {
return;
}
$connect = new IPDOSQLite(__DIR__ . '/files/build_dev.sqlite');
$connect->connect();
foreach ($names as $name) {
[$class, $func] = \preg_split('#(::)|(\\\\)#', $name);
$id = $connect->exec('SELECT id FROM methods WHERE namespace LIKE "%" || {class} AND name = {func}', [
'class' => $class,
'func' => $func,
], 1)['id'] ?? null;
if ($id === null) {
\de([
__LINE__,
'$class' => $class,
'$func' => $func,
]);
}
/** @var int $id */
$files = $connect->exec(
'SELECT m.path_to_file FROM groups as g
JOIN methods as m
ON m.id = g.method_id
WHERE g.id = {id}',
['id' => $id],
2
);
$files = \array_column($files, 'path_to_file');
foreach ($files as $file) {
require_once $file;
}
}
}
}
if (!\function_exists('infoStringFunction')) {
function infoStringFunction(string $name)
{
$refl = new \ReflectionFunction($name);
$result = [
'str' => $refl->__toString(),
'args' => [],
];
foreach ($refl->getParameters() as $param) {
$result['args'][] = [
'name' => $param->getName(),
'pos' => $param->getPosition(),
// 'default' => $param->getDefaultValue(),
'str' => $param->__toString(),
'type' => $param->getType() ? $param->getType()->getName() : 'mixed',
];
}
return $result;
}
}