From 2a5498ec05ff3e6cd053f2fe5cfe3bf7b1d1a3a1 Mon Sep 17 00:00:00 2001 From: Paul Kilmurray Date: Thu, 7 Mar 2024 23:34:08 +0100 Subject: [PATCH] remove bool typing for WordPress filters --- includes/API/Product_Variations_Controller.php | 2 +- includes/API/Products_Controller.php | 2 +- includes/Admin/Orders/Single_Order.php | 4 ++-- includes/Init.php | 6 +++++- tests/includes/API/Test_Product_Categories_Controller.php | 1 - 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/includes/API/Product_Variations_Controller.php b/includes/API/Product_Variations_Controller.php index 45e385b7..8ef1ebaa 100644 --- a/includes/API/Product_Variations_Controller.php +++ b/includes/API/Product_Variations_Controller.php @@ -210,7 +210,7 @@ public function wcpos_variation_response( WP_REST_Response $response, WC_Data $v * @param WP_REST_Request $request Request object. * @param bool $creating True when creating object, false when updating. */ - public function wcpos_insert_product_variation_object( WC_Data $object, WP_REST_Request $request, bool $creating ): void { + public function wcpos_insert_product_variation_object( WC_Data $object, WP_REST_Request $request, $creating ): void { $barcode_field = $this->wcpos_get_barcode_field(); if ( $request->has_param( 'barcode' ) ) { $barcode = $request->get_param( 'barcode' ); diff --git a/includes/API/Products_Controller.php b/includes/API/Products_Controller.php index a84e64c8..926ec480 100644 --- a/includes/API/Products_Controller.php +++ b/includes/API/Products_Controller.php @@ -231,7 +231,7 @@ public function wcpos_product_response( WP_REST_Response $response, WC_Product $ * @param WP_REST_Request $request Request object. * @param bool $creating True when creating object, false when updating. */ - public function wcpos_insert_product_object( WC_Data $object, WP_REST_Request $request, bool $creating ): void { + public function wcpos_insert_product_object( WC_Data $object, WP_REST_Request $request, $creating ): void { $barcode_field = $this->wcpos_get_barcode_field(); if ( $request->has_param( 'barcode' ) ) { $barcode = $request->get_param( 'barcode' ); diff --git a/includes/Admin/Orders/Single_Order.php b/includes/Admin/Orders/Single_Order.php index 70aa0fd9..fb1c9c9c 100644 --- a/includes/Admin/Orders/Single_Order.php +++ b/includes/Admin/Orders/Single_Order.php @@ -54,9 +54,9 @@ public function add_available_gateways() { * * @return bool */ - public function wc_order_is_editable( bool $is_editable, WC_Abstract_Order $order ): bool { + public function wc_order_is_editable( $is_editable, WC_Abstract_Order $order ) { if ( 'pos-open' == $order->get_status() ) { - $is_editable = true; + return true; } return $is_editable; diff --git a/includes/Init.php b/includes/Init.php index d9b0c4d8..df664b5e 100644 --- a/includes/Init.php +++ b/includes/Init.php @@ -123,6 +123,8 @@ public function init_rest_api(): void { * to work, or any other custom query variables you want to be publicly available. * * @param string[] $query_vars The array of allowed query variable names. + * + * @return string[] The array of allowed query variable names. */ public function query_vars( array $query_vars ): array { $query_vars[] = SHORT_NAME; @@ -143,7 +145,7 @@ public function query_vars( array $query_vars ): array { * * @return bool $served */ - public function rest_pre_serve_request( bool $served, WP_HTTP_Response $result, WP_REST_Request $request, WP_REST_Server $server ): bool { + public function rest_pre_serve_request( $served, WP_HTTP_Response $result, WP_REST_Request $request, WP_REST_Server $server ) { if ( 'OPTIONS' == $request->get_method() ) { $allow_headers = array( 'Authorization', // For user-agent authentication with a server. @@ -168,6 +170,8 @@ public function rest_pre_serve_request( bool $served, WP_HTTP_Response $result, * Fires once the requested HTTP headers for caching, content type, etc. have been sent. * * FIXME: Why is Link header not exposed sometimes on my development machine? + * + * @return void */ public function send_headers(): void { // some server convert HEAD to GET method, so use this query param instead diff --git a/tests/includes/API/Test_Product_Categories_Controller.php b/tests/includes/API/Test_Product_Categories_Controller.php index b9ce291c..bdbf40dc 100644 --- a/tests/includes/API/Test_Product_Categories_Controller.php +++ b/tests/includes/API/Test_Product_Categories_Controller.php @@ -207,7 +207,6 @@ public function test_unique_product_category_uuid() { $uuids = wp_list_pluck( $data, 'uuid' ); $this->assertEquals( 3, \count( $uuids ) ); - $this->assertContains( $uuid, $uuids ); $this->assertEquals( 3, \count( array_unique( $uuids ) ) ); } }