1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Webino (http://webino.sk/) |
4
|
|
|
* |
5
|
|
|
* @link https://github.com/webino/WebinoDebug/ for the canonical source repository |
6
|
|
|
* @copyright Copyright (c) 2014-2018 Webino, s. r. o. (http://webino.sk/) |
7
|
|
|
* @license BSD-3-Clause |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace WebinoDebug\Options; |
11
|
|
|
|
12
|
|
|
use WebinoDebug\Debugger\Bar; |
13
|
|
|
use Zend\Stdlib\AbstractOptions; |
14
|
|
|
use Zend\Stdlib\ArrayUtils; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Class DebuggerOptions |
18
|
|
|
*/ |
19
|
|
|
class DebuggerOptions extends AbstractOptions |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var bool |
23
|
|
|
*/ |
24
|
|
|
protected $enabled = true; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var bool|null |
28
|
|
|
*/ |
29
|
|
|
protected $mode = null; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var bool |
33
|
|
|
*/ |
34
|
|
|
protected $bar = false; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var array |
38
|
|
|
*/ |
39
|
|
|
protected $barInfo = []; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var array |
43
|
|
|
*/ |
44
|
|
|
protected $barPanels = [ |
45
|
|
|
'WebinoDebug:timer' => Bar\TimerPanel::class, |
46
|
|
|
'WebinoDebug:info' => Bar\InfoPanel::class, |
47
|
|
|
'WebinoDebug:config' => Bar\ConfigPanel::class, |
48
|
|
|
'WebinoDebug:events' => Bar\EventPanel::class, |
49
|
|
|
]; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var array |
53
|
|
|
*/ |
54
|
|
|
protected $cssFiles = [__DIR__ . '/../../../data/assets/Bar/style.css']; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @var array |
58
|
|
|
*/ |
59
|
|
|
protected $jsFiles = [__DIR__ . '/../../../data/assets/Bar/script.js']; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @var bool |
63
|
|
|
*/ |
64
|
|
|
protected $strict = false; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @var string|null |
68
|
|
|
*/ |
69
|
|
|
protected $log; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @var string |
73
|
|
|
*/ |
74
|
|
|
protected $email = ''; |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @var int |
78
|
|
|
*/ |
79
|
|
|
protected $maxDepth = 10; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @var int |
83
|
|
|
*/ |
84
|
|
|
protected $maxLength = 300; |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @var bool |
88
|
|
|
*/ |
89
|
|
|
protected $barNoLogo = false; |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @var bool |
93
|
|
|
*/ |
94
|
|
|
protected $barNoClose = false; |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Is debugger enabled? |
98
|
|
|
* |
99
|
|
|
* @return bool |
100
|
|
|
*/ |
101
|
|
|
public function isEnabled() |
102
|
|
|
{ |
103
|
|
|
return $this->enabled; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Enable debugger |
108
|
|
|
* |
109
|
|
|
* @param bool $enabled |
110
|
|
|
* @return $this |
111
|
|
|
*/ |
112
|
|
|
public function setEnabled($enabled) |
113
|
|
|
{ |
114
|
|
|
$this->enabled = (bool) $enabled; |
115
|
|
|
return $this; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Is debugger disabled? |
120
|
|
|
* |
121
|
|
|
* @return bool |
122
|
|
|
*/ |
123
|
|
|
public function isDisabled() |
124
|
|
|
{ |
125
|
|
|
return !$this->enabled; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* Debugger mode |
130
|
|
|
* |
131
|
|
|
* true = production|false |
132
|
|
|
* false = development|null |
133
|
|
|
* null = autodetect|IP address(es) csv/array |
134
|
|
|
* |
135
|
|
|
* @return bool|null |
136
|
|
|
*/ |
137
|
|
|
public function getMode() |
138
|
|
|
{ |
139
|
|
|
return $this->mode; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* Debugger mode, production or development. |
144
|
|
|
* |
145
|
|
|
* @param bool|null $mode |
146
|
|
|
* @return $this |
147
|
|
|
*/ |
148
|
|
|
public function setMode($mode) |
149
|
|
|
{ |
150
|
|
|
$this->mode = (null === $mode ? null : (bool) $mode); |
151
|
|
|
return $this; |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* Is debugger bar enabled? |
156
|
|
|
* |
157
|
|
|
* @return bool |
158
|
|
|
*/ |
159
|
|
|
public function showBar() |
160
|
|
|
{ |
161
|
|
|
return $this->bar; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* Toggle debugger bar |
166
|
|
|
* |
167
|
|
|
* @param bool $bar |
168
|
|
|
* @return $this |
169
|
|
|
*/ |
170
|
|
|
public function setBar($bar) |
171
|
|
|
{ |
172
|
|
|
$this->bar = (bool) $bar; |
173
|
|
|
return $this; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* Debugger bar panels |
178
|
|
|
* |
179
|
|
|
* @return array |
180
|
|
|
*/ |
181
|
|
|
public function getBarPanels() |
182
|
|
|
{ |
183
|
|
|
return $this->barPanels; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* Set custom debugger bar panels |
188
|
|
|
* |
189
|
|
|
* @param array $barPanels |
190
|
|
|
* @return $this |
191
|
|
|
*/ |
192
|
|
|
public function setBarPanels(array $barPanels) |
193
|
|
|
{ |
194
|
|
|
$this->barPanels = ArrayUtils::merge($this->barPanels, $barPanels); |
195
|
|
|
return $this; |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
/** |
199
|
|
|
* @return array |
200
|
|
|
*/ |
201
|
|
|
public function getCssFiles() |
202
|
|
|
{ |
203
|
|
|
return $this->cssFiles; |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
/** |
207
|
|
|
* Set custom CSS files |
208
|
|
|
* |
209
|
|
|
* @param array $cssFiles |
210
|
|
|
* @return $this |
211
|
|
|
*/ |
212
|
|
|
public function setCssFiles($cssFiles) |
213
|
|
|
{ |
214
|
|
|
$this->cssFiles = ArrayUtils::merge($this->cssFiles, $cssFiles); |
215
|
|
|
return $this; |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
/** |
219
|
|
|
* @return array |
220
|
|
|
*/ |
221
|
|
|
public function getJsFiles() |
222
|
|
|
{ |
223
|
|
|
return $this->jsFiles; |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
/** |
227
|
|
|
* Set custom Javascript files |
228
|
|
|
* |
229
|
|
|
* @param array $jsFiles |
230
|
|
|
* @return $this |
231
|
|
|
*/ |
232
|
|
|
public function setJsFiles($jsFiles) |
233
|
|
|
{ |
234
|
|
|
$this->jsFiles = ArrayUtils::merge($this->jsFiles, $jsFiles); |
235
|
|
|
return $this; |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
/** |
239
|
|
|
* Return custom debugger bar info |
240
|
|
|
* |
241
|
|
|
* @return array |
242
|
|
|
*/ |
243
|
|
|
public function getBarInfo() |
244
|
|
|
{ |
245
|
|
|
return $this->barInfo; |
246
|
|
|
} |
247
|
|
|
|
248
|
|
|
/** |
249
|
|
|
* Set custom debugger bar info |
250
|
|
|
* |
251
|
|
|
* @param array $barInfo |
252
|
|
|
* @return $this |
253
|
|
|
*/ |
254
|
|
|
public function setBarInfo(array $barInfo) |
255
|
|
|
{ |
256
|
|
|
$this->barInfo = ArrayUtils::merge($this->barInfo, $barInfo); |
257
|
|
|
return $this; |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
/** |
261
|
|
|
* @return bool |
262
|
|
|
*/ |
263
|
|
|
public function isStrict() |
264
|
|
|
{ |
265
|
|
|
return $this->strict; |
266
|
|
|
} |
267
|
|
|
|
268
|
|
|
/** |
269
|
|
|
* Strict errors? |
270
|
|
|
* |
271
|
|
|
* @param bool $strict |
272
|
|
|
* @return $this |
273
|
|
|
*/ |
274
|
|
|
public function setStrict($strict) |
275
|
|
|
{ |
276
|
|
|
$this->strict = (bool) $strict; |
277
|
|
|
return $this; |
278
|
|
|
} |
279
|
|
|
|
280
|
|
|
/** |
281
|
|
|
* @return string Empty string to disable, null for default |
282
|
|
|
*/ |
283
|
|
|
public function getLog() |
284
|
|
|
{ |
285
|
|
|
if (null === $this->log) { |
286
|
|
|
$this->setLog('data/log'); |
287
|
|
|
} |
288
|
|
|
return $this->log; |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
/** |
292
|
|
|
* Path to log directory |
293
|
|
|
* |
294
|
|
|
* @param string $log |
295
|
|
|
* @return $this |
296
|
|
|
*/ |
297
|
|
|
public function setLog($log) |
298
|
|
|
{ |
299
|
|
|
$this->log = realpath($log); |
300
|
|
|
return $this; |
301
|
|
|
} |
302
|
|
|
|
303
|
|
|
/** |
304
|
|
|
* Administrator address |
305
|
|
|
* |
306
|
|
|
* @return string |
307
|
|
|
*/ |
308
|
|
|
public function getEmail() |
309
|
|
|
{ |
310
|
|
|
return $this->email; |
311
|
|
|
} |
312
|
|
|
|
313
|
|
|
/** |
314
|
|
|
* Configure debugger administrator email |
315
|
|
|
* |
316
|
|
|
* @param string $email |
317
|
|
|
* @return $this |
318
|
|
|
*/ |
319
|
|
|
public function setEmail($email) |
320
|
|
|
{ |
321
|
|
|
$this->email = (string) $email; |
322
|
|
|
return $this; |
323
|
|
|
} |
324
|
|
|
|
325
|
|
|
/** |
326
|
|
|
* @return int |
327
|
|
|
*/ |
328
|
|
|
public function getMaxDepth() |
329
|
|
|
{ |
330
|
|
|
return $this->maxDepth; |
331
|
|
|
} |
332
|
|
|
|
333
|
|
|
/** |
334
|
|
|
* Variable dump max depth |
335
|
|
|
* |
336
|
|
|
* @param int $maxDepth |
337
|
|
|
* @return $this |
338
|
|
|
*/ |
339
|
|
|
public function setMaxDepth($maxDepth) |
340
|
|
|
{ |
341
|
|
|
$this->maxDepth = (int) $maxDepth; |
342
|
|
|
return $this; |
343
|
|
|
} |
344
|
|
|
|
345
|
|
|
/** |
346
|
|
|
* @return int |
347
|
|
|
*/ |
348
|
|
|
public function getMaxLength() |
349
|
|
|
{ |
350
|
|
|
return $this->maxLength; |
351
|
|
|
} |
352
|
|
|
|
353
|
|
|
/** |
354
|
|
|
* Maximum length of a variable |
355
|
|
|
* |
356
|
|
|
* @param int $maxLength |
357
|
|
|
* @return $this |
358
|
|
|
*/ |
359
|
|
|
public function setMaxLength($maxLength) |
360
|
|
|
{ |
361
|
|
|
$this->maxLength = (int) $maxLength; |
362
|
|
|
return $this; |
363
|
|
|
} |
364
|
|
|
|
365
|
|
|
/** |
366
|
|
|
* Has debugger bar a disabled logo? |
367
|
|
|
* |
368
|
|
|
* @return bool |
369
|
|
|
*/ |
370
|
|
|
public function hasBarNoLogo() |
371
|
|
|
{ |
372
|
|
|
return $this->barNoLogo; |
373
|
|
|
} |
374
|
|
|
|
375
|
|
|
/** |
376
|
|
|
* Set debugger bar logo disabled |
377
|
|
|
* |
378
|
|
|
* @param bool $noLogo |
|
|
|
|
379
|
|
|
* @return $this |
380
|
|
|
*/ |
381
|
|
|
public function setBarNoLogo($barNoLogo = true) |
382
|
|
|
{ |
383
|
|
|
$this->barNoLogo = (bool) $barNoLogo; |
384
|
|
|
return $this; |
385
|
|
|
} |
386
|
|
|
|
387
|
|
|
/** |
388
|
|
|
* Has debugger bar close button disabled? |
389
|
|
|
* |
390
|
|
|
* @return bool |
391
|
|
|
*/ |
392
|
|
|
public function hasBarNoClose() |
393
|
|
|
{ |
394
|
|
|
return $this->barNoClose; |
395
|
|
|
} |
396
|
|
|
|
397
|
|
|
/** |
398
|
|
|
* Disable debugger bar close button |
399
|
|
|
* |
400
|
|
|
* @param bool $barNoClose |
401
|
|
|
* @return $this |
402
|
|
|
*/ |
403
|
|
|
public function setBarNoClose($barNoClose = true) |
404
|
|
|
{ |
405
|
|
|
$this->barNoClose = (bool) $barNoClose; |
406
|
|
|
return $this; |
407
|
|
|
} |
408
|
|
|
} |
409
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$ireland
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was changed, but the annotation was not.