1 | <?php |
||
13 | class RangeMatcher extends CountableMatcher |
||
14 | { |
||
15 | /** |
||
16 | * @var int |
||
17 | */ |
||
18 | protected $lowerBound; |
||
19 | |||
20 | /** |
||
21 | * @var int |
||
22 | */ |
||
23 | protected $upperBound; |
||
24 | |||
25 | /** |
||
26 | * @param int|float|double $lower |
||
27 | * @param int|float|double $upper |
||
28 | */ |
||
29 | public function __construct($lower, $upper) |
||
34 | |||
35 | /** |
||
36 | * {@inheritdoc} |
||
37 | * |
||
38 | * @return TemplateInterface |
||
39 | */ |
||
40 | public function getDefaultCountableTemplate() |
||
47 | |||
48 | /** |
||
49 | * {@inheritdoc} |
||
50 | * |
||
51 | * @return TemplateInterface |
||
52 | */ |
||
53 | public function getDefaultTemplate() |
||
60 | |||
61 | /** |
||
62 | * Set the lower bound of the range matcher. |
||
63 | * |
||
64 | * @param int $lowerBound |
||
65 | * @return $this |
||
66 | */ |
||
67 | public function setLowerBound($lowerBound) |
||
76 | |||
77 | /** |
||
78 | * Set the upper bound of the range matcher. |
||
79 | * |
||
80 | * @param int $upperBound |
||
81 | * @return $this |
||
82 | */ |
||
83 | public function setUpperBound($upperBound) |
||
92 | |||
93 | /** |
||
94 | * Return the lower bound of the range matcher. |
||
95 | * |
||
96 | * @return int |
||
97 | */ |
||
98 | public function getLowerBound() |
||
102 | |||
103 | /** |
||
104 | * Return the upper bound of the range matcher. |
||
105 | * |
||
106 | * @return int |
||
107 | */ |
||
108 | public function getUpperBound() |
||
112 | |||
113 | /** |
||
114 | * Determine if the number is between an upper and lower bound (inclusive). |
||
115 | * |
||
116 | * @param $number |
||
117 | * @return bool |
||
118 | */ |
||
119 | protected function matchNumeric($number) |
||
123 | } |
||
124 |
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.