1 | <?php |
||
19 | final class Definition |
||
20 | { |
||
21 | /** |
||
22 | * The human readable activity name |
||
23 | * @var array |
||
24 | */ |
||
25 | private $name; |
||
26 | |||
27 | /** |
||
28 | * The human readable activity description |
||
29 | * @var array |
||
30 | */ |
||
31 | private $description; |
||
32 | |||
33 | /** |
||
34 | * The type of the {@link Activity} |
||
35 | * @var string |
||
36 | */ |
||
37 | private $type; |
||
38 | |||
39 | /** |
||
40 | * An IRL where human-readable information describing the {@link Activity} can be found. |
||
41 | * |
||
42 | * @var string|null |
||
43 | */ |
||
44 | private $moreInfo; |
||
45 | |||
46 | /** |
||
47 | * @param array|null $name |
||
48 | * @param array|null $description |
||
49 | * @param string|null $type |
||
50 | * @param string|null $moreInfo |
||
51 | */ |
||
52 | public function __construct(array $name = null, array $description = null, $type = null, $moreInfo = null) |
||
59 | |||
60 | /** |
||
61 | * Returns the human readable names. |
||
62 | * |
||
63 | * @return array The name language map |
||
64 | */ |
||
65 | public function getName() |
||
69 | |||
70 | /** |
||
71 | * Returns the human readable descriptions. |
||
72 | * |
||
73 | * @return array The description language map |
||
74 | */ |
||
75 | public function getDescription() |
||
79 | |||
80 | /** |
||
81 | * Returns the {@link Activity} type. |
||
82 | * |
||
83 | * @return string The type |
||
84 | */ |
||
85 | public function getType() |
||
89 | |||
90 | /** |
||
91 | * Returns an IRL where human-readable information about the activity can be found. |
||
92 | * |
||
93 | * @return string|null |
||
94 | */ |
||
95 | public function getMoreInfo() |
||
99 | |||
100 | /** |
||
101 | * Checks if another definition is equal. |
||
102 | * |
||
103 | * Two definitions are equal if and only if all of their properties are equal. |
||
104 | * |
||
105 | * @param Definition $definition The definition to compare with |
||
106 | * |
||
107 | * @return bool True if the definitions are equal, false otherwise |
||
108 | */ |
||
109 | public function equals(Definition $definition) |
||
149 | } |
||
150 |
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
.