Skip to content

Commit 9fe651a

Browse files
committed
Fix code styling issues reported by phpcs
1 parent 65923ca commit 9fe651a

File tree

4 files changed

+127
-49
lines changed

4 files changed

+127
-49
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ final class WP_Abilities_Registry {
2323
* @since 0.1.0
2424
* @var WP_Ability[]
2525
*/
26-
private array $registered_abilities = [];
26+
private array $registered_abilities = array();
2727

2828
/**
2929
* Container for the main instance of the class.
@@ -152,11 +152,11 @@ public function register( $name, array $properties = array() ): ?WP_Ability {
152152
array(
153153
'label' => $properties['label'],
154154
'description' => $properties['description'],
155-
'input_schema' => $properties['input_schema'] ?? [],
156-
'output_schema' => $properties['output_schema'] ?? [],
155+
'input_schema' => $properties['input_schema'] ?? array(),
156+
'output_schema' => $properties['output_schema'] ?? array(),
157157
'execute_callback' => $properties['execute_callback'],
158158
'permission_callback' => $properties['permission_callback'] ?? null,
159-
'meta' => $properties['meta'] ?? [],
159+
'meta' => $properties['meta'] ?? array(),
160160
)
161161
);
162162
$this->registered_abilities[ $name ] = $ability;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ class WP_Ability {
5151
* @since 0.1.0
5252
* @var array
5353
*/
54-
protected array $input_schema = [];
54+
protected array $input_schema = array();
5555

5656
/**
5757
* The optional ability output schema.
5858
*
5959
* @since 0.1.0
6060
* @var array
6161
*/
62-
protected array $output_schema = [];
62+
protected array $output_schema = array();
6363

6464
/**
6565
* The ability execute callback.
@@ -83,7 +83,7 @@ class WP_Ability {
8383
* @since 0.1.0
8484
* @var array
8585
*/
86-
protected array $meta = [];
86+
protected array $meta = array();
8787

8888
/**
8989
* Constructor.

tests/phpunit/tests/abilities-api/register.php

Lines changed: 105 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,48 +11,48 @@
1111
class Tests_Abilities_API_Register extends WP_UnitTestCase {
1212

1313
public static $test_ability_name = 'test/add-numbers';
14-
public static $test_ability_properties = [];
14+
public static $test_ability_properties = array();
1515

1616
/**
1717
* Set up before each test.
1818
*/
1919
public function set_up(): void {
2020
parent::set_up();
2121

22-
self::$test_ability_properties = [
22+
self::$test_ability_properties = array(
2323
'label' => 'Add numbers',
2424
'description' => 'Calculates the result of adding two numbers.',
25-
'input_schema' => [
25+
'input_schema' => array(
2626
'type' => 'object',
27-
'properties' => [
28-
'a' => [
27+
'properties' => array(
28+
'a' => array(
2929
'type' => 'number',
3030
'description' => 'First number.',
3131
'required' => true,
32-
],
33-
'b' => [
32+
),
33+
'b' => array(
3434
'type' => 'number',
3535
'description' => 'Second number.',
3636
'required' => true,
37-
],
38-
],
37+
),
38+
),
3939
'additionalProperties' => false,
40-
],
41-
'output_schema' => [
40+
),
41+
'output_schema' => array(
4242
'type' => 'number',
4343
'description' => 'The result of adding the two numbers.',
4444
'required' => true,
45-
],
45+
),
4646
'execute_callback' => function ( array $input ): int {
4747
return $input['a'] + $input['b'];
4848
},
4949
'permission_callback' => function (): bool {
5050
return true;
5151
},
52-
'meta' => [
52+
'meta' => array(
5353
'category' => 'math',
54-
],
55-
];
54+
),
55+
);
5656
}
5757

5858
/**
@@ -76,7 +76,7 @@ public function tear_down(): void {
7676
public function test_register_ability_invalid_name(): void {
7777
do_action( 'abilities_api_init' );
7878

79-
$result = wp_register_ability( 'invalid_name', [] );
79+
$result = wp_register_ability( 'invalid_name', array() );
8080

8181
$this->assertNull( $result );
8282
}
@@ -107,8 +107,23 @@ public function test_register_valid_ability(): void {
107107
$this->assertSame( self::$test_ability_properties['input_schema'], $result->get_input_schema() );
108108
$this->assertSame( self::$test_ability_properties['output_schema'], $result->get_output_schema() );
109109
$this->assertSame( self::$test_ability_properties['meta'], $result->get_meta() );
110-
$this->assertTrue( $result->has_permission( [ 'a' => 2, 'b' => 3 ] ) );
111-
$this->assertSame( 5, $result->execute( [ 'a' => 2, 'b' => 3 ] ) );
110+
$this->assertTrue(
111+
$result->has_permission(
112+
array(
113+
'a' => 2,
114+
'b' => 3,
115+
)
116+
)
117+
);
118+
$this->assertSame(
119+
5,
120+
$result->execute(
121+
array(
122+
'a' => 2,
123+
'b' => 3,
124+
)
125+
)
126+
);
112127
}
113128

114129
/**
@@ -124,8 +139,22 @@ public function test_register_ability_no_permissions(): void {
124139
};
125140
$result = wp_register_ability( self::$test_ability_name, self::$test_ability_properties );
126141

127-
$this->assertFalse( $result->has_permission( [ 'a' => 2, 'b' => 3 ] ) );
128-
$this->assertNull( $result->execute( [ 'a' => 2, 'b' => 3 ] ) );
142+
$this->assertFalse(
143+
$result->has_permission(
144+
array(
145+
'a' => 2,
146+
'b' => 3,
147+
)
148+
)
149+
);
150+
$this->assertNull(
151+
$result->execute(
152+
array(
153+
'a' => 2,
154+
'b' => 3,
155+
)
156+
)
157+
);
129158
}
130159

131160
/**
@@ -139,7 +168,15 @@ public function test_execute_ability_no_input_schema_match(): void {
139168

140169
$result = wp_register_ability( self::$test_ability_name, self::$test_ability_properties );
141170

142-
$this->assertNull( $result->execute( [ 'a' => 2, 'b' => 3, 'unknown' => 1 ] ) );
171+
$this->assertNull(
172+
$result->execute(
173+
array(
174+
'a' => 2,
175+
'b' => 3,
176+
'unknown' => 1,
177+
)
178+
)
179+
);
143180
}
144181

145182
/**
@@ -155,7 +192,14 @@ public function test_execute_ability_no_output_schema_match(): void {
155192
};
156193
$result = wp_register_ability( self::$test_ability_name, self::$test_ability_properties );
157194

158-
$this->assertNull( $result->execute( [ 'a' => 2, 'b' => 3 ] ) );
195+
$this->assertNull(
196+
$result->execute(
197+
array(
198+
'a' => 2,
199+
'b' => 3,
200+
)
201+
)
202+
);
159203
}
160204

161205
/**
@@ -168,7 +212,15 @@ public function test_permission_callback_no_input_schema_match(): void {
168212

169213
$result = wp_register_ability( self::$test_ability_name, self::$test_ability_properties );
170214

171-
$this->assertFalse( $result->has_permission( [ 'a' => 2, 'b' => 3, 'unknown' => 1 ] ) );
215+
$this->assertFalse(
216+
$result->has_permission(
217+
array(
218+
'a' => 2,
219+
'b' => 3,
220+
'unknown' => 1,
221+
)
222+
)
223+
);
172224
}
173225

174226
/**
@@ -186,12 +238,38 @@ public function test_permission_callback_receives_input(): void {
186238
$result = wp_register_ability( self::$test_ability_name, self::$test_ability_properties );
187239

188240
// Test with a > b (should be allowed)
189-
$this->assertTrue( $result->has_permission( [ 'a' => 5, 'b' => 3 ] ) );
190-
$this->assertSame( [ 'a' => 5, 'b' => 3 ], $received_input );
241+
$this->assertTrue(
242+
$result->has_permission(
243+
array(
244+
'a' => 5,
245+
'b' => 3,
246+
)
247+
)
248+
);
249+
$this->assertSame(
250+
array(
251+
'a' => 5,
252+
'b' => 3,
253+
),
254+
$received_input
255+
);
191256

192257
// Test with a < b (should be denied)
193-
$this->assertFalse( $result->has_permission( [ 'a' => 2, 'b' => 8 ] ) );
194-
$this->assertSame( [ 'a' => 2, 'b' => 8 ], $received_input );
258+
$this->assertFalse(
259+
$result->has_permission(
260+
array(
261+
'a' => 2,
262+
'b' => 8,
263+
)
264+
)
265+
);
266+
$this->assertSame(
267+
array(
268+
'a' => 2,
269+
'b' => 8,
270+
),
271+
$received_input
272+
);
195273
}
196274

197275
/**

tests/phpunit/tests/abilities-api/wpAbilitiesRegistry.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
class Tests_Abilities_API_wpAbilitiesRegistry extends WP_UnitTestCase {
99

1010
public static $test_ability_name = 'test/add-numbers';
11-
public static $test_ability_properties = [];
11+
public static $test_ability_properties = array();
1212

1313
/**
1414
* Mock abilities registry.
@@ -25,40 +25,40 @@ public function set_up(): void {
2525

2626
$this->registry = new WP_Abilities_Registry();
2727

28-
self::$test_ability_properties = [
28+
self::$test_ability_properties = array(
2929
'label' => 'Add numbers',
3030
'description' => 'Calculates the result of adding two numbers.',
31-
'input_schema' => [
31+
'input_schema' => array(
3232
'type' => 'object',
33-
'properties' => [
34-
'a' => [
33+
'properties' => array(
34+
'a' => array(
3535
'type' => 'number',
3636
'description' => 'First number.',
3737
'required' => true,
38-
],
39-
'b' => [
38+
),
39+
'b' => array(
4040
'type' => 'number',
4141
'description' => 'Second number.',
4242
'required' => true,
43-
],
44-
],
43+
),
44+
),
4545
'additionalProperties' => false,
46-
],
47-
'output_schema' => [
46+
),
47+
'output_schema' => array(
4848
'type' => 'number',
4949
'description' => 'The result of adding the two numbers.',
5050
'required' => true,
51-
],
51+
),
5252
'execute_callback' => function ( array $input ): int {
5353
return $input['a'] + $input['b'];
5454
},
5555
'permission_callback' => function (): bool {
5656
return true;
5757
},
58-
'meta' => [
58+
'meta' => array(
5959
'category' => 'math',
60-
],
61-
];
60+
),
61+
);
6262
}
6363

6464
/**

0 commit comments

Comments
 (0)