From e5fe4f20b77a31f3efcff368c85f7ff2c324a427 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Thu, 7 Dec 2023 12:30:44 +0100 Subject: [PATCH] some phpcs fixes (#590) * some phpcs fixes * add default $hashalg --- activitypub.php | 2 +- build/follow-me/index.asset.php | 2 +- build/follow-me/view.asset.php | 2 +- build/followers/index.asset.php | 2 +- build/followers/view.asset.php | 2 +- includes/class-activitypub.php | 6 +++--- includes/class-admin.php | 2 +- includes/class-blocks.php | 2 +- includes/class-signature.php | 3 ++- includes/collection/class-followers.php | 2 +- includes/collection/class-interactions.php | 4 ++-- includes/rest/class-followers.php | 2 +- includes/rest/class-inbox.php | 14 +++++++------- tests/class-activitypub-testcase-cache-http.php | 2 +- .../test-class-activitypub-activity-dispatcher.php | 4 ++-- tests/test-class-activitypub-activity.php | 2 +- tests/test-class-activitypub-followers.php | 2 +- ...ctivitypub-rest-post-signature-verification.php | 2 +- 18 files changed, 29 insertions(+), 28 deletions(-) diff --git a/activitypub.php b/activitypub.php index abab5f0..55d040b 100644 --- a/activitypub.php +++ b/activitypub.php @@ -171,7 +171,7 @@ function plugin_settings_link( $actions ) { */ add_action( 'bp_include', - function() { + function () { require_once __DIR__ . '/integration/class-buddypress.php'; Integration\Buddypress::init(); }, diff --git a/build/follow-me/index.asset.php b/build/follow-me/index.asset.php index 760f433..c6138c7 100644 --- a/build/follow-me/index.asset.php +++ b/build/follow-me/index.asset.php @@ -1 +1 @@ - array('wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '6aeec6336fd28aa836a7'); + array( 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives' ), 'version' => '6aeec6336fd28aa836a7' ); diff --git a/build/follow-me/view.asset.php b/build/follow-me/view.asset.php index 76495ef..1c33822 100644 --- a/build/follow-me/view.asset.php +++ b/build/follow-me/view.asset.php @@ -1 +1 @@ - array('wp-api-fetch', 'wp-components', 'wp-compose', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '5b48281e37700a970a66'); + array( 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-primitives' ), 'version' => '5b48281e37700a970a66' ); diff --git a/build/followers/index.asset.php b/build/followers/index.asset.php index 324ac5e..fec0ba9 100644 --- a/build/followers/index.asset.php +++ b/build/followers/index.asset.php @@ -1 +1 @@ - array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives', 'wp-url'), 'version' => '59d9702e06860a6d13e4'); + array( 'react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives', 'wp-url' ), 'version' => '59d9702e06860a6d13e4' ); diff --git a/build/followers/view.asset.php b/build/followers/view.asset.php index ba6c322..305d9f5 100644 --- a/build/followers/view.asset.php +++ b/build/followers/view.asset.php @@ -1 +1 @@ - array('react', 'wp-api-fetch', 'wp-components', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '04e51e7562fe28b0b2c3'); + array( 'react', 'wp-api-fetch', 'wp-components', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url' ), 'version' => '04e51e7562fe28b0b2c3' ); diff --git a/includes/class-activitypub.php b/includes/class-activitypub.php index 6f654c5..8fbdbbf 100644 --- a/includes/class-activitypub.php +++ b/includes/class-activitypub.php @@ -374,7 +374,7 @@ class Activitypub { array( 'type' => 'string', 'single' => false, - 'sanitize_callback' => function( $value ) { + 'sanitize_callback' => function ( $value ) { if ( ! is_string( $value ) ) { throw new Exception( 'Error message is no valid string' ); } @@ -390,7 +390,7 @@ class Activitypub { array( 'type' => 'string', 'single' => false, - 'sanitize_callback' => function( $value ) { + 'sanitize_callback' => function ( $value ) { return esc_sql( $value ); }, ) @@ -402,7 +402,7 @@ class Activitypub { array( 'type' => 'string', 'single' => true, - 'sanitize_callback' => function( $value ) { + 'sanitize_callback' => function ( $value ) { return sanitize_text_field( $value ); }, ) diff --git a/includes/class-admin.php b/includes/class-admin.php index f8afc8d..7acfff9 100644 --- a/includes/class-admin.php +++ b/includes/class-admin.php @@ -172,7 +172,7 @@ class Admin { 'description' => \esc_html__( 'The Identifier of the Blog-User', 'activitypub' ), 'show_in_rest' => true, 'default' => Blog_User::get_default_username(), - 'sanitize_callback' => function( $value ) { + 'sanitize_callback' => function ( $value ) { // hack to allow dots in the username $parts = explode( '.', $value ); $sanitized = array(); diff --git a/includes/class-blocks.php b/includes/class-blocks.php index 267ebee..c127795 100644 --- a/includes/class-blocks.php +++ b/includes/class-blocks.php @@ -96,7 +96,7 @@ class Blocks { $attrs['followerData']['total'] = $follower_data['total']; $attrs['followerData']['followers'] = array_map( - function( $follower ) { + function ( $follower ) { return self::filter_array_by_keys( $follower->to_array(), array( 'icon', 'name', 'preferredUsername', 'url' ) diff --git a/includes/class-signature.php b/includes/class-signature.php index d021cf0..e59a1f9 100644 --- a/includes/class-signature.php +++ b/includes/class-signature.php @@ -292,7 +292,8 @@ class Signature { if ( is_array( $headers['digest'] ) ) { $headers['digest'] = $headers['digest'][0]; } - $digest = explode( '=', $headers['digest'], 2 ); + $hashalg = 'sha256'; + $digest = explode( '=', $headers['digest'], 2 ); if ( 'SHA-256' === $digest[0] ) { $hashalg = 'sha256'; } diff --git a/includes/collection/class-followers.php b/includes/collection/class-followers.php index be98a46..b51224f 100644 --- a/includes/collection/class-followers.php +++ b/includes/collection/class-followers.php @@ -182,7 +182,7 @@ class Followers { $query = new WP_Query( $args ); $total = $query->found_posts; $followers = array_map( - function( $post ) { + function ( $post ) { return Follower::init_from_cpt( $post ); }, $query->get_posts() diff --git a/includes/collection/class-interactions.php b/includes/collection/class-interactions.php index 7a0fdcf..87e4334 100644 --- a/includes/collection/class-interactions.php +++ b/includes/collection/class-interactions.php @@ -77,7 +77,7 @@ class Interactions { // No nonce possible for this submission route \add_filter( 'akismet_comment_nonce', - function() { + function () { return 'inactive'; } ); @@ -125,7 +125,7 @@ class Interactions { // No nonce possible for this submission route \add_filter( 'akismet_comment_nonce', - function() { + function () { return 'inactive'; } ); diff --git a/includes/rest/class-followers.php b/includes/rest/class-followers.php index 71e4840..75a1f24 100644 --- a/includes/rest/class-followers.php +++ b/includes/rest/class-followers.php @@ -94,7 +94,7 @@ class Followers { // phpcs:ignore $json->orderedItems = array_map( - function( $item ) use ( $context ) { + function ( $item ) use ( $context ) { if ( 'full' === $context ) { return $item->to_array(); } diff --git a/includes/rest/class-inbox.php b/includes/rest/class-inbox.php index bdca0f4..938ca90 100644 --- a/includes/rest/class-inbox.php +++ b/includes/rest/class-inbox.php @@ -237,7 +237,7 @@ class Inbox { $params['actor'] = array( 'required' => true, - 'sanitize_callback' => function( $param, $request, $key ) { + 'sanitize_callback' => function ( $param, $request, $key ) { return object_to_uri( $param ); }, ); @@ -246,7 +246,7 @@ class Inbox { 'required' => true, //'type' => 'enum', //'enum' => array( 'Create' ), - //'sanitize_callback' => function( $param, $request, $key ) { + //'sanitize_callback' => function ( $param, $request, $key ) { // return \strtolower( $param ); //}, ); @@ -279,7 +279,7 @@ class Inbox { $params['actor'] = array( 'required' => true, //'type' => array( 'object', 'string' ), - 'sanitize_callback' => function( $param, $request, $key ) { + 'sanitize_callback' => function ( $param, $request, $key ) { return object_to_uri( $param ); }, ); @@ -288,7 +288,7 @@ class Inbox { 'required' => true, //'type' => 'enum', //'enum' => array( 'Create' ), - //'sanitize_callback' => function( $param, $request, $key ) { + //'sanitize_callback' => function ( $param, $request, $key ) { // return \strtolower( $param ); //}, ); @@ -300,7 +300,7 @@ class Inbox { $params['to'] = array( 'required' => false, - 'sanitize_callback' => function( $param, $request, $key ) { + 'sanitize_callback' => function ( $param, $request, $key ) { if ( \is_string( $param ) ) { $param = array( $param ); } @@ -310,7 +310,7 @@ class Inbox { ); $params['cc'] = array( - 'sanitize_callback' => function( $param, $request, $key ) { + 'sanitize_callback' => function ( $param, $request, $key ) { if ( \is_string( $param ) ) { $param = array( $param ); } @@ -320,7 +320,7 @@ class Inbox { ); $params['bcc'] = array( - 'sanitize_callback' => function( $param, $request, $key ) { + 'sanitize_callback' => function ( $param, $request, $key ) { if ( \is_string( $param ) ) { $param = array( $param ); } diff --git a/tests/class-activitypub-testcase-cache-http.php b/tests/class-activitypub-testcase-cache-http.php index b8b0e43..a75c092 100644 --- a/tests/class-activitypub-testcase-cache-http.php +++ b/tests/class-activitypub-testcase-cache-http.php @@ -12,7 +12,7 @@ class ActivityPub_TestCase_Cache_HTTP extends \WP_UnitTestCase { add_filter( 'rest_url', - function() { + function () { return get_option( 'home' ) . '/wp-json/'; } ); diff --git a/tests/test-class-activitypub-activity-dispatcher.php b/tests/test-class-activitypub-activity-dispatcher.php index b7534a0..c42d391 100644 --- a/tests/test-class-activitypub-activity-dispatcher.php +++ b/tests/test-class-activitypub-activity-dispatcher.php @@ -70,7 +70,7 @@ class Test_Activitypub_Activity_Dispatcher extends ActivityPub_TestCase_Cache_HT add_filter( 'activitypub_extract_mentions', - function( $mentions ) { + function ( $mentions ) { $mentions[] = 'https://example.com/alex'; return $mentions; }, @@ -134,7 +134,7 @@ class Test_Activitypub_Activity_Dispatcher extends ActivityPub_TestCase_Cache_HT add_filter( 'activitypub_is_user_type_disabled', - function( $value, $type ) { + function ( $value, $type ) { if ( 'blog' === $type ) { return false; } else { diff --git a/tests/test-class-activitypub-activity.php b/tests/test-class-activitypub-activity.php index 6ee078e..4a524fa 100644 --- a/tests/test-class-activitypub-activity.php +++ b/tests/test-class-activitypub-activity.php @@ -12,7 +12,7 @@ class Test_Activitypub_Activity extends WP_UnitTestCase { add_filter( 'activitypub_extract_mentions', - function( $mentions ) { + function ( $mentions ) { $mentions['@alex'] = 'https://example.com/alex'; return $mentions; }, diff --git a/tests/test-class-activitypub-followers.php b/tests/test-class-activitypub-followers.php index 57201cb..8d5fb32 100644 --- a/tests/test-class-activitypub-followers.php +++ b/tests/test-class-activitypub-followers.php @@ -76,7 +76,7 @@ class Test_Activitypub_Followers extends WP_UnitTestCase { $this->assertEquals( 3, \count( $db_followers ) ); $db_followers = array_map( - function( $item ) { + function ( $item ) { return $item->get_url(); }, $db_followers diff --git a/tests/test-class-activitypub-rest-post-signature-verification.php b/tests/test-class-activitypub-rest-post-signature-verification.php index 2d1c2f9..7fa60a3 100644 --- a/tests/test-class-activitypub-rest-post-signature-verification.php +++ b/tests/test-class-activitypub-rest-post-signature-verification.php @@ -55,7 +55,7 @@ class Test_Activitypub_Signature_Verification extends WP_UnitTestCase { public function test_rest_activity_signature() { add_filter( 'pre_get_remote_metadata_by_actor', - function( $json, $actor ) { + function ( $json, $actor ) { $user = Activitypub\Collection\Users::get_by_id( 1 ); $public_key = Activitypub\Signature::get_public_key_for( $user->get__id() ); // return ActivityPub Profile with signature