1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace kint; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class KintBootup |
7
|
|
|
* |
8
|
|
|
* @package kint |
9
|
|
|
*/ |
10
|
|
|
class KintBootup |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* init |
14
|
|
|
*/ |
15
|
|
|
public static function init() |
|
|
|
|
16
|
|
|
{ |
17
|
|
|
if (defined('KINT_DIR')) { |
18
|
|
|
return; |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
define('KINT_DIR', __DIR__ . '/'); |
22
|
|
|
|
23
|
|
|
require KINT_DIR . 'config.default.php'; |
24
|
|
|
|
25
|
|
|
# init settings |
26
|
|
|
if (!empty($GLOBALS['_kint_settings'])) { |
27
|
|
|
Kint::enabled($GLOBALS['_kint_settings']['enabled']); |
28
|
|
|
|
29
|
|
|
foreach ($GLOBALS['_kint_settings'] as $key => $val) { |
30
|
|
|
/** @noinspection PhpVariableVariableInspection */ |
31
|
|
|
property_exists('Kint', $key) and Kint::$$key = $val; |
|
|
|
|
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
unset($GLOBALS['_kint_settings'], $key, $val); |
35
|
|
|
} |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function initFunctions() |
39
|
|
|
{ |
40
|
|
|
if (!function_exists('d')) { |
41
|
|
|
/** |
42
|
|
|
* Alias of Kint::dump() |
43
|
|
|
* |
44
|
|
|
* @return string |
45
|
|
|
*/ |
46
|
|
|
function d() |
47
|
|
|
{ |
48
|
|
|
return call_user_func_array(array('kint\Kint', 'dump'), func_get_args()); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|
52
|
|
View Code Duplication |
if (!function_exists('dd')) { |
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Alias of Kint::dump() |
55
|
|
|
* [!!!] IMPORTANT: execution will halt after call to this function |
56
|
|
|
* |
57
|
|
|
* @return string |
58
|
|
|
* @deprecated |
59
|
|
|
*/ |
60
|
|
|
function dd() |
|
|
|
|
61
|
|
|
{ |
62
|
|
|
if (!Kint::enabled()) { |
63
|
|
|
return ''; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
echo "<pre>Kint: dd() is being deprecated, please use ddd() instead</pre>\n"; |
67
|
|
|
call_user_func_array(array('kint\Kint', 'dump'), func_get_args()); |
68
|
|
|
exit(); |
|
|
|
|
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
72
|
|
View Code Duplication |
if (!function_exists('ddd')) { |
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Alias of Kint::dump() |
75
|
|
|
* [!!!] IMPORTANT: execution will halt after call to this function |
76
|
|
|
* |
77
|
|
|
* @return string |
78
|
|
|
*/ |
79
|
|
|
function ddd() |
|
|
|
|
80
|
|
|
{ |
81
|
|
|
if (!Kint::enabled()) { |
82
|
|
|
return ''; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
call_user_func_array(array('kint\Kint', 'dump'), func_get_args()); |
86
|
|
|
exit(); |
|
|
|
|
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
if (!function_exists('de')) { |
91
|
|
|
/** |
92
|
|
|
* Alias of Kint::dump(), however the output is delayed until the end of the script |
93
|
|
|
* |
94
|
|
|
* @see d(); |
95
|
|
|
* |
96
|
|
|
* @return string |
97
|
|
|
*/ |
98
|
|
|
function de() |
|
|
|
|
99
|
|
|
{ |
100
|
|
|
$stash = Kint::settings(); |
101
|
|
|
Kint::$delayedMode = true; |
102
|
|
|
$out = call_user_func_array(array('kint\Kint', 'dump'), func_get_args()); |
103
|
|
|
Kint::settings($stash); |
104
|
|
|
|
105
|
|
|
return $out; |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|
109
|
|
View Code Duplication |
if (!function_exists('s')) { |
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* Alias of Kint::dump(), however the output is in plain html-escaped text and some minor visibility enhancements |
112
|
|
|
* added. If run in CLI mode, output is pure whitespace. |
113
|
|
|
* |
114
|
|
|
* To force rendering mode without auto-detecting anything: |
115
|
|
|
* |
116
|
|
|
* Kint::enabled( Kint::MODE_PLAIN ); |
117
|
|
|
* Kint::dump( $variable ); |
118
|
|
|
* |
119
|
|
|
* [!!!] IMPORTANT: execution will halt after call to this function |
120
|
|
|
* |
121
|
|
|
* @return string |
122
|
|
|
*/ |
123
|
|
|
function s() |
|
|
|
|
124
|
|
|
{ |
125
|
|
|
if (!Kint::enabled()) { |
126
|
|
|
return ''; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
$stash = Kint::settings(); |
130
|
|
|
|
131
|
|
|
if (Kint::enabled() !== Kint::MODE_WHITESPACE) { |
132
|
|
|
Kint::enabled(Kint::MODE_PLAIN); |
133
|
|
|
if (PHP_SAPI === 'cli' && Kint::$cliDetection === true) { |
134
|
|
|
Kint::enabled(Kint::MODE_CLI); |
135
|
|
|
} |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
$out = call_user_func_array(array('kint\Kint', 'dump'), func_get_args()); |
139
|
|
|
|
140
|
|
|
Kint::settings($stash); |
141
|
|
|
|
142
|
|
|
return $out; |
143
|
|
|
} |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
if (!function_exists('sd')) { |
147
|
|
|
/** |
148
|
|
|
* @see s() |
149
|
|
|
* |
150
|
|
|
* [!!!] IMPORTANT: execution will halt after call to this function |
151
|
|
|
* |
152
|
|
|
* @return string |
153
|
|
|
*/ |
154
|
|
|
function sd() |
|
|
|
|
155
|
|
|
{ |
156
|
|
|
if (!Kint::enabled()) { |
157
|
|
|
return ''; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
if (Kint::enabled() !== Kint::MODE_WHITESPACE) { |
161
|
|
|
Kint::enabled(Kint::MODE_PLAIN); |
162
|
|
|
if (PHP_SAPI === 'cli' && Kint::$cliDetection === true) { |
163
|
|
|
Kint::enabled(Kint::MODE_CLI); |
164
|
|
|
} |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
call_user_func_array(array('kint\Kint', 'dump'), func_get_args()); |
168
|
|
|
exit(); |
|
|
|
|
169
|
|
|
} |
170
|
|
|
} |
171
|
|
|
|
172
|
|
View Code Duplication |
if (!function_exists('se')) { |
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* @see s() |
175
|
|
|
* @see de() |
176
|
|
|
* |
177
|
|
|
* @return string |
178
|
|
|
*/ |
179
|
|
|
function se() |
|
|
|
|
180
|
|
|
{ |
181
|
|
|
if (!Kint::enabled()) { |
182
|
|
|
return ''; |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
$stash = Kint::settings(); |
186
|
|
|
|
187
|
|
|
Kint::$delayedMode = true; |
188
|
|
|
|
189
|
|
|
if (Kint::enabled() !== Kint::MODE_WHITESPACE) { |
190
|
|
|
Kint::enabled(Kint::MODE_PLAIN); |
191
|
|
|
if (PHP_SAPI === 'cli' && Kint::$cliDetection === true) { |
192
|
|
|
Kint::enabled(Kint::MODE_CLI); |
193
|
|
|
} |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
$out = call_user_func_array(array('kint\Kint', 'dump'), func_get_args()); |
197
|
|
|
|
198
|
|
|
Kint::settings($stash); |
199
|
|
|
|
200
|
|
|
return $out; |
201
|
|
|
} |
202
|
|
|
} |
203
|
|
|
|
204
|
|
View Code Duplication |
if (!function_exists('j')) { |
|
|
|
|
205
|
|
|
/** |
206
|
|
|
* Alias of Kint::dump(), however the output is dumped to the javascript console and |
207
|
|
|
* added to the global array `kintDump`. If run in CLI mode, output is pure whitespace. |
208
|
|
|
* |
209
|
|
|
* To force rendering mode without autodetecting anything: |
210
|
|
|
* |
211
|
|
|
* Kint::enabled( Kint::MODE_JS ); |
212
|
|
|
* Kint::dump( $variable ); |
213
|
|
|
* |
214
|
|
|
* @return string |
215
|
|
|
*/ |
216
|
|
|
function j() |
|
|
|
|
217
|
|
|
{ |
218
|
|
|
if (!Kint::enabled()) { |
219
|
|
|
return ''; |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
$stash = Kint::settings(); |
223
|
|
|
|
224
|
|
|
Kint::enabled( |
225
|
|
|
PHP_SAPI === 'cli' && Kint::$cliDetection === true ? Kint::MODE_CLI : Kint::MODE_JS |
226
|
|
|
); |
227
|
|
|
|
228
|
|
|
$out = call_user_func_array(array('kint\Kint', 'dump'), func_get_args()); |
229
|
|
|
|
230
|
|
|
Kint::settings($stash); |
231
|
|
|
|
232
|
|
|
return $out; |
233
|
|
|
} |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
if (!function_exists('jd')) { |
237
|
|
|
/** |
238
|
|
|
* @see j() |
239
|
|
|
* |
240
|
|
|
* [!!!] IMPORTANT: execution will halt after call to this function |
241
|
|
|
* |
242
|
|
|
* @return string |
243
|
|
|
*/ |
244
|
|
|
function jd() |
|
|
|
|
245
|
|
|
{ |
246
|
|
|
if (!Kint::enabled()) { |
247
|
|
|
return ''; |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
Kint::enabled( |
251
|
|
|
PHP_SAPI === 'cli' && Kint::$cliDetection === true ? Kint::MODE_CLI : Kint::MODE_JS |
252
|
|
|
); |
253
|
|
|
|
254
|
|
|
call_user_func_array(array('kint\Kint', 'dump'), func_get_args()); |
255
|
|
|
|
256
|
|
|
exit(); |
|
|
|
|
257
|
|
|
} |
258
|
|
|
} |
259
|
|
|
|
260
|
|
View Code Duplication |
if (!function_exists('je')) { |
|
|
|
|
261
|
|
|
/** |
262
|
|
|
* @see j() |
263
|
|
|
* @see de() |
264
|
|
|
* |
265
|
|
|
* @return string |
266
|
|
|
*/ |
267
|
|
|
function je() |
|
|
|
|
268
|
|
|
{ |
269
|
|
|
if (!Kint::enabled()) { |
270
|
|
|
return ''; |
271
|
|
|
} |
272
|
|
|
|
273
|
|
|
$stash = Kint::settings(); |
274
|
|
|
|
275
|
|
|
Kint::$delayedMode = true; |
276
|
|
|
|
277
|
|
|
Kint::enabled( |
278
|
|
|
PHP_SAPI === 'cli' && Kint::$cliDetection === true ? Kint::MODE_CLI : Kint::MODE_JS |
279
|
|
|
); |
280
|
|
|
|
281
|
|
|
$out = call_user_func_array(array('kint\Kint', 'dump'), func_get_args()); |
282
|
|
|
|
283
|
|
|
Kint::settings($stash); |
284
|
|
|
|
285
|
|
|
return $out; |
286
|
|
|
} |
287
|
|
|
} |
288
|
|
|
} |
289
|
|
|
} |
290
|
|
|
|
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: