22
33namespace Leaf \Auth ;
44
5+ use Exception ;
6+ use Throwable ;
7+ use ReturnTypeWillChange ;
8+ use Leaf \Db ;
59use Firebase \JWT \JWT ;
610use Leaf \Date ;
711use Leaf \Helpers \Password ;
@@ -22,7 +26,7 @@ class User
2226
2327 /**
2428 * Internal instance of Leaf database
25- * @var \Leaf\ Db
29+ * @var Db
2630 */
2731 protected $ db ;
2832
@@ -82,7 +86,7 @@ public function __construct($data, $session = true)
8286 $ sessionLifetime = strtotime ($ sessionLifetime );
8387
8488 if (!$ sessionLifetime ) {
85- throw new \ Exception ('Invalid session lifetime ' );
89+ throw new Exception ('Invalid session lifetime ' );
8690 }
8791 } else {
8892 $ sessionLifetime = time () + $ sessionLifetime ;
@@ -165,8 +169,8 @@ public function update(array $userData): bool
165169 $ this ->errorsArray = array_merge ($ this ->errorsArray , $ this ->db ->errors ());
166170 return false ;
167171 }
168- } catch (\ Throwable $ th ) {
169- throw new \ Exception ($ th ->getMessage ());
172+ } catch (Throwable $ th ) {
173+ throw new Exception ($ th ->getMessage ());
170174 }
171175
172176 if (Config::get ('session ' )) {
@@ -226,8 +230,8 @@ public function updatePassword(string $oldPassword, string $newPassword): bool
226230 $ this ->errorsArray = array_merge ($ this ->errorsArray , $ this ->db ->errors ());
227231 return false ;
228232 }
229- } catch (\ Throwable $ th ) {
230- throw new \ Exception ($ th ->getMessage ());
233+ } catch (Throwable $ th ) {
234+ throw new Exception ($ th ->getMessage ());
231235 }
232236
233237 $ this ->data [$ passwordKey ] = $ newPassword ;
@@ -268,8 +272,8 @@ public function resetPassword(string $newPassword): bool
268272 $ this ->errorsArray = array_merge ($ this ->errorsArray , $ this ->db ->errors ());
269273 return false ;
270274 }
271- } catch (\ Throwable $ th ) {
272- throw new \ Exception ($ th ->getMessage ());
275+ } catch (Throwable $ th ) {
276+ throw new Exception ($ th ->getMessage ());
273277 }
274278
275279 $ this ->data [$ passwordKey ] = $ newPassword ;
@@ -390,7 +394,7 @@ public function verifyEmail(): bool
390394 ->execute ();
391395
392396 return true ;
393- } catch (\ Throwable $ th ) {
397+ } catch (Throwable $ th ) {
394398 return false ;
395399 }
396400 }
@@ -425,7 +429,7 @@ public function get()
425429
426430 /**
427431 * Set user db instance
428- * @param \Leaf\ Db $db
432+ * @param Db $db
429433 * @return User
430434 */
431435 public function setDb ($ db )
@@ -444,6 +448,7 @@ public function errors()
444448 return $ this ->errorsArray ;
445449 }
446450
451+ #[ReturnTypeWillChange]
447452 public function __toString ()
448453 {
449454 return json_encode ($ this ->get ()) ?: '' ;
@@ -501,14 +506,14 @@ public function __unset($name)
501506 *
502507 * @param mixed $method The table to relate to
503508 * @param mixed $args
504- * @throws \ Exception
509+ * @throws Exception
505510 *
506511 * @return Model
507512 */
508513 public function __call ($ method , $ args )
509514 {
510515 if (!class_exists ('Leaf\App ' )) {
511- throw new \ Exception ('Relations are only available in Leaf apps. ' );
516+ throw new Exception ('Relations are only available in Leaf apps. ' );
512517 }
513518
514519 return (new Model ([
0 commit comments