Fix psalm

This commit is contained in:
dinamiko 2022-10-21 12:45:22 +02:00
parent f66c2322fd
commit d509a80802
3 changed files with 8 additions and 5 deletions

View file

@ -55,7 +55,7 @@ class CustomerApprovalListener {
public function listen(): void {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$token = wc_clean( wp_unslash( $_GET['approval_token_id'] ?? '' ) );
if ( ! $token ) {
if ( ! $token || is_array($token) ) {
return;
}

View file

@ -421,12 +421,12 @@ class PayUponInvoice {
// phpcs:ignore WordPress.Security.NonceVerification.Missing
$birth_date = wc_clean( wp_unslash( $_POST['billing_birth_date'] ?? '' ) );
if ( ( $birth_date && ! $this->checkout_helper->validate_birth_date( $birth_date ) ) || $birth_date === '' ) {
if ( ( $birth_date && is_string( $birth_date ) && ! $this->checkout_helper->validate_birth_date( $birth_date ) ) || $birth_date === '' ) {
$errors->add( 'validation', __( 'Invalid birth date.', 'woocommerce-paypal-payments' ) );
}
// phpcs:ignore WordPress.Security.NonceVerification.Missing
$national_number = wc_clean( wp_unslash( $_POST['billing_phone'] ?? 0 ) );
$national_number = wc_clean( wp_unslash( $_POST['billing_phone'] ?? '' ) );
if ( ! $national_number ) {
$errors->add( 'validation', __( 'Phone field cannot be empty.', 'woocommerce-paypal-payments' ) );
}
@ -532,7 +532,7 @@ class PayUponInvoice {
function( string $post_type ) {
if ( $post_type === 'shop_order' ) {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$post_id = wc_clean( wp_unslash( $_GET['post'] ?? 0 ) );
$post_id = wc_clean( wp_unslash( $_GET['post'] ?? '' ) );
$order = wc_get_order( $post_id );
if ( is_a( $order, WC_Order::class ) && $order->get_payment_method() === PayUponInvoiceGateway::ID ) {
$instructions = $order->get_meta( 'ppcp_ratepay_payment_instructions_payment_reference' );

View file

@ -26,7 +26,10 @@ class PaymentSourceFactory {
public function from_wc_order( WC_Order $order, string $birth_date ) {
$address = $order->get_address();
// phpcs:ignore WordPress.Security.NonceVerification.Missing
$phone = wc_clean( wp_unslash( $_POST['billing_phone'] ?? '' ) ) ?? $address['phone'] ?? '';
$phone = wc_clean( wp_unslash( $_POST['billing_phone'] ?? '' ) );
if ( ! $phone ) {
$phone = $address['phone'] ?? '';
}
$phone_country_code = WC()->countries->get_country_calling_code( $address['country'] );
$phone_country_code = is_array( $phone_country_code ) && ! empty( $phone_country_code ) ? $phone_country_code[0] : $phone_country_code;
if ( is_string( $phone_country_code ) && '' !== $phone_country_code ) {