@@ -30,6 +30,10 @@ trait PropertyLike
3030 private array $ hooks = ['set ' => null , 'get ' => null ];
3131
3232
33+ /**
34+ * @param Visibility|'public'|'protected'|'private'|null $get
35+ * @param Visibility|'public'|'protected'|'private'|null $set
36+ */
3337 public function setVisibility (Visibility |string |null $ get , Visibility |string |null $ set = null ): static
3438 {
3539 $ this ->visibility = [
@@ -40,13 +44,15 @@ public function setVisibility(Visibility|string|null $get, Visibility|string|nul
4044 }
4145
4246
47+ /** @return 'public'|'protected'|'private'|null */
4348 public function getVisibility (PropertyAccessMode |string $ mode = PropertyAccessMode::Get): ?string
4449 {
4550 $ mode = is_string ($ mode ) ? PropertyAccessMode::from ($ mode ) : $ mode ;
4651 return $ this ->visibility [$ mode ->value ]?->value;
4752 }
4853
4954
55+ /** @param PropertyAccessMode|'set'|'get' $mode */
5056 public function setPublic (PropertyAccessMode |string $ mode = PropertyAccessMode::Get): static
5157 {
5258 $ mode = is_string ($ mode ) ? PropertyAccessMode::from ($ mode ) : $ mode ;
@@ -55,13 +61,15 @@ public function setPublic(PropertyAccessMode|string $mode = PropertyAccessMode::
5561 }
5662
5763
64+ /** @param PropertyAccessMode|'set'|'get' $mode */
5865 public function isPublic (PropertyAccessMode |string $ mode = PropertyAccessMode::Get): bool
5966 {
6067 $ mode = is_string ($ mode ) ? PropertyAccessMode::from ($ mode ) : $ mode ;
6168 return in_array ($ this ->visibility [$ mode ->value ], [Visibility::Public, null ], strict: true );
6269 }
6370
6471
72+ /** @param PropertyAccessMode|'set'|'get' $mode */
6573 public function setProtected (PropertyAccessMode |string $ mode = PropertyAccessMode::Get): static
6674 {
6775 $ mode = is_string ($ mode ) ? PropertyAccessMode::from ($ mode ) : $ mode ;
@@ -70,13 +78,15 @@ public function setProtected(PropertyAccessMode|string $mode = PropertyAccessMod
7078 }
7179
7280
81+ /** @param PropertyAccessMode|'set'|'get' $mode */
7382 public function isProtected (PropertyAccessMode |string $ mode = PropertyAccessMode::Get): bool
7483 {
7584 $ mode = is_string ($ mode ) ? PropertyAccessMode::from ($ mode ) : $ mode ;
7685 return $ this ->visibility [$ mode ->value ] === Visibility::Protected;
7786 }
7887
7988
89+ /** @param PropertyAccessMode|'set'|'get' $mode */
8090 public function setPrivate (PropertyAccessMode |string $ mode = PropertyAccessMode::Get): static
8191 {
8292 $ mode = is_string ($ mode ) ? PropertyAccessMode::from ($ mode ) : $ mode ;
@@ -85,6 +95,7 @@ public function setPrivate(PropertyAccessMode|string $mode = PropertyAccessMode:
8595 }
8696
8797
98+ /** @param PropertyAccessMode|'set'|'get' $mode */
8899 public function isPrivate (PropertyAccessMode |string $ mode = PropertyAccessMode::Get): bool
89100 {
90101 $ mode = is_string ($ mode ) ? PropertyAccessMode::from ($ mode ) : $ mode ;
@@ -120,7 +131,7 @@ public function isReadOnly(): bool
120131
121132 /**
122133 * Replaces all hooks.
123- * @param PropertyHook[] $hooks
134+ * @param array<string, PropertyHook> $hooks
124135 */
125136 public function setHooks (array $ hooks ): static
126137 {
@@ -137,6 +148,7 @@ public function getHooks(): array
137148 }
138149
139150
151+ /** @param PropertyHookType|'set'|'get' $type */
140152 public function addHook (PropertyHookType |string $ type , string $ shortBody = '' ): PropertyHook
141153 {
142154 $ type = is_string ($ type ) ? PropertyHookType::from ($ type ) : $ type ;
@@ -145,13 +157,15 @@ public function addHook(PropertyHookType|string $type, string $shortBody = ''):
145157 }
146158
147159
160+ /** @param PropertyHookType|'set'|'get' $type */
148161 public function getHook (PropertyHookType |string $ type ): ?PropertyHook
149162 {
150163 $ type = is_string ($ type ) ? PropertyHookType::from ($ type ) : $ type ;
151164 return $ this ->hooks [$ type ->value ] ?? null ;
152165 }
153166
154167
168+ /** @param PropertyHookType|'set'|'get' $type */
155169 public function hasHook (PropertyHookType |string $ type ): bool
156170 {
157171 $ type = is_string ($ type ) ? PropertyHookType::from ($ type ) : $ type ;
0 commit comments