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

View file

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