1 | <?php |
||
26 | class DependencyResult |
||
27 | { |
||
28 | |||
29 | const MODE_LIST = 'list'; |
||
30 | const MODE_COUNT = 'count'; |
||
31 | const MODE_DELETE = 'delete'; |
||
32 | |||
33 | /** |
||
34 | * Name of this result. |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | private $name; |
||
39 | |||
40 | /** |
||
41 | * Entities collection. |
||
42 | * |
||
43 | * @var array|\Traversable |
||
44 | */ |
||
45 | private $entities; |
||
46 | |||
47 | /** |
||
48 | * ViewScript to render the entity list with. |
||
49 | * |
||
50 | * @var string |
||
51 | */ |
||
52 | private $viewScript; |
||
53 | |||
54 | /** |
||
55 | * Description |
||
56 | * |
||
57 | * @var string |
||
58 | */ |
||
59 | private $description; |
||
60 | |||
61 | /** |
||
62 | * Mode of this result. |
||
63 | * |
||
64 | * @var string |
||
65 | */ |
||
66 | private $mode; |
||
67 | |||
68 | /** |
||
69 | * DependencyResult constructor. |
||
70 | * |
||
71 | * There are two valid options: |
||
72 | * - 'description': Sets the description. |
||
73 | * - 'viewScript': Sets the view script. |
||
74 | * |
||
75 | * @param string $name |
||
76 | * @param array|\Traversable $entities |
||
77 | * @param array|null $options |
||
78 | */ |
||
79 | public function __construct($name, $entities, array $options = null) |
||
101 | |||
102 | /** |
||
103 | * @return string |
||
104 | */ |
||
105 | public function getName() |
||
109 | |||
110 | /** |
||
111 | * @return array|\Traversable |
||
112 | */ |
||
113 | public function getEntities() |
||
117 | |||
118 | /** |
||
119 | * @return string |
||
120 | */ |
||
121 | public function getViewScript() |
||
125 | |||
126 | /** |
||
127 | * @return string |
||
128 | */ |
||
129 | public function getDescription() |
||
133 | |||
134 | public function isMode($mode) |
||
138 | |||
139 | public function isList() |
||
143 | |||
144 | public function isCount() |
||
148 | |||
149 | public function isDelete() |
||
153 | |||
154 | } |
||
155 |
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.