Skip to content

Commit eada1e6

Browse files
committed
Address feedback from review regarding coding style
1 parent 36b632b commit eada1e6

File tree

10 files changed

+226
-201
lines changed

10 files changed

+226
-201
lines changed

src/wp-includes/abilities-api.php

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,45 +20,45 @@
2020
*
2121
* @see WP_Abilities_Registry::register()
2222
*
23-
* @param string $name The name of the ability. The name must be a string containing a namespace
24-
* prefix, i.e. `my-plugin/my-ability`. It can only contain lowercase
25-
* alphanumeric characters, dashes and the forward slash.
26-
* @param array<string,mixed> $args {
23+
* @param string $name The name of the ability. The name must be a string containing a namespace
24+
* prefix, i.e. `my-plugin/my-ability`. It can only contain lowercase
25+
* alphanumeric characters, dashes and the forward slash.
26+
* @param array<string, mixed> $args {
2727
* An associative array of arguments for the ability.
2828
*
29-
* @type string $label The human-readable label for the ability.
30-
* @type string $description A detailed description of what the ability does.
31-
* @type string $category The category slug this ability belongs to.
32-
* @type callable $execute_callback A callback function to execute when the ability is invoked.
33-
* Receives optional mixed input and returns mixed result or WP_Error.
34-
* @type callable $permission_callback A callback function to check permissions before execution.
35-
* Receives optional mixed input and returns bool or WP_Error.
36-
* @type array<string,mixed> $input_schema Optional. JSON Schema definition for the ability's input.
37-
* @type array<string,mixed> $output_schema Optional. JSON Schema definition for the ability's output.
38-
* @type array<string,mixed> $meta {
29+
* @type string $label The human-readable label for the ability.
30+
* @type string $description A detailed description of what the ability does.
31+
* @type string $category The category slug this ability belongs to.
32+
* @type callable $execute_callback A callback function to execute when the ability is invoked.
33+
* Receives optional mixed input and returns mixed result or WP_Error.
34+
* @type callable $permission_callback A callback function to check permissions before execution.
35+
* Receives optional mixed input and returns bool or WP_Error.
36+
* @type array<string, mixed> $input_schema Optional. JSON Schema definition for the ability's input.
37+
* @type array<string, mixed> $output_schema Optional. JSON Schema definition for the ability's output.
38+
* @type array<string, mixed> $meta {
3939
* Optional. Additional metadata for the ability.
4040
*
41-
* @type array<string,bool|string> $annotations Optional. Annotation metadata for the ability.
42-
* @type bool $show_in_rest Optional. Whether to expose this ability in the REST API. Default false.
41+
* @type array<string, bool|string> $annotations Optional. Annotation metadata for the ability.
42+
* @type bool $show_in_rest Optional. Whether to expose this ability in the REST API. Default false.
4343
* }
44-
* @type string $ability_class Optional. Custom class to instantiate instead of WP_Ability.
44+
* @type string $ability_class Optional. Custom class to instantiate instead of WP_Ability.
4545
* }
4646
* @return WP_Ability|null An instance of registered ability on success, null on failure.
4747
*
4848
* @phpstan-param array{
4949
* label?: string,
5050
* description?: string,
5151
* category?: string,
52-
* execute_callback?: callable( mixed $input= ): (mixed|\WP_Error),
53-
* permission_callback?: callable( mixed $input= ): (bool|\WP_Error),
54-
* input_schema?: array<string,mixed>,
55-
* output_schema?: array<string,mixed>,
52+
* execute_callback?: callable( mixed $input= ): (mixed|WP_Error),
53+
* permission_callback?: callable( mixed $input= ): (bool|WP_Error),
54+
* input_schema?: array<string, mixed>,
55+
* output_schema?: array<string, mixed>,
5656
* meta?: array{
57-
* annotations?: array<string,(bool|string)>,
57+
* annotations?: array<string, (bool|string)>,
5858
* show_in_rest?: bool,
59-
* ...<string,mixed>,
59+
* ...<string, mixed>,
6060
* },
61-
* ability_class?: class-string<\WP_Ability>,
61+
* ability_class?: class-string<WP_Ability>,
6262
* ...<string, mixed>
6363
* } $args
6464
*/
@@ -115,7 +115,7 @@ function wp_get_ability( string $name ): ?WP_Ability {
115115
*
116116
* @see WP_Abilities_Registry::get_all_registered()
117117
*
118-
* @return \WP_Ability[] The array of registered abilities.
118+
* @return WP_Ability[] The array of registered abilities.
119119
*/
120120
function wp_get_abilities(): array {
121121
return WP_Abilities_Registry::get_instance()->get_all_registered();
@@ -128,21 +128,21 @@ function wp_get_abilities(): array {
128128
*
129129
* @see WP_Abilities_Category_Registry::register()
130130
*
131-
* @param string $slug The unique slug for the category. Must contain only lowercase
132-
* alphanumeric characters and dashes.
133-
* @param array<string,mixed> $args {
131+
* @param string $slug The unique slug for the category. Must contain only lowercase
132+
* alphanumeric characters and dashes.
133+
* @param array<string, mixed> $args {
134134
* An associative array of arguments for the category.
135135
*
136136
* @type string $label The human-readable label for the category.
137137
* @type string $description A description of the category.
138-
* @type array<string,mixed> $meta Optional. Additional metadata for the category.
138+
* @type array<string, mixed> $meta Optional. Additional metadata for the category.
139139
* }
140140
* @return WP_Ability_Category|null The registered category instance on success, null on failure.
141141
*
142142
* @phpstan-param array{
143143
* label: string,
144144
* description: string,
145-
* meta?: array<string,mixed>,
145+
* meta?: array<string, mixed>,
146146
* ...<string, mixed>
147147
* } $args
148148
*/
@@ -185,7 +185,7 @@ function wp_get_ability_category( string $slug ): ?WP_Ability_Category {
185185
*
186186
* @see WP_Abilities_Category_Registry::get_all_registered()
187187
*
188-
* @return \WP_Ability_Category[] The array of registered categories.
188+
* @return WP_Ability_Category[] The array of registered categories.
189189
*/
190190
function wp_get_ability_categories(): array {
191191
return WP_Abilities_Category_Registry::get_instance()->get_all_registered();

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

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,21 @@ final class WP_Abilities_Category_Registry {
4343
*
4444
* @see wp_register_ability_category()
4545
*
46-
* @param string $slug The unique slug for the category. Must contain only lowercase
47-
* alphanumeric characters and dashes.
48-
* @param array<string,mixed> $args {
46+
* @param string $slug The unique slug for the category. Must contain only lowercase
47+
* alphanumeric characters and dashes.
48+
* @param array<string, mixed> $args {
4949
* An associative array of arguments for the category.
5050
*
51-
* @type string $label The human-readable label for the category.
52-
* @type string $description A description of the category.
53-
* @type array<string,mixed> $meta Optional. Additional metadata for the category.
51+
* @type string $label The human-readable label for the category.
52+
* @type string $description A description of the category.
53+
* @type array<string, mixed> $meta Optional. Additional metadata for the category.
5454
* }
5555
* @return WP_Ability_Category|null The registered category instance on success, null on failure.
5656
*
5757
* @phpstan-param array{
5858
* label: string,
5959
* description: string,
60-
* meta?: array<string,mixed>,
60+
* meta?: array<string, mixed>,
6161
* ...<string, mixed>
6262
* } $args
6363
*/
@@ -100,21 +100,21 @@ public function register( string $slug, array $args ): ?WP_Ability_Category {
100100
*
101101
* @since 6.9.0
102102
*
103-
* @param array<string,mixed> $args {
103+
* @param array<string, mixed> $args {
104104
* The arguments used to instantiate the category.
105105
*
106-
* @type string $label The human-readable label for the category.
107-
* @type string $description A description of the category.
108-
* @type array<string,mixed> $meta Optional. Additional metadata for the category.
106+
* @type string $label The human-readable label for the category.
107+
* @type string $description A description of the category.
108+
* @type array<string, mixed> $meta Optional. Additional metadata for the category.
109109
* }
110-
* @param string $slug The slug of the category.
110+
* @param string $slug The slug of the category.
111111
*/
112112
$args = apply_filters( 'register_ability_category_args', $args, $slug );
113113

114114
try {
115115
// WP_Ability_Category::prepare_properties() will throw an exception if the properties are invalid.
116116
$category = new WP_Ability_Category( $slug, $args );
117-
} catch ( \InvalidArgumentException $e ) {
117+
} catch ( InvalidArgumentException $e ) {
118118
_doing_it_wrong(
119119
__METHOD__,
120120
$e->getMessage(),
@@ -165,7 +165,7 @@ public function unregister( string $slug ): ?WP_Ability_Category {
165165
*
166166
* @see wp_get_ability_categories()
167167
*
168-
* @return array<string,\WP_Ability_Category> The array of registered categories.
168+
* @return array<string, WP_Ability_Category> The array of registered categories.
169169
*/
170170
public function get_all_registered(): array {
171171
return $this->registered_categories;
@@ -215,7 +215,7 @@ public function get_registered( string $slug ): ?WP_Ability_Category {
215215
*
216216
* @since 6.9.0
217217
*
218-
* @return \WP_Abilities_Category_Registry The main registry instance.
218+
* @return WP_Abilities_Category_Registry The main registry instance.
219219
*/
220220
public static function get_instance(): self {
221221
if ( null === self::$instance ) {
@@ -228,7 +228,7 @@ public static function get_instance(): self {
228228
*
229229
* @since 6.9.0
230230
*
231-
* @param \WP_Abilities_Category_Registry $instance Categories registry object.
231+
* @param WP_Abilities_Category_Registry $instance Categories registry object.
232232
*/
233233
do_action( 'abilities_api_categories_init', self::$instance );
234234
}
@@ -240,19 +240,21 @@ public static function get_instance(): self {
240240
* Wakeup magic method.
241241
*
242242
* @since 6.9.0
243-
* @throws \LogicException If the registry is unserialized. This is a security hardening measure to prevent unserialization of the registry.
243+
* @throws LogicException If the registry object is unserialized.
244+
* This is a security hardening measure to prevent unserialization of the registry.
244245
*/
245246
public function __wakeup(): void {
246-
throw new \LogicException( __CLASS__ . ' should never be unserialized.' );
247+
throw new LogicException( __CLASS__ . ' should never be unserialized.' );
247248
}
248249

249250
/**
250-
* Serialization magic method.
251+
* Sleep magic method.
251252
*
252253
* @since 6.9.0
253-
* @throws \LogicException If the registry is serialized. This is a security hardening measure to prevent serialization of the registry.
254+
* @throws LogicException If the registry object is serialized.
255+
* This is a security hardening measure to prevent serialization of the registry.
254256
*/
255257
public function __sleep(): array {
256-
throw new \LogicException( __CLASS__ . ' should never be serialized' );
258+
throw new LogicException( __CLASS__ . ' should never be serialized' );
257259
}
258260
}

0 commit comments

Comments
 (0)