1 | <?php |
||
13 | class FormValueAssertion |
||
14 | { |
||
15 | use Debugger; |
||
16 | |||
17 | /** |
||
18 | * @var RawTqContext |
||
19 | */ |
||
20 | private $context; |
||
21 | /** |
||
22 | * @var string |
||
23 | * Field selector. |
||
24 | */ |
||
25 | private $selector = ''; |
||
26 | /** |
||
27 | * Found element. |
||
28 | * |
||
29 | * @var NodeElement |
||
30 | */ |
||
31 | private $element; |
||
32 | /** |
||
33 | * Expected value. |
||
34 | * |
||
35 | * @var string |
||
36 | */ |
||
37 | private $expected = ''; |
||
38 | /** |
||
39 | * Field element value. |
||
40 | * |
||
41 | * @var string |
||
42 | */ |
||
43 | private $value = ''; |
||
44 | /** |
||
45 | * Tag name of found element. |
||
46 | * |
||
47 | * @var string |
||
48 | */ |
||
49 | private $tag = ''; |
||
50 | /** |
||
51 | * Negate the condition. |
||
52 | * |
||
53 | * @var bool |
||
54 | */ |
||
55 | private $not = false; |
||
56 | |||
57 | /** |
||
58 | * @param RawTqContext $context |
||
59 | * Behat context. |
||
60 | * @param string $selector |
||
61 | * Field selector. |
||
62 | * @param bool $not |
||
63 | * Negate the condition. |
||
64 | * @param string $expected |
||
65 | * Expected value. |
||
66 | */ |
||
67 | public function __construct(RawTqContext $context, $selector, $not, $expected = '') |
||
78 | |||
79 | /** |
||
80 | * Check value in inputs and text areas. |
||
81 | */ |
||
82 | public function textual() |
||
101 | |||
102 | /** |
||
103 | * Ensure option is selected. |
||
104 | */ |
||
105 | public function selectable() |
||
122 | |||
123 | /** |
||
124 | * Ensure that checkbox/radio button is checked. |
||
125 | */ |
||
126 | public function checkable() |
||
138 | |||
139 | /** |
||
140 | * @param array[] $allowedElements |
||
141 | * Element machine names. |
||
142 | */ |
||
143 | private function restrictElements(array $allowedElements) |
||
161 | |||
162 | /** |
||
163 | * @param bool $value |
||
164 | * Value for checking. |
||
165 | * @param string $word |
||
166 | * A word for default message (e.g. "checked", "selected", etc). |
||
167 | * |
||
168 | * @throws \Exception |
||
169 | */ |
||
170 | private function assert($value, $word = '') |
||
190 | } |
||
191 |
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.