Skip to content

Commit 8c93454

Browse files
committed
Adjust types to hint possible WP_Error usage in callbacks
1 parent 8330380 commit 8c93454

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

includes/abilities-api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
* input_schema?: array<string,mixed>,
3737
* output_schema?: array<string,mixed>,
3838
* execute_callback?: callable( array<string,mixed> $input): (mixed|\WP_Error),
39-
* permission_callback?: callable( ?array<string,mixed> $input ): bool,
39+
* permission_callback?: callable( array<string,mixed> $input ): (bool|\WP_Error),
4040
* meta?: array<string,mixed>,
4141
* ...<string, mixed>
4242
* } $properties

includes/abilities-api/class-wp-abilities-registry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ final class WP_Abilities_Registry {
5757
* input_schema?: array<string,mixed>,
5858
* output_schema?: array<string,mixed>,
5959
* execute_callback?: callable( array<string,mixed> $input): (mixed|\WP_Error),
60-
* permission_callback?: ?callable( ?array<string,mixed> $input ): bool,
60+
* permission_callback?: ?callable( array<string,mixed> $input ): (bool|\WP_Error),
6161
* meta?: array<string,mixed>,
6262
* ...<string, mixed>
6363
* } $properties

includes/abilities-api/class-wp-ability.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ class WP_Ability {
6666
* The ability execute callback.
6767
*
6868
* @since 0.1.0
69-
* @var callable
69+
* @var callable( array<string,mixed> $input): (mixed|\WP_Error)
7070
*/
7171
protected $execute_callback;
7272

7373
/**
7474
* The optional ability permission callback.
7575
*
7676
* @since 0.1.0
77-
* @var ?callable
77+
* @var ?callable( array<string,mixed> $input ): (bool|\WP_Error)
7878
*/
7979
protected $permission_callback = null;
8080

@@ -106,7 +106,7 @@ class WP_Ability {
106106
* input_schema?: array<string,mixed>,
107107
* output_schema?: array<string,mixed>,
108108
* execute_callback: callable( array<string,mixed> $input): (mixed|\WP_Error),
109-
* permission_callback?: ?callable( ?array<string,mixed> $input ): bool,
109+
* permission_callback?: ?callable( array<string,mixed> $input ): (bool|\WP_Error),
110110
* meta?: array<string,mixed>,
111111
* } $properties
112112
*/
@@ -262,7 +262,7 @@ public function has_permission( array $input = array() ) {
262262
*
263263
* @since 0.1.0
264264
*
265-
* @param bool $permission_result The current permission result.
265+
* @param bool|\WP_Error $permission_result The current permission result.
266266
* @param string $ability_name The ability name.
267267
* @param array<string,mixed> $input The input for the ability.
268268
* @return bool|\WP_Error The filtered permission result.

0 commit comments

Comments
 (0)