1 | <?php |
||
12 | class Error implements ErrorInterface |
||
13 | { |
||
14 | /** |
||
15 | * @var string |
||
16 | */ |
||
17 | private $message; |
||
18 | |||
19 | /** |
||
20 | * @var int |
||
21 | */ |
||
22 | private $line; |
||
23 | |||
24 | /** |
||
25 | * @var string |
||
26 | */ |
||
27 | private $file; |
||
28 | |||
29 | /** |
||
30 | * @var array |
||
31 | */ |
||
32 | private $trace; |
||
33 | |||
34 | /** |
||
35 | * @var array |
||
36 | */ |
||
37 | private $parameters = array(); |
||
38 | |||
39 | /** |
||
40 | * Create a new error wrapping the given error context info. |
||
41 | * |
||
42 | * @param string $message |
||
43 | * @param int $line |
||
44 | * @param string $file |
||
45 | * @param array|null $trace |
||
46 | * @param array|null $parameters |
||
47 | */ |
||
48 | 11 | public function __construct($message, $line, $file, array $trace = null, array $parameters = null) |
|
56 | |||
57 | /** |
||
58 | * @param string $file |
||
59 | */ |
||
60 | 11 | private function setFile($file) |
|
64 | |||
65 | /** |
||
66 | * @return string |
||
67 | */ |
||
68 | 10 | public function getFile() |
|
72 | |||
73 | /** |
||
74 | * @param int $line |
||
75 | */ |
||
76 | 11 | private function setLine($line) |
|
80 | |||
81 | /** |
||
82 | * @return int |
||
83 | */ |
||
84 | 10 | public function getLine() |
|
88 | |||
89 | /** |
||
90 | * @param string $message |
||
91 | */ |
||
92 | 11 | private function setMessage($message) |
|
96 | |||
97 | /** |
||
98 | * @return string |
||
99 | */ |
||
100 | 1 | public function getMessage() |
|
104 | |||
105 | /** |
||
106 | * @param array|null $parameters |
||
107 | */ |
||
108 | 11 | private function setParameters(array $parameters = null) |
|
120 | |||
121 | /** |
||
122 | * This will add fallback data to the parameters if the key is not set |
||
123 | * |
||
124 | * @param string $name |
||
125 | * @param mixed $fallbackData |
||
126 | */ |
||
127 | 11 | private function addParameterFallback($name, $fallbackData = null) |
|
133 | |||
134 | /** |
||
135 | * @return array |
||
136 | */ |
||
137 | 5 | public function getParameters() |
|
141 | |||
142 | /** |
||
143 | * @param array|null $trace |
||
144 | */ |
||
145 | 11 | private function setTrace(array $trace = null) |
|
158 | |||
159 | /** |
||
160 | * @return array |
||
161 | */ |
||
162 | 2 | public function getTrace() |
|
166 | } |
||
167 |
Our type inference engine has found an assignment of a scalar value (like a string, an integer or null) to a property which is an array.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.
To type hint that a parameter can be either an array or null, you can set a type hint of array and a default value of null. The PHP interpreter will then accept both an array or null for that parameter.
The function can be called with either null or an array for the parameter
$needle
but will only accept an array as$haystack
.