1 | <?php |
||
8 | class ToolsFilter { |
||
9 | |||
10 | /** |
||
11 | * @var null|string[] |
||
12 | */ |
||
13 | private $include = null; |
||
14 | |||
15 | /** |
||
16 | * @var null|string[] |
||
17 | */ |
||
18 | private $exclude = null; |
||
19 | |||
20 | |||
21 | /** |
||
22 | * @return null|string[] |
||
23 | */ |
||
24 | public function getInclude() { |
||
27 | |||
28 | |||
29 | /** |
||
30 | * @param null|string[] $include |
||
31 | * @return $this |
||
32 | */ |
||
33 | public function setInclude(array $include = null) { |
||
36 | |||
37 | |||
38 | /** |
||
39 | * @return null|\string[] |
||
40 | */ |
||
41 | public function getExclude() { |
||
44 | |||
45 | |||
46 | /** |
||
47 | * @param null|\string[] $exclude |
||
48 | * @return $this |
||
49 | */ |
||
50 | public function setExclude(array $exclude = null) { |
||
53 | |||
54 | |||
55 | /** |
||
56 | * @param FileTool $tool |
||
57 | * @return bool |
||
58 | */ |
||
59 | public function isValid(FileTool $tool) { |
||
74 | |||
75 | } |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.