1 | <?php |
||
34 | class User extends Model implements IdentityInterface |
||
35 | { |
||
36 | public $id; |
||
37 | public $name; |
||
38 | public $email; |
||
39 | public $username; |
||
40 | public $type; |
||
41 | public $seller; |
||
42 | public $seller_id; |
||
43 | |||
44 | public $auth_key; |
||
45 | public $password_hash; |
||
46 | |||
47 | private static $_users = []; |
||
48 | |||
49 | public function save() |
||
54 | |||
55 | public static function findOne($id) |
||
63 | |||
64 | /** |
||
65 | * {@inheritdoc} |
||
66 | */ |
||
67 | public function rules() |
||
77 | |||
78 | /** {@inheritdoc} */ |
||
79 | public static function findIdentity($id) |
||
83 | |||
84 | /** {@inheritdoc} */ |
||
85 | public function getAccessToken() |
||
94 | |||
95 | /** |
||
96 | * {@inheritdoc} |
||
97 | */ |
||
98 | public static function findIdentityByAccessToken($token, $type = null) |
||
102 | |||
103 | /** |
||
104 | * Finds user by username. |
||
105 | * |
||
106 | * @param string $username |
||
107 | * @return static|null |
||
108 | */ |
||
109 | public static function findByUsername($username) |
||
113 | |||
114 | /** |
||
115 | * Finds user by password reset token. |
||
116 | * |
||
117 | * @param string $token password reset token |
||
118 | * @return static|null |
||
119 | */ |
||
120 | public static function findByPasswordResetToken($token) |
||
131 | |||
132 | /** |
||
133 | * Finds out if password reset token is valid. |
||
134 | * |
||
135 | * @param string $token password reset token |
||
136 | * @return boolean |
||
137 | */ |
||
138 | public static function isPasswordResetTokenValid($token) |
||
148 | |||
149 | /** |
||
150 | * {@inheritdoc} |
||
151 | */ |
||
152 | public function getId() |
||
156 | |||
157 | public function is($key) |
||
161 | |||
162 | public function not($key) |
||
166 | |||
167 | /** |
||
168 | * {@inheritdoc} |
||
169 | */ |
||
170 | public function getAuthKey() |
||
175 | |||
176 | /** |
||
177 | * {@inheritdoc} |
||
178 | */ |
||
179 | public function validateAuthKey($authKey) |
||
183 | |||
184 | /** |
||
185 | * Validates password. |
||
186 | * |
||
187 | * @param string $password password to validate |
||
188 | * @return boolean if password provided is valid for current user |
||
189 | */ |
||
190 | public function validatePassword($password) |
||
194 | |||
195 | /** |
||
196 | * Generates password hash from password and sets it to the model. |
||
197 | * |
||
198 | * @param string $password |
||
199 | */ |
||
200 | public function setPassword($password) |
||
204 | |||
205 | /** |
||
206 | * Generates "remember me" authentication key. |
||
207 | */ |
||
208 | public function generateAuthKey() |
||
213 | |||
214 | /** |
||
215 | * Generates new password reset token. |
||
216 | */ |
||
217 | public function generatePasswordResetToken() |
||
221 | |||
222 | /** |
||
223 | * Removes password reset token. |
||
224 | */ |
||
225 | public function removePasswordResetToken() |
||
229 | } |
||
230 |
Let’s assume you have a class which uses late-static binding:
The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the
getSomeVariable()
on that sub-class, you will receive a runtime error:In the case above, it makes sense to update
SomeClass
to useself
instead: