1 | <?php |
||
14 | final class StringCombinations implements IteratorAggregate, StringCombinationsInterface |
||
15 | { |
||
16 | /** |
||
17 | * @var string[] |
||
18 | */ |
||
19 | private $charset; |
||
20 | |||
21 | /** |
||
22 | * @var int |
||
23 | */ |
||
24 | private $min; |
||
25 | |||
26 | /** |
||
27 | * @var int |
||
28 | */ |
||
29 | private $max; |
||
30 | |||
31 | /** |
||
32 | * @var int |
||
33 | */ |
||
34 | private $count; |
||
35 | |||
36 | /** |
||
37 | * @var string |
||
38 | */ |
||
39 | private $glue; |
||
40 | |||
41 | /** |
||
42 | * StringCombination constructor. |
||
43 | * @param mixed $charset |
||
44 | * @param int $min |
||
45 | * @param int $max |
||
46 | * @param string $glue |
||
47 | * @throws \InvalidArgumentException |
||
48 | */ |
||
49 | public function __construct($charset, $min = 1, $max = null, $glue = '') |
||
65 | |||
66 | /** |
||
67 | * @return NoDuplicateLettersStringCombinations |
||
68 | */ |
||
69 | public function withoutDuplicates() |
||
73 | |||
74 | /** |
||
75 | * @inheritDoc |
||
76 | */ |
||
77 | public function count() |
||
86 | |||
87 | /** |
||
88 | * @inheritDoc |
||
89 | */ |
||
90 | public function getIterator() |
||
98 | |||
99 | /** |
||
100 | * Creates a random string from current charset |
||
101 | * @return string |
||
102 | */ |
||
103 | public function getRandomString() |
||
113 | |||
114 | /** |
||
115 | * @return array |
||
116 | */ |
||
117 | public function asArray() |
||
121 | |||
122 | /** |
||
123 | * @return \Generator |
||
124 | */ |
||
125 | private function generateSets() |
||
132 | |||
133 | private function validateCharset($charset) |
||
144 | |||
145 | /** |
||
146 | * @throws \InvalidArgumentException |
||
147 | */ |
||
148 | private function denyCharset() |
||
152 | |||
153 | /** |
||
154 | * @inheritDoc |
||
155 | */ |
||
156 | public function __get($name) |
||
160 | } |
||
161 |
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.