1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Whoops - php errors for cool kids |
4
|
|
|
* @author Filipe Dobreira <http://github.com/filp> |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace Whoops\Handler; |
8
|
|
|
|
9
|
|
|
use Whoops\Exception\Inspector; |
10
|
|
|
use Whoops\RunInterface; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Abstract implementation of a Handler. |
14
|
|
|
*/ |
15
|
|
|
abstract class Handler implements HandlerInterface |
16
|
|
|
{ |
17
|
|
|
/* |
18
|
|
|
Return constants that can be returned from Handler::handle |
19
|
|
|
to message the handler walker. |
20
|
|
|
*/ |
21
|
|
|
const DONE = 0x10; // returning this is optional, only exists for |
22
|
|
|
// semantic purposes |
23
|
|
|
/** |
24
|
|
|
* The Handler has handled the Throwable in some way, and wishes to skip any other Handler. |
25
|
|
|
* Execution will continue. |
26
|
|
|
*/ |
27
|
|
|
const LAST_HANDLER = 0x20; |
28
|
|
|
/** |
29
|
|
|
* The Handler has handled the Throwable in some way, and wishes to quit/stop execution |
30
|
|
|
*/ |
31
|
|
|
const QUIT = 0x30; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var RunInterface |
35
|
|
|
*/ |
36
|
|
|
private $run; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var Inspector $inspector |
40
|
|
|
*/ |
41
|
|
|
private $inspector; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @var \Throwable $exception |
45
|
|
|
*/ |
46
|
|
|
private $exception; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @param RunInterface $run |
50
|
|
|
*/ |
51
|
3 |
|
public function setRun(RunInterface $run) |
52
|
|
|
{ |
53
|
3 |
|
$this->run = $run; |
54
|
3 |
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @return RunInterface |
58
|
|
|
*/ |
59
|
1 |
|
protected function getRun() |
60
|
|
|
{ |
61
|
1 |
|
return $this->run; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @param Inspector $inspector |
66
|
|
|
*/ |
67
|
3 |
|
public function setInspector(Inspector $inspector) |
68
|
|
|
{ |
69
|
3 |
|
$this->inspector = $inspector; |
70
|
3 |
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return Inspector |
74
|
|
|
*/ |
75
|
2 |
|
protected function getInspector() |
76
|
|
|
{ |
77
|
2 |
|
return $this->inspector; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @param \Throwable $exception |
82
|
|
|
*/ |
83
|
3 |
|
public function setException($exception) |
84
|
|
|
{ |
85
|
3 |
|
$this->exception = $exception; |
86
|
3 |
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @return \Throwable |
90
|
|
|
*/ |
91
|
3 |
|
protected function getException() |
92
|
|
|
{ |
93
|
3 |
|
return $this->exception; |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|