Skip to content

Commit 743bc5c

Browse files
committed
added property typehints
1 parent 45036f0 commit 743bc5c

File tree

9 files changed

+44
-93
lines changed

9 files changed

+44
-93
lines changed

src/Bridges/SecurityDI/SecurityExtension.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
*/
2020
class SecurityExtension extends Nette\DI\CompilerExtension
2121
{
22-
/** @var bool */
23-
private $debugMode;
22+
private bool $debugMode;
2423

2524

2625
public function __construct(bool $debugMode = false)

src/Bridges/SecurityHttp/CookieStorage.php

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,13 @@ final class CookieStorage implements Nette\Security\UserStorage
2323

2424
private const MinLength = 13;
2525

26-
/** @var Http\IRequest */
27-
private $request;
28-
29-
/** @var Http\IResponse */
30-
private $response;
31-
32-
/** @var ?string */
33-
private $uid;
34-
35-
/** @var string */
36-
private $cookieName = 'userid';
37-
38-
/** @var ?string */
39-
private $cookieDomain;
40-
41-
/** @var string */
42-
private $cookieSameSite = 'Lax';
43-
44-
/** @var ?string */
45-
private $cookieExpiration;
26+
private Http\IRequest $request;
27+
private Http\IResponse $response;
28+
private ?string $uid = null;
29+
private string $cookieName = 'userid';
30+
private ?string $cookieDomain = null;
31+
private string $cookieSameSite = 'Lax';
32+
private ?string $cookieExpiration = null;
4633

4734

4835
public function __construct(Http\IRequest $request, Http\IResponse $response)

src/Bridges/SecurityHttp/SessionStorage.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,11 @@ final class SessionStorage implements Nette\Security\UserStorage
2222
{
2323
use Nette\SmartObject;
2424

25-
/** @var string */
26-
private $namespace = '';
27-
28-
/** @var Session */
29-
private $sessionHandler;
30-
31-
/** @var SessionSection */
32-
private $sessionSection;
33-
34-
/** @var ?int */
35-
private $expireTime;
36-
37-
/** @var bool */
38-
private $expireIdentity = false;
25+
private string $namespace = '';
26+
private Session $sessionHandler;
27+
private ?SessionSection $sessionSection = null;
28+
private ?int $expireTime = null;
29+
private bool $expireIdentity = false;
3930

4031

4132
public function __construct(Session $sessionHandler)

src/Bridges/SecurityTracy/UserPanel.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ class UserPanel implements Tracy\IBarPanel
2020
{
2121
use Nette\SmartObject;
2222

23-
/** @var Nette\Security\User */
24-
private $user;
23+
private Nette\Security\User $user;
2524

2625

2726
public function __construct(Nette\Security\User $user)

src/Security/Identity.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
/**
1616
* @deprecated use Nette\Security\SimpleIdentity
17-
* @property mixed $id
17+
* @property string|int $id
1818
* @property array $roles
1919
* @property array $data
2020
*/
@@ -26,14 +26,9 @@ class Identity implements IIdentity
2626
__isset as private parentIsSet;
2727
}
2828

29-
/** @var mixed */
30-
private $id;
31-
32-
/** @var array */
33-
private $roles;
34-
35-
/** @var array */
36-
private $data;
29+
private string|int $id;
30+
private array $roles;
31+
private array $data;
3732

3833

3934
public function __construct($id, $roles = null, ?iterable $data = null)

src/Security/Passwords.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,8 @@ class Passwords
1919
{
2020
use Nette\SmartObject;
2121

22-
/** @var int|string string since PHP 7.4 */
23-
private $algo;
24-
25-
/** @var array */
26-
private $options;
22+
private string $algo;
23+
private array $options;
2724

2825

2926
/**

src/Security/Permission.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ class Permission implements Authorizator
2121
{
2222
use Nette\SmartObject;
2323

24-
/** @var array Role storage */
25-
private $roles = [];
24+
/** Role storage */
25+
private array $roles = [];
2626

27-
/** @var array Resource storage */
28-
private $resources = [];
27+
/** Resource storage */
28+
private array $resources = [];
2929

30-
/** @var array Access Control List rules; whitelist (deny everything to all) by default */
31-
private $rules = [
30+
/** Access Control List rules; whitelist (deny everything to all) by default */
31+
private array $rules = [
3232
'allResources' => [
3333
'allRoles' => [
3434
'allPrivileges' => [
@@ -42,9 +42,7 @@ class Permission implements Authorizator
4242
'byResource' => [],
4343
];
4444

45-
/** @var mixed */
46-
private $queriedRole;
47-
45+
private mixed $queriedRole;
4846
private $queriedResource;
4947

5048

src/Security/SimpleAuthenticator.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,9 @@ class SimpleAuthenticator implements Authenticator
1919
{
2020
use Nette\SmartObject;
2121

22-
/** @var array */
23-
private $passwords;
24-
25-
/** @var array */
26-
private $roles;
27-
28-
/** @var array */
29-
private $data;
22+
private array $passwords;
23+
private array $roles;
24+
private array $data;
3025

3126

3227
/**

src/Security/User.php

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,35 +41,25 @@ class User
4141
public const LOGOUT_MANUAL = self::LogoutManual;
4242
public const LOGOUT_INACTIVITY = self::LogoutInactivity;
4343

44-
/** @var string default role for unauthenticated user */
45-
public $guestRole = 'guest';
44+
/** default role for unauthenticated user */
45+
public string $guestRole = 'guest';
4646

47-
/** @var string default role for authenticated user without own identity */
48-
public $authenticatedRole = 'authenticated';
47+
/** default role for authenticated user without own identity */
48+
public string $authenticatedRole = 'authenticated';
4949

5050
/** @var callable[] function (User $sender): void; Occurs when the user is successfully logged in */
51-
public $onLoggedIn = [];
51+
public array $onLoggedIn = [];
5252

5353
/** @var callable[] function (User $sender): void; Occurs when the user is logged out */
54-
public $onLoggedOut = [];
55-
56-
/** @var UserStorage|IUserStorage Session storage for current user */
57-
private $storage;
58-
59-
/** @var IAuthenticator|null */
60-
private $authenticator;
61-
62-
/** @var Authorizator|null */
63-
private $authorizator;
64-
65-
/** @var IIdentity|null */
66-
private $identity;
67-
68-
/** @var bool|null */
69-
private $authenticated;
70-
71-
/** @var int|null */
72-
private $logoutReason;
54+
public array $onLoggedOut = [];
55+
56+
/** Session storage for current user */
57+
private UserStorage|IUserStorage $storage;
58+
private ?IAuthenticator $authenticator;
59+
private ?Authorizator $authorizator;
60+
private ?IIdentity $identity = null;
61+
private ?bool $authenticated = null;
62+
private ?int $logoutReason = null;
7363

7464

7565
public function __construct(

0 commit comments

Comments
 (0)