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
|
|
|
if (property_exists('Kint', $key)) { |
31
|
|
|
Kint::$$key = $val; |
32
|
|
|
} |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
unset($GLOBALS['_kint_settings'], $key, $val); |
36
|
|
|
} |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public static function initFunctions() |
40
|
|
|
{ |
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
|
|
|
/** |
53
|
|
|
* Alias of Kint::dump() |
54
|
|
|
* [!!!] IMPORTANT: execution will halt after call to this function |
55
|
|
|
* |
56
|
|
|
* @return string |
57
|
|
|
*/ |
58
|
|
View Code Duplication |
function dd() |
|
|
|
|
59
|
|
|
{ |
60
|
|
|
if (!Kint::enabled()) { |
61
|
|
|
return ''; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
call_user_func_array(array('kint\Kint', 'dump'), func_get_args()); |
65
|
|
|
exit(); |
|
|
|
|
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Alias of Kint::dump() |
70
|
|
|
* [!!!] IMPORTANT: execution will halt after call to this function |
71
|
|
|
* |
72
|
|
|
* @return string |
73
|
|
|
*/ |
74
|
|
View Code Duplication |
function ddd() |
|
|
|
|
75
|
|
|
{ |
76
|
|
|
if (!Kint::enabled()) { |
77
|
|
|
return ''; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
call_user_func_array(array('kint\Kint', 'dump'), func_get_args()); |
81
|
|
|
exit(); |
|
|
|
|
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Alias of Kint::dump(), however the output is delayed until the end of the script |
86
|
|
|
* |
87
|
|
|
* @see d(); |
88
|
|
|
* |
89
|
|
|
* @return string |
90
|
|
|
*/ |
91
|
|
|
function de() |
|
|
|
|
92
|
|
|
{ |
93
|
|
|
$stash = Kint::settings(); |
94
|
|
|
Kint::$delayedMode = true; |
95
|
|
|
$out = call_user_func_array(array('kint\Kint', 'dump'), func_get_args()); |
96
|
|
|
Kint::settings($stash); |
97
|
|
|
|
98
|
|
|
return $out; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Alias of Kint::dump(), however the output is in plain html-escaped text and some minor visibility enhancements |
103
|
|
|
* added. If run in CLI mode, output is pure whitespace. |
104
|
|
|
* |
105
|
|
|
* To force rendering mode without auto-detecting anything: |
106
|
|
|
* |
107
|
|
|
* Kint::enabled( Kint::MODE_PLAIN ); |
108
|
|
|
* Kint::dump( $variable ); |
109
|
|
|
* |
110
|
|
|
* [!!!] IMPORTANT: execution will halt after call to this function |
111
|
|
|
* |
112
|
|
|
* @return string |
113
|
|
|
*/ |
114
|
|
|
function s() |
|
|
|
|
115
|
|
|
{ |
116
|
|
|
if (!Kint::enabled()) { |
117
|
|
|
return ''; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
$stash = Kint::settings(); |
121
|
|
|
|
122
|
|
|
if (Kint::enabled() !== Kint::MODE_WHITESPACE) { |
123
|
|
|
Kint::enabled(Kint::MODE_PLAIN); |
124
|
|
|
if (PHP_SAPI === 'cli' && Kint::$cliDetection === true) { |
125
|
|
|
Kint::enabled(Kint::MODE_CLI); |
126
|
|
|
} |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
$out = call_user_func_array(array('kint\Kint', 'dump'), func_get_args()); |
130
|
|
|
|
131
|
|
|
Kint::settings($stash); |
132
|
|
|
|
133
|
|
|
return $out; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @see s() |
138
|
|
|
* |
139
|
|
|
* [!!!] IMPORTANT: execution will halt after call to this function |
140
|
|
|
* |
141
|
|
|
* @return string |
142
|
|
|
*/ |
143
|
|
|
function sd() |
|
|
|
|
144
|
|
|
{ |
145
|
|
|
if (!Kint::enabled()) { |
146
|
|
|
return ''; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
if (Kint::enabled() !== Kint::MODE_WHITESPACE) { |
150
|
|
|
Kint::enabled(Kint::MODE_PLAIN); |
151
|
|
|
if (PHP_SAPI === 'cli' && Kint::$cliDetection === true) { |
152
|
|
|
Kint::enabled(Kint::MODE_CLI); |
153
|
|
|
} |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
call_user_func_array(array('kint\Kint', 'dump'), func_get_args()); |
157
|
|
|
exit(); |
|
|
|
|
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* @see s() |
162
|
|
|
* @see de() |
163
|
|
|
* |
164
|
|
|
* @return string |
165
|
|
|
*/ |
166
|
|
|
function se() |
|
|
|
|
167
|
|
|
{ |
168
|
|
|
if (!Kint::enabled()) { |
169
|
|
|
return ''; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
$stash = Kint::settings(); |
173
|
|
|
|
174
|
|
|
Kint::$delayedMode = true; |
175
|
|
|
|
176
|
|
|
if (Kint::enabled() !== Kint::MODE_WHITESPACE) { |
177
|
|
|
Kint::enabled(Kint::MODE_PLAIN); |
178
|
|
|
if (PHP_SAPI === 'cli' && Kint::$cliDetection === true) { |
179
|
|
|
Kint::enabled(Kint::MODE_CLI); |
180
|
|
|
} |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
$out = call_user_func_array(array('kint\Kint', 'dump'), func_get_args()); |
184
|
|
|
|
185
|
|
|
Kint::settings($stash); |
186
|
|
|
|
187
|
|
|
return $out; |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* Alias of Kint::dump(), however the output is dumped to the javascript console and |
192
|
|
|
* added to the global array `kintDump`. If run in CLI mode, output is pure whitespace. |
193
|
|
|
* |
194
|
|
|
* To force rendering mode without autodetecting anything: |
195
|
|
|
* |
196
|
|
|
* Kint::enabled( Kint::MODE_JS ); |
197
|
|
|
* Kint::dump( $variable ); |
198
|
|
|
* |
199
|
|
|
* @return string |
200
|
|
|
*/ |
201
|
|
|
function j() |
|
|
|
|
202
|
|
|
{ |
203
|
|
|
if (!Kint::enabled()) { |
204
|
|
|
return ''; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
$stash = Kint::settings(); |
208
|
|
|
|
209
|
|
|
Kint::enabled( |
210
|
|
|
PHP_SAPI === 'cli' && Kint::$cliDetection === true ? Kint::MODE_CLI : Kint::MODE_JS |
211
|
|
|
); |
212
|
|
|
|
213
|
|
|
$out = call_user_func_array(array('kint\Kint', 'dump'), func_get_args()); |
214
|
|
|
|
215
|
|
|
Kint::settings($stash); |
216
|
|
|
|
217
|
|
|
return $out; |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
/** |
221
|
|
|
* @see j() |
222
|
|
|
* |
223
|
|
|
* [!!!] IMPORTANT: execution will halt after call to this function |
224
|
|
|
* |
225
|
|
|
* @return string |
226
|
|
|
*/ |
227
|
|
|
function jd() |
|
|
|
|
228
|
|
|
{ |
229
|
|
|
if (!Kint::enabled()) { |
230
|
|
|
return ''; |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
Kint::enabled( |
234
|
|
|
PHP_SAPI === 'cli' && Kint::$cliDetection === true ? Kint::MODE_CLI : Kint::MODE_JS |
235
|
|
|
); |
236
|
|
|
|
237
|
|
|
call_user_func_array(array('kint\Kint', 'dump'), func_get_args()); |
238
|
|
|
|
239
|
|
|
exit(); |
|
|
|
|
240
|
|
|
} |
241
|
|
|
|
242
|
|
|
/** |
243
|
|
|
* @see j() |
244
|
|
|
* @see de() |
245
|
|
|
* |
246
|
|
|
* @return string |
247
|
|
|
*/ |
248
|
|
|
function je() |
|
|
|
|
249
|
|
|
{ |
250
|
|
|
if (!Kint::enabled()) { |
251
|
|
|
return ''; |
252
|
|
|
} |
253
|
|
|
|
254
|
|
|
$stash = Kint::settings(); |
255
|
|
|
|
256
|
|
|
Kint::$delayedMode = true; |
257
|
|
|
|
258
|
|
|
Kint::enabled( |
259
|
|
|
PHP_SAPI === 'cli' && Kint::$cliDetection === true ? Kint::MODE_CLI : Kint::MODE_JS |
260
|
|
|
); |
261
|
|
|
|
262
|
|
|
$out = call_user_func_array(array('kint\Kint', 'dump'), func_get_args()); |
263
|
|
|
|
264
|
|
|
Kint::settings($stash); |
265
|
|
|
|
266
|
|
|
return $out; |
267
|
|
|
} |
268
|
|
|
} |
269
|
|
|
|
270
|
|
|
} |
271
|
|
|
|
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: