99
1010namespace Nette \Security ;
1111
12- use Nette ;
13-
1412
1513/**
1614 * @deprecated use Nette\Security\SimpleIdentity
2018 */
2119class Identity implements IIdentity
2220{
23- use Nette \SmartObject {
24- __get as private parentGet;
25- __set as private parentSet;
26- __isset as private parentIsSet;
27- }
28-
2921 private string |int $ id ;
3022 private array $ roles ;
3123 private array $ data ;
@@ -46,7 +38,6 @@ public function __construct($id, $roles = null, ?iterable $data = null)
4638 */
4739 public function setId (string |int $ id ): static
4840 {
49-
5041 $ this ->id = is_numeric ($ id ) && !is_float ($ tmp = $ id * 1 ) ? $ tmp : $ id ;
5142 return $ this ;
5243 }
@@ -94,8 +85,8 @@ public function getData(): array
9485 */
9586 public function __set (string $ key , $ value ): void
9687 {
97- if ($ this -> parentIsSet ($ key )) {
98- $ this ->parentSet ( $ key, $ value );
88+ if (in_array ($ key, [ ' id ' , ' roles ' , ' data ' ], strict: true )) {
89+ $ this ->{ " set $ key" }( $ value );
9990
10091 } else {
10192 $ this ->data [$ key ] = $ value ;
@@ -108,8 +99,9 @@ public function __set(string $key, $value): void
10899 */
109100 public function &__get (string $ key ): mixed
110101 {
111- if ($ this ->parentIsSet ($ key )) {
112- return $ this ->parentGet ($ key );
102+ if (in_array ($ key , ['id ' , 'roles ' , 'data ' ], strict: true )) {
103+ $ res = $ this ->{"get $ key " }();
104+ return $ res ;
113105
114106 } else {
115107 return $ this ->data [$ key ];
@@ -119,6 +111,6 @@ public function &__get(string $key): mixed
119111
120112 public function __isset (string $ key ): bool
121113 {
122- return isset ($ this ->data [$ key ]) || $ this -> parentIsSet ($ key );
114+ return isset ($ this ->data [$ key ]) || in_array ($ key, [ ' id ' , ' roles ' , ' data ' ], strict: true );
123115 }
124116}
0 commit comments