1 | <?php |
||
8 | class BadFunctionDefinitionException extends \ReflectionException implements \ArrayAccess |
||
9 | { |
||
10 | /** |
||
11 | * Global tokens to replace in error messages. |
||
12 | * |
||
13 | * @var string[] |
||
14 | */ |
||
15 | private $tokens = []; |
||
16 | /** |
||
17 | * A list of error messages. |
||
18 | * |
||
19 | * @var string[] |
||
20 | */ |
||
21 | private $errors = []; |
||
22 | |||
23 | /** |
||
24 | * BadFunctionDefinitionException constructor. |
||
25 | * |
||
26 | * @param \ReflectionFunctionAbstract $function |
||
27 | * A function/method to collect violations for. |
||
28 | * |
||
29 | * @throws self |
||
30 | * When argument is not of "ReflectionMethod" or "ReflectionFunction" type. |
||
31 | */ |
||
32 | 20 | public function __construct(\ReflectionFunctionAbstract $function) |
|
52 | |||
53 | /** |
||
54 | * {@inheritdoc} |
||
55 | */ |
||
56 | 2 | public function offsetExists($token) |
|
60 | |||
61 | /** |
||
62 | * {@inheritdoc} |
||
63 | */ |
||
64 | 2 | public function offsetGet($token) |
|
68 | |||
69 | /** |
||
70 | * {@inheritdoc} |
||
71 | */ |
||
72 | 15 | public function offsetSet($token, $value) |
|
76 | |||
77 | /** |
||
78 | * {@inheritdoc} |
||
79 | */ |
||
80 | 2 | public function offsetUnset($token) |
|
84 | |||
85 | /** |
||
86 | * Adds an error message to the list. |
||
87 | * |
||
88 | * @param string $message |
||
89 | * A message to add. |
||
90 | * @param string[] $tokens |
||
91 | * An array of additional tokens to replace in a message. |
||
92 | */ |
||
93 | 17 | public function addError(string $message, array $tokens = []) |
|
97 | |||
98 | /** |
||
99 | * Returns a list of error messages. |
||
100 | * |
||
101 | * @return string[] |
||
102 | * A list of error messages. |
||
103 | */ |
||
104 | 19 | public function getErrors(): array |
|
108 | |||
109 | /** |
||
110 | * Throws an instance of self in a case when errors list is not empty. |
||
111 | * |
||
112 | * @throws self |
||
113 | */ |
||
114 | 19 | public function throwIfErrorsExist() |
|
123 | } |
||
124 |