Skip to content

Commit fc2a70f

Browse files
committed
Address minor static analysis complaints
1 parent ea7b687 commit fc2a70f

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

plugins/image-prioritizer/helper.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,10 @@ static function ( $host ) {
292292
*
293293
* @return WP_REST_Response|WP_HTTP_Response|WP_Error|mixed Result to send to the client.
294294
* @noinspection PhpDocMissingThrowsInspection
295+
* @noinspection PhpDeprecationInspection
295296
*/
296297
function image_prioritizer_filter_rest_request_before_callbacks( $response, array $handler, WP_REST_Request $request ) {
298+
unset( $handler ); // Unused.
297299

298300
// Check for class existence and use constant or class method calls accordingly.
299301
$route_endpoint = class_exists( 'OD_REST_URL_Metrics_Store_Endpoint' )

plugins/optimization-detective/storage/class-od-rest-url-metrics-store-endpoint.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,8 @@ public function handle_rest_request( WP_REST_Request $request ) {
322322
* @return mixed Passed through $result if successful, or otherwise a WP_Error.
323323
*/
324324
public function decompress_rest_request_body( $result, WP_REST_Server $server, WP_REST_Request $request ) {
325+
unset( $server ); // Unused.
326+
325327
if (
326328
$request->get_route() === '/' . self::ROUTE_NAMESPACE . self::ROUTE_BASE &&
327329
'application/gzip' === $request->get_header( 'Content-Type' ) &&

plugins/optimization-detective/tests/storage/test-class-od-rest-url-metrics-store-endpoint.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
* Class Test_OD_REST_URL_Metrics_Store_Endpoint used to test `OD_REST_URL_Metrics_Store_Endpoint` class.
1010
*
1111
* @since n.e.x.t
12+
*
13+
* @noinspection PhpUnhandledExceptionInspection
14+
* @noinspection PhpDocMissingThrowsInspection
1215
*/
1316
class Test_OD_REST_URL_Metrics_Store_Endpoint extends WP_UnitTestCase {
1417
use Optimization_Detective_Test_Helpers;
@@ -1065,6 +1068,9 @@ private function create_request( array $params ): WP_REST_Request {
10651068
$request->set_query_params( wp_array_slice_assoc( $params, array( 'hmac', 'current_etag', 'slug', 'cache_purge_post_id' ) ) );
10661069
$request->set_header( 'Origin', home_url() );
10671070
unset( $params['hmac'], $params['slug'], $params['current_etag'], $params['cache_purge_post_id'] );
1071+
if ( ! function_exists( 'gzencode' ) ) {
1072+
throw new Exception( 'The gzencode() function is not available.' );
1073+
}
10681074
$request->set_body( gzencode( wp_json_encode( $params ) ) );
10691075
return $request;
10701076
}

0 commit comments

Comments
 (0)