From 1ce7a1ca2e7fb84c107292e08003e090b717a094 Mon Sep 17 00:00:00 2001 From: emilicastells Date: Thu, 1 Dec 2022 15:00:48 +0100 Subject: [PATCH] Remove param types on closures to avoid third party issues --- .../Gateway/PayUponInvoice/PayUponInvoice.php | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoice.php b/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoice.php index 06f6758a4..3e2dc8402 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoice.php +++ b/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoice.php @@ -360,7 +360,16 @@ class PayUponInvoice { add_filter( 'woocommerce_gateway_description', - function( string $description, string $id ): string { + /** + * Param types removed to avoid third-party issues. + * + * @psalm-suppress MissingClosureParamType + */ + function( $description, $id ): string { + if ( ! is_string( $description ) || ! is_string( $id ) ) { + return $description; + } + if ( PayUponInvoiceGateway::ID === $id ) { ob_start(); @@ -423,7 +432,16 @@ class PayUponInvoice { add_action( 'woocommerce_after_checkout_validation', - function( array $fields, WP_Error $errors ) { + /** + * Param types removed to avoid third-party issues. + * + * @psalm-suppress MissingClosureParamType + */ + function( $fields, WP_Error $errors ) { + if ( ! is_array( $fields ) ) { + return; + } + // phpcs:ignore WordPress.Security.NonceVerification.Missing $payment_method = wc_clean( wp_unslash( $_POST['payment_method'] ?? '' ) ); if ( PayUponInvoiceGateway::ID !== $payment_method ) { @@ -458,8 +476,13 @@ class PayUponInvoice { add_filter( 'woocommerce_available_payment_gateways', - function ( array $methods ): array { - if ( State::STATE_ONBOARDED !== $this->state->current_state() ) { + /** + * Param types removed to avoid third-party issues. + * + * @psalm-suppress MissingClosureParamType + */ + function ( $methods ): array { + if ( ! is_array( $methods ) || State::STATE_ONBOARDED !== $this->state->current_state() ) { return $methods; }