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 ;
@@ -93,8 +85,8 @@ public function getData(): array
9385 */
9486 public function __set (string $ key , $ value ): void
9587 {
96- if ($ this -> parentIsSet ($ key )) {
97- $ this ->parentSet ( $ key, $ value );
88+ if (in_array ($ key, [ ' id ' , ' roles ' , ' data ' ], strict: true )) {
89+ $ this ->{ " set $ key" }( $ value );
9890
9991 } else {
10092 $ this ->data [$ key ] = $ value ;
@@ -107,8 +99,9 @@ public function __set(string $key, $value): void
10799 */
108100 public function &__get (string $ key ): mixed
109101 {
110- if ($ this ->parentIsSet ($ key )) {
111- return $ this ->parentGet ($ key );
102+ if (in_array ($ key , ['id ' , 'roles ' , 'data ' ], strict: true )) {
103+ $ res = $ this ->{"get $ key " }();
104+ return $ res ;
112105
113106 } else {
114107 return $ this ->data [$ key ];
@@ -118,6 +111,6 @@ public function &__get(string $key): mixed
118111
119112 public function __isset (string $ key ): bool
120113 {
121- return isset ($ this ->data [$ key ]) || $ this -> parentIsSet ($ key );
114+ return isset ($ this ->data [$ key ]) || in_array ($ key, [ ' id ' , ' roles ' , ' data ' ], strict: true );
122115 }
123116}
0 commit comments