@@ -28,6 +28,10 @@ trait PropertyLike
2828 private array $ hooks = ['set ' => null , 'get ' => null ];
2929
3030
31+ /**
32+ * @param Visibility|'public'|'protected'|'private'|null $get
33+ * @param Visibility|'public'|'protected'|'private'|null $set
34+ */
3135 public function setVisibility (Visibility |string |null $ get , Visibility |string |null $ set = null ): static
3236 {
3337 $ this ->visibility = [
@@ -38,13 +42,15 @@ public function setVisibility(Visibility|string|null $get, Visibility|string|nul
3842 }
3943
4044
45+ /** @return 'public'|'protected'|'private'|null */
4146 public function getVisibility (PropertyAccessMode |string $ mode = PropertyAccessMode::Get): ?string
4247 {
4348 $ mode = is_string ($ mode ) ? PropertyAccessMode::from ($ mode ) : $ mode ;
4449 return $ this ->visibility [$ mode ->value ]?->value;
4550 }
4651
4752
53+ /** @param PropertyAccessMode|'set'|'get' $mode */
4854 public function setPublic (PropertyAccessMode |string $ mode = PropertyAccessMode::Get): static
4955 {
5056 $ mode = is_string ($ mode ) ? PropertyAccessMode::from ($ mode ) : $ mode ;
@@ -53,13 +59,15 @@ public function setPublic(PropertyAccessMode|string $mode = PropertyAccessMode::
5359 }
5460
5561
62+ /** @param PropertyAccessMode|'set'|'get' $mode */
5663 public function isPublic (PropertyAccessMode |string $ mode = PropertyAccessMode::Get): bool
5764 {
5865 $ mode = is_string ($ mode ) ? PropertyAccessMode::from ($ mode ) : $ mode ;
5966 return in_array ($ this ->visibility [$ mode ->value ], [Visibility::Public, null ], strict: true );
6067 }
6168
6269
70+ /** @param PropertyAccessMode|'set'|'get' $mode */
6371 public function setProtected (PropertyAccessMode |string $ mode = PropertyAccessMode::Get): static
6472 {
6573 $ mode = is_string ($ mode ) ? PropertyAccessMode::from ($ mode ) : $ mode ;
@@ -68,13 +76,15 @@ public function setProtected(PropertyAccessMode|string $mode = PropertyAccessMod
6876 }
6977
7078
79+ /** @param PropertyAccessMode|'set'|'get' $mode */
7180 public function isProtected (PropertyAccessMode |string $ mode = PropertyAccessMode::Get): bool
7281 {
7382 $ mode = is_string ($ mode ) ? PropertyAccessMode::from ($ mode ) : $ mode ;
7483 return $ this ->visibility [$ mode ->value ] === Visibility::Protected;
7584 }
7685
7786
87+ /** @param PropertyAccessMode|'set'|'get' $mode */
7888 public function setPrivate (PropertyAccessMode |string $ mode = PropertyAccessMode::Get): static
7989 {
8090 $ mode = is_string ($ mode ) ? PropertyAccessMode::from ($ mode ) : $ mode ;
@@ -83,6 +93,7 @@ public function setPrivate(PropertyAccessMode|string $mode = PropertyAccessMode:
8393 }
8494
8595
96+ /** @param PropertyAccessMode|'set'|'get' $mode */
8697 public function isPrivate (PropertyAccessMode |string $ mode = PropertyAccessMode::Get): bool
8798 {
8899 $ mode = is_string ($ mode ) ? PropertyAccessMode::from ($ mode ) : $ mode ;
@@ -118,7 +129,7 @@ public function isReadOnly(): bool
118129
119130 /**
120131 * Replaces all hooks.
121- * @param PropertyHook[] $hooks
132+ * @param array<string, PropertyHook> $hooks
122133 */
123134 public function setHooks (array $ hooks ): static
124135 {
@@ -135,6 +146,7 @@ public function getHooks(): array
135146 }
136147
137148
149+ /** @param PropertyHookType|'set'|'get' $type */
138150 public function addHook (PropertyHookType |string $ type , string $ shortBody = '' ): PropertyHook
139151 {
140152 $ type = is_string ($ type ) ? PropertyHookType::from ($ type ) : $ type ;
@@ -143,13 +155,15 @@ public function addHook(PropertyHookType|string $type, string $shortBody = ''):
143155 }
144156
145157
158+ /** @param PropertyHookType|'set'|'get' $type */
146159 public function getHook (PropertyHookType |string $ type ): ?PropertyHook
147160 {
148161 $ type = is_string ($ type ) ? PropertyHookType::from ($ type ) : $ type ;
149162 return $ this ->hooks [$ type ->value ] ?? null ;
150163 }
151164
152165
166+ /** @param PropertyHookType|'set'|'get' $type */
153167 public function hasHook (PropertyHookType |string $ type ): bool
154168 {
155169 $ type = is_string ($ type ) ? PropertyHookType::from ($ type ) : $ type ;
0 commit comments