From 2b4f77818b350fcdae9617fed7b335a257a72e69 Mon Sep 17 00:00:00 2001 From: dinamiko Date: Thu, 23 Jun 2022 11:50:08 +0200 Subject: [PATCH] Fix psalm --- .../src/Gateway/PayUponInvoice/PayUponInvoice.php | 7 +++++-- modules/ppcp-wc-gateway/src/WCGatewayModule.php | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoice.php b/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoice.php index 6d6189f12..7243d84c4 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoice.php +++ b/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoice.php @@ -347,8 +347,11 @@ class PayUponInvoice { } $national_number = filter_input( INPUT_POST, 'billing_phone', FILTER_SANITIZE_STRING ); - if ( $national_number && ! preg_match( '/^[0-9]{1,14}?$/', preg_replace( '/[^0-9]/', '', $national_number ) ) ) { - $errors->add( 'validation', __( 'Phone number size must be between 1 and 14', 'woocommerce-paypal-payments' ) ); + if ( $national_number ) { + $numeric_phone_number = preg_replace( '/[^0-9]/', '', $national_number ); + if ( $numeric_phone_number && ! preg_match( '/^[0-9]{1,14}?$/', $numeric_phone_number ) ) { + $errors->add( 'validation', __( 'Phone number size must be between 1 and 14', 'woocommerce-paypal-payments' ) ); + } } }, 10, diff --git a/modules/ppcp-wc-gateway/src/WCGatewayModule.php b/modules/ppcp-wc-gateway/src/WCGatewayModule.php index 5cd25d7e0..5d85638f1 100644 --- a/modules/ppcp-wc-gateway/src/WCGatewayModule.php +++ b/modules/ppcp-wc-gateway/src/WCGatewayModule.php @@ -256,7 +256,6 @@ class WCGatewayModule implements ModuleInterface { $logger->error( $message ); $wc_order->update_status( 'failed', $message ); } - }, 10, 2