1 | <?php |
||
7 | class GenericBadNews implements BadNewsInterface |
||
8 | { |
||
9 | /** |
||
10 | * The message describing this bad news. |
||
11 | * @var StringAtom |
||
12 | */ |
||
13 | protected $message; |
||
14 | |||
15 | /** |
||
16 | * The optional reasons associated with this bad news. |
||
17 | * @var array |
||
18 | */ |
||
19 | protected $reasons; |
||
20 | |||
21 | /** |
||
22 | * Create a new generic bad news container given the message and optional |
||
23 | * reasons associated with it. |
||
24 | * |
||
25 | * @param StringAtom $message |
||
26 | * @param array $reasons |
||
27 | */ |
||
28 | public function __construct(StringAtom $message, array $reasons = null) |
||
33 | |||
34 | /** |
||
35 | * @see BadNewsInterface |
||
36 | */ |
||
37 | public function getMessage() |
||
41 | |||
42 | /** |
||
43 | * @see BadNewsInterface |
||
44 | */ |
||
45 | public function hasReasons() |
||
49 | |||
50 | /** |
||
51 | * @see BadNewsInterface |
||
52 | */ |
||
53 | public function getReasons() |
||
57 | } |
||
58 |
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
.