1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Recca0120\LaravelTracy; |
4
|
|
|
|
5
|
|
|
use Tracy\Bar; |
6
|
|
|
use Tracy\Debugger; |
7
|
|
|
|
8
|
|
|
class Tracy |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* $bar. |
12
|
|
|
* |
13
|
|
|
* @var \Tracy\Bar |
14
|
|
|
*/ |
15
|
|
|
protected $bar; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* __construct. |
19
|
|
|
* |
20
|
|
|
* @param array $config |
21
|
|
|
* @param BarManager $barManager |
22
|
|
|
* @param \Tracy\Bar $bar |
23
|
|
|
*/ |
24
|
1 |
|
public function __construct($config = [], BarManager $barManager = null, Bar $bar = null) |
25
|
|
|
{ |
26
|
1 |
|
$config = array_merge([ |
27
|
1 |
|
'directory' => null, |
28
|
|
|
'email' => null, |
29
|
|
|
'emailSnooze' => null, |
30
|
|
|
'enabled' => true, |
31
|
|
|
'showBar' => true, |
32
|
|
|
'editor' => 'subl://open?url=file://%file&line=%line', |
33
|
|
|
'maxDepth' => 4, |
34
|
|
|
'maxLength' => 1000, |
35
|
|
|
'scream' => true, |
36
|
|
|
'showLocation' => true, |
37
|
|
|
'strictMode' => true, |
38
|
|
|
'panels' => [ |
39
|
|
|
'routing' => false, |
40
|
|
|
'database' => true, |
41
|
|
|
'view' => false, |
42
|
|
|
'event' => false, |
43
|
|
|
'session' => true, |
44
|
|
|
'request' => true, |
45
|
|
|
'auth' => true, |
46
|
|
|
'terminal' => false, |
47
|
|
|
], |
48
|
|
|
], $config); |
49
|
|
|
|
50
|
1 |
|
$mode = $config['enabled'] === true ? Debugger::DEVELOPMENT : Debugger::PRODUCTION; |
51
|
1 |
|
$config = DebuggerManager::init($config); |
52
|
1 |
|
Debugger::enable($mode, $config['directory'], $config['email']); |
53
|
1 |
|
if (is_null($config['emailSnooze']) === false) { |
54
|
1 |
|
Debugger::getLogger()->emailSnooze = $config['emailSnooze']; |
|
|
|
|
55
|
|
|
} |
56
|
|
|
|
57
|
1 |
|
$bar = $bar ?: Debugger::getBar(); |
58
|
1 |
|
$barManager = $barManager ?: new BarManager($bar); |
59
|
|
|
|
60
|
1 |
|
$this->bar = $barManager->loadPanels($config['panels'])->getBar(); |
61
|
1 |
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* __call. |
65
|
|
|
* |
66
|
|
|
* @param string $method |
67
|
|
|
* @param array $parameters |
68
|
|
|
* @return mix |
69
|
|
|
*/ |
70
|
1 |
|
public function __call($method, $parameters) |
71
|
|
|
{ |
72
|
1 |
|
if (method_exists($this->bar, $method) === true) { |
73
|
1 |
|
return call_user_func_array([$this->bar, $method], $parameters); |
74
|
|
|
} |
75
|
|
|
|
76
|
1 |
|
return call_user_func_array(['\Tracy\Debugger', $method], $parameters); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* instance. |
81
|
|
|
* |
82
|
|
|
* @param array$config |
83
|
|
|
* @return static |
84
|
|
|
*/ |
85
|
1 |
|
public static function instance($config = [], BarManager $barManager = null, Bar $bar = null) |
86
|
|
|
{ |
87
|
1 |
|
static $instance; |
88
|
|
|
|
89
|
1 |
|
if (is_null($instance) === false) { |
90
|
1 |
|
return $instance; |
91
|
|
|
} |
92
|
|
|
|
93
|
1 |
|
return $instance = new static($config, $barManager, $bar); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: