1 | <?php |
||
17 | class FileMetadata |
||
18 | { |
||
19 | /** |
||
20 | * @var string |
||
21 | */ |
||
22 | private $filename; |
||
23 | |||
24 | /** |
||
25 | * @var array |
||
26 | */ |
||
27 | private $uses; |
||
28 | |||
29 | /** |
||
30 | * @var ClassMetadata[] |
||
31 | */ |
||
32 | private $classes; |
||
33 | |||
34 | /** |
||
35 | * @var TraitMetadata[] |
||
36 | */ |
||
37 | private $traits; |
||
38 | |||
39 | /** |
||
40 | * @var array |
||
41 | */ |
||
42 | private $ast; |
||
43 | |||
44 | /** |
||
45 | * FileMetadata constructor. |
||
46 | * |
||
47 | * @param string $filename |
||
48 | * @param array $classes |
||
49 | * @param array $traits |
||
50 | * @param array $ast |
||
51 | */ |
||
52 | public function __construct($filename, array $uses = [], array $classes = [], array $traits = [], array $ast = null) |
||
60 | |||
61 | /** |
||
62 | * @return string |
||
63 | */ |
||
64 | public function getFilename() |
||
68 | |||
69 | /** |
||
70 | * @return array |
||
71 | */ |
||
72 | public function getUses() |
||
76 | |||
77 | /** |
||
78 | * @return ClassMetadata[] |
||
79 | */ |
||
80 | public function getClasses() |
||
84 | |||
85 | /** |
||
86 | * @return TraitMetadata[] |
||
87 | */ |
||
88 | public function getTraits() |
||
92 | |||
93 | /** |
||
94 | * @return array |
||
95 | */ |
||
96 | public function getAst() |
||
100 | } |
||
101 |
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
.