1818 *
1919 * @property-read bool $loggedIn
2020 * @property-read IIdentity $identity
21- * @property-read mixed $id
21+ * @property-read string|int $id
2222 * @property-read array $roles
2323 * @property-read int $logoutReason
2424 * @property IAuthenticator $authenticator
@@ -79,10 +79,7 @@ public function __construct(
7979 }
8080
8181
82- /**
83- * @return UserStorage|IUserStorage
84- */
85- final public function getStorage ()
82+ final public function getStorage (): UserStorage |IUserStorage
8683 {
8784 return $ this ->storage ;
8885 }
@@ -96,7 +93,7 @@ final public function getStorage()
9693 * @param string|IIdentity $user name or Identity
9794 * @throws AuthenticationException if authentication was not successful
9895 */
99- public function login ($ user , ?string $ password = null ): void
96+ public function login (string | IIdentity $ user , ?string $ password = null ): void
10097 {
10198 $ this ->logout (true );
10299 if ($ user instanceof IIdentity) {
@@ -199,9 +196,8 @@ private function getStoredData(): void
199196
200197 /**
201198 * Returns current user ID, if any.
202- * @return mixed
203199 */
204- public function getId ()
200+ public function getId (): string | int | null
205201 {
206202 $ identity = $ this ->getIdentity ();
207203 return $ identity ? $ identity ->getId () : null ;
@@ -216,9 +212,8 @@ final public function refreshStorage(): void
216212
217213 /**
218214 * Sets authentication handler.
219- * @return static
220215 */
221- public function setAuthenticator (IAuthenticator $ handler )
216+ public function setAuthenticator (IAuthenticator $ handler ): static
222217 {
223218 $ this ->authenticator = $ handler ;
224219 return $ this ;
@@ -261,15 +256,9 @@ final public function hasAuthenticator(): bool
261256
262257 /**
263258 * Enables log out after inactivity (like '20 minutes').
264- * @param string|null $expire
265- * @param int|bool $clearIdentity
266- * @return static
267259 */
268- public function setExpiration ($ expire , $ clearIdentity = null )
260+ public function setExpiration (? string $ expire , bool | int | null $ clearIdentity = null )
269261 {
270- if ($ expire !== null && !is_string ($ expire )) {
271- trigger_error ("Expiration should be a string like '20 minutes' etc. " , E_USER_DEPRECATED );
272- }
273262
274263 if (func_num_args () > 2 ) {
275264 $ clearIdentity = $ clearIdentity || func_get_arg (2 );
@@ -343,9 +332,8 @@ public function isAllowed($resource = Authorizator::All, $privilege = Authorizat
343332
344333 /**
345334 * Sets authorization handler.
346- * @return static
347335 */
348- public function setAuthorizator (Authorizator $ handler )
336+ public function setAuthorizator (Authorizator $ handler ): static
349337 {
350338 $ this ->authorizator = $ handler ;
351339 return $ this ;
0 commit comments