Fix psalm

This commit is contained in:
Emili Castells Guasch 2023-08-30 16:22:23 +02:00
parent 5852e45178
commit 1942acf67b
2 changed files with 4 additions and 7 deletions

View file

@ -17,6 +17,7 @@ use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
use WooCommerce\PayPalCommerce\ApiClient\Factory\WebhookEventFactory;
use WooCommerce\PayPalCommerce\ApiClient\Factory\WebhookFactory;
use Psr\Log\LoggerInterface;
use WP_Error;
/**
* Class WebhookEndpoint
@ -193,7 +194,7 @@ class WebhookEndpoint {
);
$response = $this->request( $url, $args );
if ( is_wp_error( $response ) ) {
if ( $response instanceof WP_Error ) {
throw new RuntimeException(
__( 'Not able to delete the webhook.', 'woocommerce-paypal-payments' )
);
@ -201,10 +202,7 @@ class WebhookEndpoint {
$status_code = (int) wp_remote_retrieve_response_code( $response );
if ( 204 !== $status_code ) {
$json = null;
if ( is_array( $response ) ) {
$json = json_decode( $response['body'] );
}
$json = json_decode( $response['body'] ) ?? null;
throw new PayPalApiException(
$json,
$status_code

View file

@ -112,8 +112,7 @@ class PaymentCaptureRefunded implements RequestHandler {
'amount' => $request['resource']['amount']['value'],
)
);
if ( is_wp_error( $refund ) ) {
assert( $refund instanceof WP_Error );
if ( $refund instanceof WP_Error ) {
$message = sprintf(
'Order %1$s could not be refunded. %2$s',
(string) $wc_order->get_id(),