1- <?php declare ( strict_types = 1 );
2-
1+ <?php
32/**
43 * Abilities API
54 *
109 * @since 0.1.0
1110 */
1211
12+ declare ( strict_types = 1 );
13+
1314/**
1415 * Encapsulates the properties and methods related to a specific ability in the registry.
1516 *
@@ -49,15 +50,15 @@ class WP_Ability {
4950 * The optional ability input schema.
5051 *
5152 * @since 0.1.0
52- * @var array
53+ * @var array<string,mixed>
5354 */
5455 protected $ input_schema = array ();
5556
5657 /**
5758 * The optional ability output schema.
5859 *
5960 * @since 0.1.0
60- * @var array
61+ * @var array<string,mixed>
6162 */
6263 protected $ output_schema = array ();
6364
@@ -81,7 +82,7 @@ class WP_Ability {
8182 * The optional ability metadata.
8283 *
8384 * @since 0.1.0
84- * @var array
85+ * @var array<string,mixed>
8586 */
8687 protected $ meta = array ();
8788
@@ -94,10 +95,10 @@ class WP_Ability {
9495 *
9596 * @since 0.1.0
9697 *
97- * @param string $name The name of the ability, with its namespace.
98- * @param array $properties An associative array of properties for the ability. This should
99- * include `label`, `description`, `input_schema`, `output_schema`,
100- * `execute_callback`, `permission_callback`, and `meta`.
98+ * @param string $name The name of the ability, with its namespace.
99+ * @param array<string,mixed> $properties An associative array of properties for the ability. This should
100+ * include `label`, `description`, `input_schema`, `output_schema`,
101+ * `execute_callback`, `permission_callback`, and `meta`.
101102 */
102103 public function __construct ( string $ name , array $ properties ) {
103104 $ this ->name = $ name ;
@@ -145,7 +146,7 @@ public function get_description(): string {
145146 *
146147 * @since 0.1.0
147148 *
148- * @return array The input schema for the ability.
149+ * @return array<string,mixed> The input schema for the ability.
149150 */
150151 public function get_input_schema (): array {
151152 return $ this ->input_schema ;
@@ -156,7 +157,7 @@ public function get_input_schema(): array {
156157 *
157158 * @since 0.1.0
158159 *
159- * @return array The output schema for the ability.
160+ * @return array<string,mixed> The output schema for the ability.
160161 */
161162 public function get_output_schema (): array {
162163 return $ this ->output_schema ;
@@ -167,7 +168,7 @@ public function get_output_schema(): array {
167168 *
168169 * @since 0.1.0
169170 *
170- * @return array The metadata for the ability.
171+ * @return array<string,mixed> The metadata for the ability.
171172 */
172173 public function get_meta (): array {
173174 return $ this ->meta ;
@@ -178,7 +179,7 @@ public function get_meta(): array {
178179 *
179180 * @since 0.1.0
180181 *
181- * @param array $input Optional. The input data to validate.
182+ * @param array<string,mixed> $input Optional. The input data to validate.
182183 * @return bool Returns true if valid, false if validation fails.
183184 */
184185 protected function validate_input ( array $ input = array () ): bool {
@@ -214,7 +215,7 @@ protected function validate_input( array $input = array() ): bool {
214215 *
215216 * @since 0.1.0
216217 *
217- * @param array $input Optional. The input data for permission checking.
218+ * @param array<string,mixed> $input Optional. The input data for permission checking.
218219 * @return bool Whether the ability has the necessary permission.
219220 */
220221 public function has_permission ( array $ input = array () ): bool {
@@ -234,8 +235,8 @@ public function has_permission( array $input = array() ): bool {
234235 *
235236 * @since 0.1.0
236237 *
237- * @param array $input The input data for the ability.
238- * @return mixed|WP_Error The result of the ability execution, or WP_Error on failure.
238+ * @param array<string,mixed> $input The input data for the ability.
239+ * @return mixed|\ WP_Error The result of the ability execution, or WP_Error on failure.
239240 */
240241 protected function do_execute ( array $ input ) {
241242 if ( ! is_callable ( $ this ->execute_callback ) ) {
@@ -292,8 +293,8 @@ protected function validate_output( $output ): bool {
292293 *
293294 * @since 0.1.0
294295 *
295- * @param array $input Optional. The input data for the ability.
296- * @return mixed|WP_Error The result of the ability execution, or WP_Error on failure.
296+ * @param array<string,mixed> $input Optional. The input data for the ability.
297+ * @return mixed|\ WP_Error The result of the ability execution, or WP_Error on failure.
297298 */
298299 public function execute ( array $ input = array () ) {
299300 if ( ! $ this ->has_permission ( $ input ) ) {
@@ -326,6 +327,6 @@ public function execute( array $input = array() ) {
326327 * @since 0.1.0
327328 */
328329 public function __wakeup (): void {
329- throw new \LogicException ( __CLASS__ . ' should never be unserialized. ' );
330+ throw new \LogicException ( self ::class . ' should never be unserialized. ' );
330331 }
331332}
0 commit comments