1 | <?php |
||
10 | final class Event |
||
11 | { |
||
12 | /** |
||
13 | * @var string |
||
14 | */ |
||
15 | private $type; |
||
16 | |||
17 | /** |
||
18 | * @var integer |
||
19 | */ |
||
20 | private $version; |
||
21 | |||
22 | /** |
||
23 | * @var array |
||
24 | */ |
||
25 | private $data; |
||
26 | |||
27 | /** |
||
28 | * @var array |
||
29 | */ |
||
30 | private $metadata; |
||
31 | |||
32 | /** |
||
33 | * @var UUID |
||
34 | */ |
||
35 | private $eventId; |
||
36 | |||
37 | /** |
||
38 | * @param string $type |
||
39 | * @param integer $version |
||
40 | * @param array $data |
||
41 | * @param array $metadata |
||
42 | * @param UUID $eventId |
||
43 | */ |
||
44 | 11 | public function __construct($type, $version, array $data, array $metadata = null, UUID $eventId = null) |
|
52 | |||
53 | /** |
||
54 | * @return string |
||
55 | */ |
||
56 | public function getType() |
||
60 | |||
61 | /** |
||
62 | * @return integer |
||
63 | */ |
||
64 | 3 | public function getVersion() |
|
68 | |||
69 | /** |
||
70 | * @return array |
||
71 | */ |
||
72 | 3 | public function getData() |
|
76 | |||
77 | /** |
||
78 | * @return array |
||
79 | */ |
||
80 | 3 | public function getMetadata() |
|
84 | |||
85 | /** |
||
86 | * @return UUID |
||
87 | */ |
||
88 | 1 | public function getEventId() |
|
92 | } |
||
93 |
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
.