Skip to content

Commit 75127d3

Browse files
committed
Fix PHPCS errors and configure exclusions for tests/adapters
1 parent 65c6f82 commit 75127d3

3 files changed

Lines changed: 33 additions & 7 deletions

File tree

includes/class-rest-controller.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -405,11 +405,14 @@ protected function get_timeline( $request, $user_id ) {
405405

406406
// Sort items by published date (newest first).
407407
$items = $result['items'];
408-
\usort( $items, function ( $a, $b ) {
409-
$date_a = isset( $a['published'] ) ? \strtotime( $a['published'] ) : 0;
410-
$date_b = isset( $b['published'] ) ? \strtotime( $b['published'] ) : 0;
411-
return $date_b - $date_a;
412-
} );
408+
\usort(
409+
$items,
410+
function ( $a, $b ) {
411+
$date_a = isset( $a['published'] ) ? \strtotime( $a['published'] ) : 0;
412+
$date_b = isset( $b['published'] ) ? \strtotime( $b['published'] ) : 0;
413+
return $date_b - $date_a;
414+
}
415+
);
413416

414417
// Apply limit.
415418
$items = \array_slice( $items, 0, $args['limit'] );

phpcs.xml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,28 @@
2121
<rule ref="WordPress">
2222
<exclude name="Universal.Operators.DisallowShortTernary" />
2323
</rule>
24-
<rule ref="VariableAnalysis"/>
24+
<rule ref="VariableAnalysis">
25+
<exclude-pattern>*/includes/class-adapter.php</exclude-pattern>
26+
<exclude-pattern>*/includes/adapters/*</exclude-pattern>
27+
<exclude-pattern>*/tests/*</exclude-pattern>
28+
</rule>
29+
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter">
30+
<exclude-pattern>*/includes/class-adapter.php</exclude-pattern>
31+
<exclude-pattern>*/includes/adapters/*</exclude-pattern>
32+
</rule>
33+
<rule ref="Generic.Formatting.MultipleStatementAlignment">
34+
<exclude-pattern>*/tests/*</exclude-pattern>
35+
</rule>
36+
<rule ref="WordPress.Files.FileName">
37+
<exclude-pattern>*/tests/*</exclude-pattern>
38+
</rule>
39+
<rule ref="Generic.Files.OneObjectStructurePerFile">
40+
<exclude-pattern>*/tests/*</exclude-pattern>
41+
</rule>
42+
<rule ref="Squiz.Commenting">
43+
<exclude-pattern>*/tests/*</exclude-pattern>
44+
</rule>
45+
<rule ref="WordPress.Security.EscapeOutput">
46+
<exclude-pattern>*/tests/*</exclude-pattern>
47+
</rule>
2548
</ruleset>

tests/phpunit/bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* Manually load the plugin being tested.
3030
*/
3131
function _manually_load_plugin() {
32-
require dirname( dirname( dirname( __FILE__ ) ) ) . '/microsub.php';
32+
require dirname( __DIR__, 2 ) . '/microsub.php';
3333
}
3434

3535
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );

0 commit comments

Comments
 (0)