1 | <?php |
||
15 | class User extends BaseType implements TypeInterface |
||
16 | { |
||
17 | /** |
||
18 | * {@inheritdoc} |
||
19 | * |
||
20 | * @var array |
||
21 | */ |
||
22 | static protected $requiredParams = ['id', 'first_name']; |
||
23 | |||
24 | /** |
||
25 | * {@inheritdoc} |
||
26 | * |
||
27 | * @var array |
||
28 | */ |
||
29 | static protected $map = [ |
||
30 | 'id' => true, |
||
31 | 'first_name' => true, |
||
32 | 'last_name' => true, |
||
33 | 'username' => true, |
||
34 | 'language_code' => true, |
||
35 | ]; |
||
36 | |||
37 | /** |
||
38 | * Unique identifier for this user or bot |
||
39 | * |
||
40 | * @var int |
||
41 | */ |
||
42 | protected $id; |
||
43 | |||
44 | /** |
||
45 | * User‘s or bot’s first name |
||
46 | * |
||
47 | * @var string |
||
48 | */ |
||
49 | protected $firstName; |
||
50 | |||
51 | /** |
||
52 | * Optional. User‘s or bot’s last name |
||
53 | * |
||
54 | * @var string |
||
55 | */ |
||
56 | protected $lastName; |
||
57 | |||
58 | /** |
||
59 | * Optional. User‘s or bot’s username |
||
60 | * |
||
61 | * @var string |
||
62 | */ |
||
63 | protected $username; |
||
64 | |||
65 | /** |
||
66 | * Optional. IETF language tag of the user's language |
||
67 | * |
||
68 | * @var string |
||
69 | */ |
||
70 | protected $languageCode; |
||
71 | |||
72 | /** |
||
73 | * @return string |
||
74 | */ |
||
75 | 2 | public function getFirstName() |
|
79 | |||
80 | /** |
||
81 | * @param string $firstName |
||
82 | */ |
||
83 | 32 | public function setFirstName($firstName) |
|
87 | |||
88 | /** |
||
89 | * @return int |
||
90 | */ |
||
91 | 2 | public function getId() |
|
95 | |||
96 | /** |
||
97 | * @param int $id |
||
98 | * |
||
99 | * @throws InvalidArgumentException |
||
100 | */ |
||
101 | 34 | public function setId($id) |
|
109 | |||
110 | /** |
||
111 | * @return string |
||
112 | */ |
||
113 | 2 | public function getLastName() |
|
117 | |||
118 | /** |
||
119 | * @param string $lastName |
||
120 | */ |
||
121 | 32 | public function setLastName($lastName) |
|
125 | |||
126 | /** |
||
127 | * @return string |
||
128 | */ |
||
129 | 2 | public function getUsername() |
|
133 | |||
134 | /** |
||
135 | * @param string $username |
||
136 | */ |
||
137 | 32 | public function setUsername($username) |
|
141 | |||
142 | /** |
||
143 | * @return string |
||
144 | */ |
||
145 | public function getLanguageCode() |
||
149 | |||
150 | /** |
||
151 | * @param string $languageCode |
||
152 | */ |
||
153 | public function setLanguageCode($languageCode) |
||
157 | } |
||
158 |
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.