2020 * @property-read mixed $id
2121 * @property-read array $roles
2222 * @property-read int $logoutReason
23- * @property IAuthenticator $authenticator
24- * @property IAuthorizator $authorizator
23+ * @property Authenticator $authenticator
24+ * @property Authorizator $authorizator
2525 */
2626class User
2727{
2828 use Nette \SmartObject;
2929
3030 /** @deprecated */
3131 public const
32- MANUAL = IUserStorage ::MANUAL ,
33- INACTIVITY = IUserStorage ::INACTIVITY ;
32+ MANUAL = UserStorage ::MANUAL ,
33+ INACTIVITY = UserStorage ::INACTIVITY ;
3434
3535 /** @var string default role for unauthenticated user */
3636 public $ guestRole = 'guest ' ;
@@ -44,13 +44,13 @@ class User
4444 /** @var callable[] function (User $sender): void; Occurs when the user is logged out */
4545 public $ onLoggedOut ;
4646
47- /** @var IUserStorage Session storage for current user */
47+ /** @var UserStorage Session storage for current user */
4848 private $ storage ;
4949
50- /** @var IAuthenticator |null */
50+ /** @var Authenticator |null */
5151 private $ authenticator ;
5252
53- /** @var IAuthorizator |null */
53+ /** @var Authorizator |null */
5454 private $ authorizator ;
5555
5656 /** @var IIdentity|false|null false means undefined */
@@ -61,17 +61,17 @@ class User
6161
6262
6363 public function __construct (
64- IUserStorage $ storage ,
65- IAuthenticator $ authenticator = null ,
66- IAuthorizator $ authorizator = null
64+ UserStorage $ storage ,
65+ Authenticator $ authenticator = null ,
66+ Authorizator $ authorizator = null
6767 ) {
6868 $ this ->storage = $ storage ;
6969 $ this ->authenticator = $ authenticator ;
7070 $ this ->authorizator = $ authorizator ;
7171 }
7272
7373
74- final public function getStorage (): IUserStorage
74+ final public function getStorage (): UserStorage
7575 {
7676 return $ this ->storage ;
7777 }
@@ -162,7 +162,7 @@ final public function refreshStorage(): void
162162 * Sets authentication handler.
163163 * @return static
164164 */
165- public function setAuthenticator (IAuthenticator $ handler )
165+ public function setAuthenticator (Authenticator $ handler )
166166 {
167167 $ this ->authenticator = $ handler ;
168168 return $ this ;
@@ -172,7 +172,7 @@ public function setAuthenticator(IAuthenticator $handler)
172172 /**
173173 * Returns authentication handler.
174174 */
175- final public function getAuthenticator (): ?IAuthenticator
175+ final public function getAuthenticator (): ?Authenticator
176176 {
177177 if (func_num_args ()) {
178178 trigger_error (__METHOD__ . '() parameter $throw is deprecated, use getAuthenticatorIfExists() ' , E_USER_DEPRECATED );
@@ -188,7 +188,7 @@ final public function getAuthenticator(): ?IAuthenticator
188188 /**
189189 * Returns authentication handler.
190190 */
191- final public function getAuthenticatorIfExists (): ?IAuthenticator
191+ final public function getAuthenticatorIfExists (): ?Authenticator
192192 {
193193 return $ this ->authenticator ;
194194 }
@@ -202,14 +202,14 @@ final public function hasAuthenticator(): bool
202202
203203
204204 /**
205- * Enables log out after inactivity (like '20 minutes'). Accepts flag IUserStorage ::CLEAR_IDENTITY.
205+ * Enables log out after inactivity (like '20 minutes'). Accepts flag UserStorage ::CLEAR_IDENTITY.
206206 * @param string|null $expire
207207 * @param int $flags
208208 * @return static
209209 */
210210 public function setExpiration ($ expire , /*int*/ $ flags = 0 )
211211 {
212- $ clearIdentity = $ flags === IUserStorage ::CLEAR_IDENTITY ;
212+ $ clearIdentity = $ flags === UserStorage ::CLEAR_IDENTITY ;
213213 if ($ expire !== null && !is_string ($ expire )) {
214214 trigger_error ("Expiration should be a string like '20 minutes' etc. " , E_USER_DEPRECATED );
215215 }
@@ -218,9 +218,9 @@ public function setExpiration($expire, /*int*/$flags = 0)
218218 }
219219 if (func_num_args () > 2 ) {
220220 $ clearIdentity = $ clearIdentity || func_get_arg (2 );
221- trigger_error (__METHOD__ . '() third parameter is deprecated, use flag setExpiration($time, IUserStorage ::CLEAR_IDENTITY) ' , E_USER_DEPRECATED );
221+ trigger_error (__METHOD__ . '() third parameter is deprecated, use flag setExpiration($time, UserStorage ::CLEAR_IDENTITY) ' , E_USER_DEPRECATED );
222222 }
223- $ this ->storage ->setExpiration ($ expire , $ clearIdentity ? IUserStorage ::CLEAR_IDENTITY : 0 );
223+ $ this ->storage ->setExpiration ($ expire , $ clearIdentity ? UserStorage ::CLEAR_IDENTITY : 0 );
224224 return $ this ;
225225 }
226226
@@ -264,7 +264,7 @@ final public function isInRole(string $role): bool
264264 * Has a user effective access to the Resource?
265265 * If $resource is null, then the query applies to all resources.
266266 */
267- public function isAllowed ($ resource = IAuthorizator ::ALL , $ privilege = IAuthorizator ::ALL ): bool
267+ public function isAllowed ($ resource = Authorizator ::ALL , $ privilege = Authorizator ::ALL ): bool
268268 {
269269 foreach ($ this ->getRoles () as $ role ) {
270270 if ($ this ->getAuthorizator ()->isAllowed ($ role , $ resource , $ privilege )) {
@@ -280,7 +280,7 @@ public function isAllowed($resource = IAuthorizator::ALL, $privilege = IAuthoriz
280280 * Sets authorization handler.
281281 * @return static
282282 */
283- public function setAuthorizator (IAuthorizator $ handler )
283+ public function setAuthorizator (Authorizator $ handler )
284284 {
285285 $ this ->authorizator = $ handler ;
286286 return $ this ;
@@ -290,7 +290,7 @@ public function setAuthorizator(IAuthorizator $handler)
290290 /**
291291 * Returns current authorization handler.
292292 */
293- final public function getAuthorizator (): ?IAuthorizator
293+ final public function getAuthorizator (): ?Authorizator
294294 {
295295 if (func_num_args ()) {
296296 trigger_error (__METHOD__ . '() parameter $throw is deprecated, use getAuthorizatorIfExists() ' , E_USER_DEPRECATED );
@@ -306,7 +306,7 @@ final public function getAuthorizator(): ?IAuthorizator
306306 /**
307307 * Returns current authorization handler.
308308 */
309- final public function getAuthorizatorIfExists (): ?IAuthorizator
309+ final public function getAuthorizatorIfExists (): ?Authorizator
310310 {
311311 return $ this ->authorizator ;
312312 }
0 commit comments