1 | <?php |
||
8 | final class Event |
||
9 | { |
||
10 | /** |
||
11 | * @var string |
||
12 | */ |
||
13 | private $type; |
||
14 | |||
15 | /** |
||
16 | * @var integer |
||
17 | */ |
||
18 | private $version; |
||
19 | |||
20 | /** |
||
21 | * @var array |
||
22 | */ |
||
23 | private $data; |
||
24 | |||
25 | /** |
||
26 | * @var array |
||
27 | */ |
||
28 | private $metadata; |
||
29 | |||
30 | /** |
||
31 | * @param string $type |
||
32 | * @param integer $version |
||
33 | * @param array $data |
||
34 | * @param array $metadata |
||
35 | */ |
||
36 | 9 | public function __construct($type, $version, array $data, array $metadata = null) |
|
43 | |||
44 | /** |
||
45 | * @return string |
||
46 | */ |
||
47 | public function getType() |
||
51 | |||
52 | /** |
||
53 | * @return integer |
||
54 | */ |
||
55 | 3 | public function getVersion() |
|
59 | |||
60 | /** |
||
61 | * @return array |
||
62 | */ |
||
63 | 3 | public function getData() |
|
67 | |||
68 | /** |
||
69 | * @return array |
||
70 | */ |
||
71 | 3 | public function getMetadata() |
|
75 | } |
||
76 |
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
.