1 | <?php |
||
14 | class ComparisonExpression implements ExpressionInterface |
||
15 | { |
||
16 | const OPERATOR_LT = '<'; |
||
17 | const OPERATOR_LTE = '<='; |
||
18 | const OPERATOR_GT = '>'; |
||
19 | const OPERATOR_GTE = '>='; |
||
20 | const OPERATOR_EQ = '='; |
||
21 | |||
22 | /** @var string */ |
||
23 | protected $name; |
||
24 | |||
25 | /** @var string */ |
||
26 | protected $operator; |
||
27 | |||
28 | /** @var array|string */ |
||
29 | protected $value; |
||
30 | |||
31 | /** |
||
32 | * WhereStatement constructor. |
||
33 | * @param string $name |
||
34 | * @param string $operator |
||
35 | * @param string|array|\Wandu\Database\Contracts\ExpressionInterface $value |
||
36 | */ |
||
37 | 24 | public function __construct($name, $operator, $value) |
|
43 | |||
44 | /** |
||
45 | * {@inheritdoc} |
||
46 | */ |
||
47 | 26 | public function toSql() |
|
66 | |||
67 | /** |
||
68 | * {@inheritdoc} |
||
69 | */ |
||
70 | 26 | public function getBindings() |
|
83 | } |
||
84 |
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.