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 string |
38
|
|
|
*/ |
39
|
|
|
protected $barTitle; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var array |
43
|
|
|
*/ |
44
|
|
|
protected $barInfo = []; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var array |
48
|
|
|
*/ |
49
|
|
|
protected $barPanels = [ |
50
|
|
|
'WebinoDebug:timer' => Bar\TimerPanel::class, |
51
|
|
|
'WebinoDebug:info' => Bar\InfoPanel::class, |
52
|
|
|
'WebinoDebug:config' => Bar\ConfigPanel::class, |
53
|
|
|
'WebinoDebug:events' => Bar\EventPanel::class, |
54
|
|
|
]; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @var array |
58
|
|
|
*/ |
59
|
|
|
protected $cssFiles = [__DIR__ . '/../../../data/assets/Bar/style.css']; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @var array |
63
|
|
|
*/ |
64
|
|
|
protected $jsFiles = [__DIR__ . '/../../../data/assets/Bar/script.js']; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @var bool |
68
|
|
|
*/ |
69
|
|
|
protected $strict = false; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @var string|null |
73
|
|
|
*/ |
74
|
|
|
protected $log; |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @var string |
78
|
|
|
*/ |
79
|
|
|
protected $email = ''; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @var int |
83
|
|
|
*/ |
84
|
|
|
protected $maxDepth = 10; |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @var int |
88
|
|
|
*/ |
89
|
|
|
protected $maxLength = 300; |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @var bool |
93
|
|
|
*/ |
94
|
|
|
protected $barNoLogo = false; |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @var bool |
98
|
|
|
*/ |
99
|
|
|
protected $barNoClose = false; |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Is debugger enabled? |
103
|
|
|
* |
104
|
|
|
* @return bool |
105
|
|
|
*/ |
106
|
|
|
public function isEnabled() : bool |
107
|
|
|
{ |
108
|
|
|
return $this->enabled; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Enable debugger |
113
|
|
|
* |
114
|
|
|
* @param bool $enabled |
115
|
|
|
* @return $this |
116
|
|
|
*/ |
117
|
|
|
public function setEnabled($enabled = true) |
118
|
|
|
{ |
119
|
|
|
$this->enabled = (bool) $enabled; |
120
|
|
|
return $this; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* Is debugger disabled? |
125
|
|
|
* |
126
|
|
|
* @return bool |
127
|
|
|
*/ |
128
|
|
|
public function isDisabled() : bool |
129
|
|
|
{ |
130
|
|
|
return !$this->enabled; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* Debugger mode |
135
|
|
|
* |
136
|
|
|
* true = production|false |
137
|
|
|
* false = development|null |
138
|
|
|
* null = autodetect|IP address(es) csv/array |
139
|
|
|
* |
140
|
|
|
* @return bool|null |
141
|
|
|
*/ |
142
|
|
|
public function getMode() : ?bool |
143
|
|
|
{ |
144
|
|
|
return $this->mode; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* Debugger mode, production or development. |
149
|
|
|
* |
150
|
|
|
* @param bool|null $mode |
151
|
|
|
* @return $this |
152
|
|
|
*/ |
153
|
|
|
public function setMode($mode) |
154
|
|
|
{ |
155
|
|
|
$this->mode = (null === $mode ? null : (bool) $mode); |
156
|
|
|
return $this; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* Is debugger bar enabled? |
161
|
|
|
* |
162
|
|
|
* @return bool |
163
|
|
|
*/ |
164
|
|
|
public function showBar() : bool |
165
|
|
|
{ |
166
|
|
|
return $this->bar; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* Toggle debugger bar |
171
|
|
|
* |
172
|
|
|
* @param bool $bar |
173
|
|
|
* @return $this |
174
|
|
|
*/ |
175
|
|
|
public function setBar($bar) |
176
|
|
|
{ |
177
|
|
|
$this->bar = (bool) $bar; |
178
|
|
|
return $this; |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* Debugger bar panels |
183
|
|
|
* |
184
|
|
|
* @return array |
185
|
|
|
*/ |
186
|
|
|
public function getBarPanels() : array |
187
|
|
|
{ |
188
|
|
|
return $this->barPanels; |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* Set custom debugger bar panels |
193
|
|
|
* |
194
|
|
|
* @param array $barPanels |
195
|
|
|
* @return $this |
196
|
|
|
*/ |
197
|
|
|
public function setBarPanels(array $barPanels) |
198
|
|
|
{ |
199
|
|
|
$this->barPanels = ArrayUtils::merge($this->barPanels, $barPanels); |
200
|
|
|
return $this; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* @return array |
205
|
|
|
*/ |
206
|
|
|
public function getCssFiles() : array |
207
|
|
|
{ |
208
|
|
|
return $this->cssFiles; |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* Set custom CSS files |
213
|
|
|
* |
214
|
|
|
* @param array $cssFiles |
215
|
|
|
* @return $this |
216
|
|
|
*/ |
217
|
|
|
public function setCssFiles(array $cssFiles) |
218
|
|
|
{ |
219
|
|
|
$this->cssFiles = ArrayUtils::merge($this->cssFiles, $cssFiles); |
220
|
|
|
return $this; |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* @return array |
225
|
|
|
*/ |
226
|
|
|
public function getJsFiles() : array |
227
|
|
|
{ |
228
|
|
|
return $this->jsFiles; |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
/** |
232
|
|
|
* Set custom Javascript files |
233
|
|
|
* |
234
|
|
|
* @param array $jsFiles |
235
|
|
|
* @return $this |
236
|
|
|
*/ |
237
|
|
|
public function setJsFiles(array $jsFiles) |
238
|
|
|
{ |
239
|
|
|
$this->jsFiles = ArrayUtils::merge($this->jsFiles, $jsFiles); |
240
|
|
|
return $this; |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
/** |
244
|
|
|
* Return custom debugger bar info |
245
|
|
|
* |
246
|
|
|
* @return array |
247
|
|
|
*/ |
248
|
|
|
public function getBarInfo() : array |
249
|
|
|
{ |
250
|
|
|
return $this->barInfo; |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
/** |
254
|
|
|
* Set custom debugger bar info |
255
|
|
|
* |
256
|
|
|
* @param array $barInfo |
257
|
|
|
* @return $this |
258
|
|
|
*/ |
259
|
|
|
public function setBarInfo(array $barInfo) |
260
|
|
|
{ |
261
|
|
|
$this->barInfo = ArrayUtils::merge($this->barInfo, $barInfo); |
262
|
|
|
return $this; |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
/** |
266
|
|
|
* @return bool |
267
|
|
|
*/ |
268
|
|
|
public function isStrict() : bool |
269
|
|
|
{ |
270
|
|
|
return $this->strict; |
271
|
|
|
} |
272
|
|
|
|
273
|
|
|
/** |
274
|
|
|
* Strict errors? |
275
|
|
|
* |
276
|
|
|
* @param bool $strict |
277
|
|
|
* @return $this |
278
|
|
|
*/ |
279
|
|
|
public function setStrict($strict) |
280
|
|
|
{ |
281
|
|
|
$this->strict = (bool) $strict; |
282
|
|
|
return $this; |
283
|
|
|
} |
284
|
|
|
|
285
|
|
|
/** |
286
|
|
|
* @return string Empty string to disable, null for default |
287
|
|
|
*/ |
288
|
|
|
public function getLog() : string |
289
|
|
|
{ |
290
|
|
|
if (null === $this->log) { |
291
|
|
|
$this->setLog('data/log'); |
292
|
|
|
} |
293
|
|
|
return $this->log; |
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
/** |
297
|
|
|
* Path to log directory |
298
|
|
|
* |
299
|
|
|
* @param string $log |
300
|
|
|
* @return $this |
301
|
|
|
*/ |
302
|
|
|
public function setLog($log) |
303
|
|
|
{ |
304
|
|
|
$this->log = realpath($log); |
305
|
|
|
return $this; |
306
|
|
|
} |
307
|
|
|
|
308
|
|
|
/** |
309
|
|
|
* Administrator address |
310
|
|
|
* |
311
|
|
|
* @return string |
312
|
|
|
*/ |
313
|
|
|
public function getEmail() : string |
314
|
|
|
{ |
315
|
|
|
return $this->email; |
316
|
|
|
} |
317
|
|
|
|
318
|
|
|
/** |
319
|
|
|
* Configure debugger administrator email |
320
|
|
|
* |
321
|
|
|
* @param string $email |
322
|
|
|
* @return $this |
323
|
|
|
*/ |
324
|
|
|
public function setEmail($email) |
325
|
|
|
{ |
326
|
|
|
$this->email = (string) $email; |
327
|
|
|
return $this; |
328
|
|
|
} |
329
|
|
|
|
330
|
|
|
/** |
331
|
|
|
* @return int |
332
|
|
|
*/ |
333
|
|
|
public function getMaxDepth() : int |
334
|
|
|
{ |
335
|
|
|
return $this->maxDepth; |
336
|
|
|
} |
337
|
|
|
|
338
|
|
|
/** |
339
|
|
|
* Variable dump max depth |
340
|
|
|
* |
341
|
|
|
* @param int $maxDepth |
342
|
|
|
* @return $this |
343
|
|
|
*/ |
344
|
|
|
public function setMaxDepth($maxDepth) |
345
|
|
|
{ |
346
|
|
|
$this->maxDepth = (int) $maxDepth; |
347
|
|
|
return $this; |
348
|
|
|
} |
349
|
|
|
|
350
|
|
|
/** |
351
|
|
|
* @return int |
352
|
|
|
*/ |
353
|
|
|
public function getMaxLength() : int |
354
|
|
|
{ |
355
|
|
|
return $this->maxLength; |
356
|
|
|
} |
357
|
|
|
|
358
|
|
|
/** |
359
|
|
|
* Maximum length of a variable |
360
|
|
|
* |
361
|
|
|
* @param int $maxLength |
362
|
|
|
* @return $this |
363
|
|
|
*/ |
364
|
|
|
public function setMaxLength($maxLength) |
365
|
|
|
{ |
366
|
|
|
$this->maxLength = (int) $maxLength; |
367
|
|
|
return $this; |
368
|
|
|
} |
369
|
|
|
|
370
|
|
|
/** |
371
|
|
|
* Return debugger bar title |
372
|
|
|
* |
373
|
|
|
* @return string |
374
|
|
|
*/ |
375
|
|
|
public function getBarTitle() : string |
376
|
|
|
{ |
377
|
|
|
return $this->barTitle; |
378
|
|
|
} |
379
|
|
|
|
380
|
|
|
/** |
381
|
|
|
* Set debugger bar custom title |
382
|
|
|
* |
383
|
|
|
* @param string $barTitle |
384
|
|
|
* @return $this |
385
|
|
|
*/ |
386
|
|
|
public function setBarTitle(string $barTitle) |
387
|
|
|
{ |
388
|
|
|
$this->barTitle = $barTitle; |
389
|
|
|
return $this; |
390
|
|
|
} |
391
|
|
|
|
392
|
|
|
/** |
393
|
|
|
* Has debugger bar a disabled logo? |
394
|
|
|
* |
395
|
|
|
* @return bool |
396
|
|
|
*/ |
397
|
|
|
public function hasBarNoLogo() : bool |
398
|
|
|
{ |
399
|
|
|
return $this->barNoLogo; |
400
|
|
|
} |
401
|
|
|
|
402
|
|
|
/** |
403
|
|
|
* Set debugger bar logo disabled |
404
|
|
|
* |
405
|
|
|
* @param bool $noLogo |
|
|
|
|
406
|
|
|
* @return $this |
407
|
|
|
*/ |
408
|
|
|
public function setBarNoLogo($barNoLogo = true) |
409
|
|
|
{ |
410
|
|
|
$this->barNoLogo = (bool) $barNoLogo; |
411
|
|
|
return $this; |
412
|
|
|
} |
413
|
|
|
|
414
|
|
|
/** |
415
|
|
|
* Has debugger bar close button disabled? |
416
|
|
|
* |
417
|
|
|
* @return bool |
418
|
|
|
*/ |
419
|
|
|
public function hasBarNoClose() : bool |
420
|
|
|
{ |
421
|
|
|
return $this->barNoClose; |
422
|
|
|
} |
423
|
|
|
|
424
|
|
|
/** |
425
|
|
|
* Disable debugger bar close button |
426
|
|
|
* |
427
|
|
|
* @param bool $barNoClose |
428
|
|
|
* @return $this |
429
|
|
|
*/ |
430
|
|
|
public function setBarNoClose($barNoClose = true) |
431
|
|
|
{ |
432
|
|
|
$this->barNoClose = (bool) $barNoClose; |
433
|
|
|
return $this; |
434
|
|
|
} |
435
|
|
|
} |
436
|
|
|
|
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.