1 | <?php |
||
17 | class CodeWarning extends Exception |
||
18 | { |
||
19 | /** |
||
20 | * Is this topic fixable? |
||
21 | * |
||
22 | * @var bool |
||
23 | */ |
||
24 | private $isFixable = false; |
||
25 | |||
26 | /** |
||
27 | * The payload for displaying the error message. |
||
28 | * |
||
29 | * @var array |
||
30 | */ |
||
31 | private $payload = []; |
||
32 | |||
33 | /** |
||
34 | * The position of the error. |
||
35 | * |
||
36 | * @var int |
||
37 | */ |
||
38 | private $stackPosition; |
||
39 | |||
40 | /** |
||
41 | * The erroneous token. |
||
42 | * |
||
43 | * @var array|void |
||
44 | */ |
||
45 | private $token; |
||
46 | |||
47 | /** |
||
48 | * CodeWarning constructor. |
||
49 | * |
||
50 | * @param string $code The code for the sniffer. |
||
51 | * @param string $message The message for the sniffer. |
||
52 | * @param int $stackPosition Where is the token in the stack? |
||
53 | */ |
||
54 | public function __construct(string $code, string $message, int $stackPosition) |
||
63 | |||
64 | /** |
||
65 | * Returns the payload for displaying the error message. |
||
66 | * |
||
67 | * @return array The possible payload for the error message. |
||
68 | */ |
||
69 | public function getPayload(): array |
||
73 | |||
74 | /** |
||
75 | * Returns the position of the error. |
||
76 | * |
||
77 | * @return int Where is the token in the stack? |
||
78 | */ |
||
79 | public function getStackPosition(): int |
||
83 | |||
84 | /** |
||
85 | * Returns the erroneous token. |
||
86 | * |
||
87 | * @return array The "broken" token. |
||
88 | */ |
||
89 | public function getToken(): array |
||
93 | |||
94 | /** |
||
95 | * Is this topic fixable? |
||
96 | * |
||
97 | * @param bool|null $newStatus If given the new status. |
||
98 | * |
||
99 | * @return bool Returns the "old" status if this is fixable. |
||
100 | */ |
||
101 | public function isFixable(?bool $newStatus = null): bool |
||
111 | |||
112 | /** |
||
113 | * Sets the payload for displaying the error message. |
||
114 | * |
||
115 | * @param array $payload The possible payload for the error message. |
||
116 | * |
||
117 | * @return $this Fluent-Interface. |
||
118 | */ |
||
119 | public function setPayload(array $payload): self |
||
125 | |||
126 | /** |
||
127 | * Sets the erroneous token. |
||
128 | * |
||
129 | * @param array $token The "broken" token. |
||
130 | * |
||
131 | * @return $this Fluent Interface. |
||
132 | */ |
||
133 | public function setToken(array $token): self |
||
139 | } |
||
140 |